Chromium Code Reviews| 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 // Library used by debugger wire protocol tests (standalone VM debugging). | 5 // Library used by debugger wire protocol tests (standalone VM debugging). |
| 6 | 6 |
| 7 library DartDebugger; | 7 library DartDebugger; |
| 8 | 8 |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 import "dart:math"; | 10 import "dart:math"; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 | 448 |
| 449 void close({killDebugee: false}) { | 449 void close({killDebugee: false}) { |
| 450 if (errorsDetected) { | 450 if (errorsDetected) { |
| 451 for (int i = 0; i < errors.length; i++) print(errors[i]); | 451 for (int i = 0; i < errors.length; i++) print(errors[i]); |
| 452 } | 452 } |
| 453 if (socket != null) socket.close(); | 453 if (socket != null) socket.close(); |
| 454 if (killDebugee) { | 454 if (killDebugee) { |
| 455 targetProcess.kill(); | 455 targetProcess.kill(); |
| 456 print("Target process killed"); | 456 print("Target process killed"); |
| 457 } | 457 } |
| 458 Expect.isTrue(!errorsDetected); | 458 if (errorsDetected) throw new Exception("Errors detected"); |
|
Lasse Reichstein Nielsen
2013/04/08 11:27:49
Why use "Exception" and not "Error"?
Or perhaps ju
floitsch
2013/04/08 12:06:47
I wanted to use the Error class, but Error doesn't
floitsch
2013/04/08 16:06:59
Done.
| |
| 459 exit(errors.length); | 459 exit(errors.length); |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 | 462 |
| 463 | 463 |
| 464 bool RunScript(List script) { | 464 bool RunScript(List script) { |
| 465 var options = new Options(); | 465 var options = new Options(); |
| 466 if (options.arguments.contains("--debuggee")) { | 466 if (options.arguments.contains("--debuggee")) { |
| 467 return false; | 467 return false; |
| 468 } | 468 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 480 // is initialized. | 480 // is initialized. |
| 481 targetOpts.add("--verbose_debug"); | 481 targetOpts.add("--verbose_debug"); |
| 482 targetOpts.add(options.script); | 482 targetOpts.add(options.script); |
| 483 targetOpts.add("--debuggee"); | 483 targetOpts.add("--debuggee"); |
| 484 print('args: ${targetOpts.join(" ")}'); | 484 print('args: ${targetOpts.join(" ")}'); |
| 485 | 485 |
| 486 Process.start(options.executable, targetOpts).then((Process process) { | 486 Process.start(options.executable, targetOpts).then((Process process) { |
| 487 print("Debug target process started"); | 487 print("Debug target process started"); |
| 488 process.stdin.close(); | 488 process.stdin.close(); |
| 489 process.exitCode.then((int exitCode) { | 489 process.exitCode.then((int exitCode) { |
| 490 Expect.equals(0, exitCode); | 490 if (exitCode != 0) throw new Exception("bad exit code: $exitCode"); |
| 491 print("Debug target process exited with exit code $exitCode"); | 491 print("Debug target process exited with exit code $exitCode"); |
| 492 }); | 492 }); |
| 493 var debugger = | 493 var debugger = |
| 494 new Debugger(process, debugPort, new DebugScript(script)); | 494 new Debugger(process, debugPort, new DebugScript(script)); |
| 495 }); | 495 }); |
| 496 }, | 496 }, |
| 497 onError: (e) { | 497 onError: (e) { |
| 498 if (++retries >= 3) { | 498 if (++retries >= 3) { |
| 499 print('unable to find unused port: $e'); | 499 print('unable to find unused port: $e'); |
| 500 return -1; | 500 return -1; |
| 501 } else { | 501 } else { |
| 502 // Retry with another random port. | 502 // Retry with another random port. |
| 503 RunScript(script); | 503 RunScript(script); |
| 504 } | 504 } |
| 505 }); | 505 }); |
| 506 return true; | 506 return true; |
| 507 } | 507 } |
| OLD | NEW |