| 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 print("Unexpected exception:\n$e\n$trace"); | 451 print("Unexpected exception:\n$e\n$trace"); |
| 452 close(killDebugee: true); | 452 close(killDebugee: true); |
| 453 } | 453 } |
| 454 }, | 454 }, |
| 455 onDone: () { | 455 onDone: () { |
| 456 print("Connection closed by debug target"); | 456 print("Connection closed by debug target"); |
| 457 close(killDebugee: true); | 457 close(killDebugee: true); |
| 458 }, | 458 }, |
| 459 onError: (e) { | 459 onError: (e) { |
| 460 print("Error '$e' detected in input stream from debug target"); | 460 print("Error '$e' detected in input stream from debug target"); |
| 461 var trace = getAttachedStackTrace(e); |
| 462 if (trace != null) print("StackTrace: $trace"); |
| 461 close(killDebugee: true); | 463 close(killDebugee: true); |
| 462 }); | 464 }); |
| 463 }, | 465 }, |
| 464 onError: (asyncErr) { | 466 onError: (e) { |
| 465 error("Error while connecting to debugee: $asyncErr"); | 467 String msg = "Error while connecting to debugee: $e"; |
| 468 var trace = getAttachedStackTrace(e); |
| 469 if (trace != null) msg += "\nStackTrace: $trace"; |
| 470 error(msg); |
| 466 close(killDebugee: true); | 471 close(killDebugee: true); |
| 467 }); | 472 }); |
| 468 } | 473 } |
| 469 | 474 |
| 470 void close({killDebugee: false}) { | 475 void close({killDebugee: false}) { |
| 471 if (errorsDetected) { | 476 if (errorsDetected) { |
| 472 for (int i = 0; i < errors.length; i++) print(errors[i]); | 477 for (int i = 0; i < errors.length; i++) print(errors[i]); |
| 473 } | 478 } |
| 474 if (socket != null) socket.close(); | 479 if (socket != null) socket.close(); |
| 475 if (killDebugee) { | 480 if (killDebugee) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 if (exitCode != 0) throw "bad exit code: $exitCode"; | 516 if (exitCode != 0) throw "bad exit code: $exitCode"; |
| 512 print("Debug target process exited with exit code $exitCode"); | 517 print("Debug target process exited with exit code $exitCode"); |
| 513 }); | 518 }); |
| 514 var debugger = | 519 var debugger = |
| 515 new Debugger(process, debugPort, new DebugScript(script)); | 520 new Debugger(process, debugPort, new DebugScript(script)); |
| 516 }); | 521 }); |
| 517 }, | 522 }, |
| 518 onError: (e) { | 523 onError: (e) { |
| 519 if (++retries >= 3) { | 524 if (++retries >= 3) { |
| 520 print('unable to find unused port: $e'); | 525 print('unable to find unused port: $e'); |
| 526 var trace = getAttachedStackTrace(e); |
| 527 if (trace != null) print("StackTrace: $trace"); |
| 521 return -1; | 528 return -1; |
| 522 } else { | 529 } else { |
| 523 // Retry with another random port. | 530 // Retry with another random port. |
| 524 RunScript(script); | 531 RunScript(script); |
| 525 } | 532 } |
| 526 }); | 533 }); |
| 527 return true; | 534 return true; |
| 528 } | 535 } |
| OLD | NEW |