| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Simple interactive debugger shell that connects to the Dart VM's debugger | 5 // Simple interactive debugger shell that connects to the Dart VM's debugger |
| 6 // connection port. | 6 // connection port. |
| 7 | 7 |
| 8 #import("dart:io"); | 8 #import("dart:io"); |
| 9 #import("dart:json"); | 9 #import("dart:json"); |
| 10 #import("dart:math", prefix: "Math"); | 10 #import("dart:math", prefix: "Math"); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 if (nexting == 0) return index; | 519 if (nexting == 0) return index; |
| 520 } else if (char == '"') { | 520 } else if (char == '"') { |
| 521 // Strings can contain braces. Skip their content. | 521 // Strings can contain braces. Skip their content. |
| 522 index = skipString(index); | 522 index = skipString(index); |
| 523 } | 523 } |
| 524 } | 524 } |
| 525 return 0; | 525 return 0; |
| 526 } | 526 } |
| 527 | 527 |
| 528 | 528 |
| 529 void main() { | 529 void debuggerMain() { |
| 530 outstandingCommands = new Map<int, Completer>(); | 530 outstandingCommands = new Map<int, Completer>(); |
| 531 vmSock = new Socket("127.0.0.1", 5858); | 531 vmSock = new Socket("127.0.0.1", 5858); |
| 532 vmStream = new SocketOutputStream(vmSock); | 532 vmStream = new SocketOutputStream(vmSock); |
| 533 var stdinStream = new StringInputStream(stdin); | 533 var stdinStream = new StringInputStream(stdin); |
| 534 stdinStream.onLine = () { | 534 stdinStream.onLine = () { |
| 535 processCommand(stdinStream.readLine()); | 535 processCommand(stdinStream.readLine()); |
| 536 }; | 536 }; |
| 537 var vmInStream = new SocketInputStream(vmSock); | 537 var vmInStream = new SocketInputStream(vmSock); |
| 538 vmInStream.onData = () { | 538 vmInStream.onData = () { |
| 539 String s = decodeUtf8(vmInStream.read()); | 539 String s = decodeUtf8(vmInStream.read()); |
| 540 processVmData(s); | 540 processVmData(s); |
| 541 }; | 541 }; |
| 542 vmInStream.onError = (err) { | 542 vmInStream.onError = (err) { |
| 543 print("Error in debug connection: $err"); | 543 print("Error in debug connection: $err"); |
| 544 quitShell(); | 544 quitShell(); |
| 545 }; | 545 }; |
| 546 vmInStream.onClosed = () { | 546 vmInStream.onClosed = () { |
| 547 print("VM debugger connection closed"); | 547 print("VM debugger connection closed"); |
| 548 quitShell(); | 548 quitShell(); |
| 549 }; | 549 }; |
| 550 } | 550 } |
| 551 |
| 552 void main() { |
| 553 Options options = new Options(); |
| 554 List<String> arguments = options.arguments; |
| 555 if (arguments.length > 0) { |
| 556 arguments = <String>['--debug', '--verbose_debug']..addAll(arguments); |
| 557 Process.start(options.executable, arguments).then((Process process) { |
| 558 process.onExit = (int exitCode) { |
| 559 print('${Strings.join(arguments, " ")} exited with $exitCode'); |
| 560 }; |
| 561 process.stdin.close(); |
| 562 // Redirecting both stdout and stderr of the child process to |
| 563 // stdout. This should help users keep track of which errors |
| 564 // are coming from the debugger, and which errors are coming |
| 565 // from the process being debugged. |
| 566 process.stderr.pipe(stdout); |
| 567 process.stdout.pipe(stdout); |
| 568 debuggerMain(); |
| 569 }); |
| 570 } else { |
| 571 debuggerMain(); |
| 572 } |
| 573 } |
| OLD | NEW |