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" as json; |
10 import "dart:utf"; | 10 import "dart:utf"; |
| 11 import "dart:async"; |
11 | 12 |
12 | 13 |
13 Map<int, Completer> outstandingCommands; | 14 Map<int, Completer> outstandingCommands; |
14 | 15 |
15 Socket vmSock; | 16 Socket vmSock; |
16 String vmData; | 17 String vmData; |
17 OutputStream vmStream; | 18 OutputStream vmStream; |
18 int seqNum = 0; | 19 int seqNum = 0; |
19 int isolate_id = -1; | 20 int isolate_id = -1; |
20 | 21 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 vmSock.close(); | 60 vmSock.close(); |
60 stdin.close(); | 61 stdin.close(); |
61 } | 62 } |
62 | 63 |
63 | 64 |
64 Future sendCmd(Map<String, dynamic> cmd) { | 65 Future sendCmd(Map<String, dynamic> cmd) { |
65 var completer = new Completer(); | 66 var completer = new Completer(); |
66 int id = cmd["id"]; | 67 int id = cmd["id"]; |
67 outstandingCommands[id] = completer; | 68 outstandingCommands[id] = completer; |
68 if (verbose) { | 69 if (verbose) { |
69 print("sending: '${jsonStringify(cmd)}'"); | 70 print("sending: '${json.stringify(cmd)}'"); |
70 } | 71 } |
71 vmStream.writeString(jsonStringify(cmd)); | 72 vmStream.writeString(json.stringify(cmd)); |
72 return completer.future; | 73 return completer.future; |
73 } | 74 } |
74 | 75 |
75 | 76 |
76 void processCommand(String cmdLine) { | 77 void processCommand(String cmdLine) { |
77 seqNum++; | 78 seqNum++; |
78 var args = cmdLine.split(' '); | 79 var args = cmdLine.split(' '); |
79 if (args.length == 0) { | 80 if (args.length == 0) { |
80 return; | 81 return; |
81 } | 82 } |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 assert(reason == "exception"); | 404 assert(reason == "exception"); |
404 var excObj = msg["params"]["exception"]; | 405 var excObj = msg["params"]["exception"]; |
405 print("Isolate $isolate_id paused on exception"); | 406 print("Isolate $isolate_id paused on exception"); |
406 print(remoteObject(excObj)); | 407 print(remoteObject(excObj)); |
407 } | 408 } |
408 print("Stack trace:"); | 409 print("Stack trace:"); |
409 printStackTrace(stackTrace); | 410 printStackTrace(stackTrace); |
410 } | 411 } |
411 | 412 |
412 | 413 |
413 void processVmMessage(String json) { | 414 void processVmMessage(String jsonString) { |
414 var msg = parseJson(json); | 415 var msg = json.parse(jsonString); |
415 if (msg == null) { | 416 if (msg == null) { |
416 return; | 417 return; |
417 } | 418 } |
418 var event = msg["event"]; | 419 var event = msg["event"]; |
419 if (event == "paused") { | 420 if (event == "paused") { |
420 handlePausedEvent(msg); | 421 handlePausedEvent(msg); |
421 return; | 422 return; |
422 } | 423 } |
423 if (event == "breakpointResolved") { | 424 if (event == "breakpointResolved") { |
424 Map params = msg["params"]; | 425 Map params = msg["params"]; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // are coming from the debugger, and which errors are coming | 564 // are coming from the debugger, and which errors are coming |
564 // from the process being debugged. | 565 // from the process being debugged. |
565 process.stderr.pipe(stdout); | 566 process.stderr.pipe(stdout); |
566 process.stdout.pipe(stdout); | 567 process.stdout.pipe(stdout); |
567 debuggerMain(); | 568 debuggerMain(); |
568 }); | 569 }); |
569 } else { | 570 } else { |
570 debuggerMain(); | 571 debuggerMain(); |
571 } | 572 } |
572 } | 573 } |
OLD | NEW |