| 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 17 matching lines...) Expand all Loading... |
| 28 class Program { | 28 class Program { |
| 29 static int numBps = 0; | 29 static int numBps = 0; |
| 30 | 30 |
| 31 // Maps source code url to source. | 31 // Maps source code url to source. |
| 32 static var sources = new Map<String, Source>(); | 32 static var sources = new Map<String, Source>(); |
| 33 | 33 |
| 34 // Takes a JSON Debugger response and increments the count for | 34 // Takes a JSON Debugger response and increments the count for |
| 35 // the source position. | 35 // the source position. |
| 36 static void recordBp(Debugger debugger, Map<String,dynamic> msg) { | 36 static void recordBp(Debugger debugger, Map<String,dynamic> msg) { |
| 37 // Progress indicator. | 37 // Progress indicator. |
| 38 if (++numBps % 100 == 0) print(numBps); | 38 if (++numBps % 1000 == 0) print(numBps); |
| 39 var location = msg["params"]["location"]; | 39 var location = msg["params"]["location"]; |
| 40 if (location == null) return; | 40 if (location == null) return; |
| 41 String url = location["url"]; | 41 String url = location["url"]; |
| 42 assert(url != null); | 42 assert(url != null); |
| 43 int tokenPos = location["tokenOffset"];; | 43 int tokenPos = location["tokenOffset"];; |
| 44 Source s = sources[url]; | 44 Source s = sources[url]; |
| 45 if (s == null) { | 45 if (s == null) { |
| 46 debugger.GetLineNumberTable(url); | 46 debugger.GetLineNumberTable(url); |
| 47 s = new Source(url); | 47 s = new Source(url); |
| 48 sources[url] = s; | 48 sources[url] = s; |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 targetOpts.add(str); | 485 targetOpts.add(str); |
| 486 break; | 486 break; |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 | 489 |
| 490 Process.start(options.executable, targetOpts).then((Process process) { | 490 Process.start(options.executable, targetOpts).then((Process process) { |
| 491 process.stdin.close(); | 491 process.stdin.close(); |
| 492 var debugger = new Debugger(process); | 492 var debugger = new Debugger(process); |
| 493 }); | 493 }); |
| 494 } | 494 } |
| OLD | NEW |