| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // This test forks a second vm process that runs a dart script as | 5 // This test forks a second vm process that runs a dart script as |
| 6 // a debug target, single stepping through the entire program, and | 6 // a debug target, single stepping through the entire program, and |
| 7 // recording each breakpoint. At the end, a coverage map of the source | 7 // recording each breakpoint. At the end, a coverage map of the source |
| 8 // is printed. | 8 // is printed. |
| 9 // | 9 // |
| 10 // Usage: dart coverage.dart [--wire] [--verbose] target_script.dart | 10 // Usage: dart coverage.dart [--wire] [--verbose] target_script.dart |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 Source(this.url); | 72 Source(this.url); |
| 73 | 73 |
| 74 void recordBp(int tokenPos) { | 74 void recordBp(int tokenPos) { |
| 75 var count = tokenCounts[tokenPos]; | 75 var count = tokenCounts[tokenPos]; |
| 76 tokenCounts[tokenPos] = count == null ? 1 : count + 1; | 76 tokenCounts[tokenPos] = count == null ? 1 : count + 1; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void SetLineInfo(List lineInfoTable) { | 79 void SetLineInfo(List lineInfoTable) { |
| 80 // Each line is encoded as an array with first element being the line | 80 // Each line is encoded as an array with first element being the line |
| 81 // number, followed by pairs of (tokenPosition, textOffset). | 81 // number, followed by pairs of (tokenPosition, columnNumber). |
| 82 lineInfoTable.forEach((List<int> line) { | 82 lineInfoTable.forEach((List<int> line) { |
| 83 int lineNumber = line[0]; | 83 int lineNumber = line[0]; |
| 84 for (int t = 1; t < line.length; t += 2) { | 84 for (int t = 1; t < line.length; t += 2) { |
| 85 assert(tokenPosToLine[line[t]] == null); | 85 assert(tokenPosToLine[line[t]] == null); |
| 86 tokenPosToLine[line[t]] = lineNumber; | 86 tokenPosToLine[line[t]] = lineNumber; |
| 87 } | 87 } |
| 88 }); | 88 }); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Print out the annotated source code. For each line that has seen | 91 // Print out the annotated source code. For each line that has seen |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 targetOpts.add(str); | 538 targetOpts.add(str); |
| 539 break; | 539 break; |
| 540 } | 540 } |
| 541 } | 541 } |
| 542 | 542 |
| 543 Process.start(options.executable, targetOpts).then((Process process) { | 543 Process.start(options.executable, targetOpts).then((Process process) { |
| 544 process.stdin.close(); | 544 process.stdin.close(); |
| 545 debugger = new Debugger(process); | 545 debugger = new Debugger(process); |
| 546 }); | 546 }); |
| 547 } | 547 } |
| OLD | NEW |