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:async"; | 10 import "dart:async"; |
11 | 11 |
12 | 12 |
13 Map<int, Completer> outstandingCommands; | 13 Map<int, Completer> outstandingCommands; |
14 | 14 |
15 Socket vmSock; | 15 Socket vmSock; |
16 String vmData; | 16 String vmData; |
17 var stdinSubscription; | 17 var stdinSubscription; |
18 var vmSubscription; | 18 var vmSubscription; |
19 int seqNum = 0; | 19 int seqNum = 0; |
20 int isolate_id = -1; | 20 int isolate_id = -1; |
21 | 21 |
22 final verbose = false; | 22 final verbose = false; |
23 final printMessages = false; | 23 final printMessages = true; |
24 | 24 |
25 // The location of the last paused event. | 25 // The location of the last paused event. |
26 Map pausedLocation = null; | 26 Map pausedLocation = null; |
27 | 27 |
28 | 28 |
29 void printHelp() { | 29 void printHelp() { |
30 print(""" | 30 print(""" |
31 q Quit debugger shell | 31 q Quit debugger shell |
32 bt Show backtrace | 32 bt Show backtrace |
33 r Resume execution | 33 r Resume execution |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 var kind = value["kind"]; | 241 var kind = value["kind"]; |
242 var text = value["text"]; | 242 var text = value["text"]; |
243 var id = value["objectId"]; | 243 var id = value["objectId"]; |
244 if (kind == "string") { | 244 if (kind == "string") { |
245 return "(string, id $id) '$text'"; | 245 return "(string, id $id) '$text'"; |
246 } else if (kind == "list") { | 246 } else if (kind == "list") { |
247 var len = value["length"]; | 247 var len = value["length"]; |
248 return "(list, id $id, len $len) $text"; | 248 return "(list, id $id, len $len) $text"; |
249 } else if (kind == "object") { | 249 } else if (kind == "object") { |
250 return "(obj, id $id) $text"; | 250 return "(obj, id $id) $text"; |
| 251 } else if (kind == "function") { |
| 252 var location = value['location'] != null |
| 253 ? ", file '${value['location']['url']}'" |
| 254 ", token pos ${value['location']['tokenOffset']}" |
| 255 : ""; |
| 256 var name = value['name']; |
| 257 var signature = value['signature']; |
| 258 return "(closure ${name}${signature} $location)"; |
251 } else { | 259 } else { |
252 return "$text"; | 260 return "$text"; |
253 } | 261 } |
254 } | 262 } |
255 | 263 |
256 | 264 |
257 printNamedObject(obj) { | 265 printNamedObject(obj) { |
258 var name = obj["name"]; | 266 var name = obj["name"]; |
259 var value = obj["value"]; | 267 var value = obj["value"]; |
260 print(" $name = ${remoteObject(value)}"); | 268 print(" $name = ${remoteObject(value)}"); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 process.stdin.close(); | 641 process.stdin.close(); |
634 process.exitCode.then((int exitCode) { | 642 process.exitCode.then((int exitCode) { |
635 print('${arguments.join(" ")} exited with $exitCode'); | 643 print('${arguments.join(" ")} exited with $exitCode'); |
636 }); | 644 }); |
637 debuggerMain(); | 645 debuggerMain(); |
638 }); | 646 }); |
639 } else { | 647 } else { |
640 debuggerMain(); | 648 debuggerMain(); |
641 } | 649 } |
642 } | 650 } |
OLD | NEW |