| 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:convert"; | 8 import "dart:convert"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 import "dart:json" as json; | |
| 11 import "dart:async"; | 10 import "dart:async"; |
| 12 | 11 |
| 13 | 12 |
| 14 Map<int, Completer> outstandingCommands; | 13 Map<int, Completer> outstandingCommands; |
| 15 | 14 |
| 16 Socket vmSock; | 15 Socket vmSock; |
| 17 String vmData; | 16 String vmData; |
| 18 var stdinSubscription; | 17 var stdinSubscription; |
| 19 var vmSubscription; | 18 var vmSubscription; |
| 20 int seqNum = 0; | 19 int seqNum = 0; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 vmSock.close(); | 61 vmSock.close(); |
| 63 stdinSubscription.cancel(); | 62 stdinSubscription.cancel(); |
| 64 } | 63 } |
| 65 | 64 |
| 66 | 65 |
| 67 Future sendCmd(Map<String, dynamic> cmd) { | 66 Future sendCmd(Map<String, dynamic> cmd) { |
| 68 var completer = new Completer(); | 67 var completer = new Completer(); |
| 69 int id = cmd["id"]; | 68 int id = cmd["id"]; |
| 70 outstandingCommands[id] = completer; | 69 outstandingCommands[id] = completer; |
| 71 if (verbose) { | 70 if (verbose) { |
| 72 print("sending: '${json.stringify(cmd)}'"); | 71 print("sending: '${JSON.encode(cmd)}'"); |
| 73 } | 72 } |
| 74 vmSock.write(json.stringify(cmd)); | 73 vmSock.write(JSON.encode(cmd)); |
| 75 return completer.future; | 74 return completer.future; |
| 76 } | 75 } |
| 77 | 76 |
| 78 void processCommand(String cmdLine) { | 77 void processCommand(String cmdLine) { |
| 79 | 78 |
| 80 void huh() { | 79 void huh() { |
| 81 print("'$cmdLine' not understood, try h for help"); | 80 print("'$cmdLine' not understood, try h for help"); |
| 82 } | 81 } |
| 83 | 82 |
| 84 seqNum++; | 83 seqNum++; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } else { | 454 } else { |
| 456 assert(reason == "exception"); | 455 assert(reason == "exception"); |
| 457 var excObj = msg["params"]["exception"]; | 456 var excObj = msg["params"]["exception"]; |
| 458 print("Isolate $isolate_id paused on exception"); | 457 print("Isolate $isolate_id paused on exception"); |
| 459 print(remoteObject(excObj)); | 458 print(remoteObject(excObj)); |
| 460 } | 459 } |
| 461 } | 460 } |
| 462 | 461 |
| 463 | 462 |
| 464 void processVmMessage(String jsonString) { | 463 void processVmMessage(String jsonString) { |
| 465 var msg = json.parse(jsonString); | 464 var msg = JSON.decode(jsonString); |
| 466 if (msg == null) { | 465 if (msg == null) { |
| 467 return; | 466 return; |
| 468 } | 467 } |
| 469 var event = msg["event"]; | 468 var event = msg["event"]; |
| 470 if (event == "paused") { | 469 if (event == "paused") { |
| 471 handlePausedEvent(msg); | 470 handlePausedEvent(msg); |
| 472 return; | 471 return; |
| 473 } | 472 } |
| 474 if (event == "breakpointResolved") { | 473 if (event == "breakpointResolved") { |
| 475 Map params = msg["params"]; | 474 Map params = msg["params"]; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 process.stdin.close(); | 632 process.stdin.close(); |
| 634 process.exitCode.then((int exitCode) { | 633 process.exitCode.then((int exitCode) { |
| 635 print('${arguments.join(" ")} exited with $exitCode'); | 634 print('${arguments.join(" ")} exited with $exitCode'); |
| 636 }); | 635 }); |
| 637 debuggerMain(); | 636 debuggerMain(); |
| 638 }); | 637 }); |
| 639 } else { | 638 } else { |
| 640 debuggerMain(); | 639 debuggerMain(); |
| 641 } | 640 } |
| 642 } | 641 } |
| OLD | NEW |