Chromium Code Reviews| 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 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 bt Show backtrace | 31 bt Show backtrace |
| 32 r Resume execution | 32 r Resume execution |
| 33 s Single step | 33 s Single step |
| 34 so Step over | 34 so Step over |
| 35 si Step into | 35 si Step into |
| 36 sbp [<file>] <line> Set breakpoint | 36 sbp [<file>] <line> Set breakpoint |
| 37 rbp <id> Remove breakpoint with given id | 37 rbp <id> Remove breakpoint with given id |
| 38 po <id> Print object info for given id | 38 po <id> Print object info for given id |
| 39 pc <id> Print class info for given id | 39 pc <id> Print class info for given id |
| 40 ll List loaded libraries | 40 ll List loaded libraries |
| 41 pl <id> Print dlibrary info for given id | 41 pl <id> Print library info for given id |
| 42 pg <id> Print global variables visible given library | |
|
siva
2012/06/26 18:46:28
This line doesn't seem to read well.
Did you mean
| |
| 42 ls <libname> List loaded scripts in library | 43 ls <libname> List loaded scripts in library |
| 43 gs <lib_id> <script_url> Get source text of script in library | 44 gs <lib_id> <script_url> Get source text of script in library |
| 44 epi <none|all|unhandled> Set exception pause info | 45 epi <none|all|unhandled> Set exception pause info |
| 45 h Print help | 46 h Print help |
| 46 """); | 47 """); |
| 47 } | 48 } |
| 48 | 49 |
| 49 | 50 |
| 50 void quitShell() { | 51 void quitShell() { |
| 51 vmStream.close(); | 52 vmStream.close(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 "params": {"objectId": Math.parseInt(args[1]) }}; | 114 "params": {"objectId": Math.parseInt(args[1]) }}; |
| 114 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result)); | 115 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result)); |
| 115 } else if (command == "pc" && args.length == 2) { | 116 } else if (command == "pc" && args.length == 2) { |
| 116 var cmd = { "id": seqNum, "command": "getClassProperties", | 117 var cmd = { "id": seqNum, "command": "getClassProperties", |
| 117 "params": {"classId": Math.parseInt(args[1]) }}; | 118 "params": {"classId": Math.parseInt(args[1]) }}; |
| 118 sendCmd(cmd).then((result) => handleGetClassPropsResponse(result)); | 119 sendCmd(cmd).then((result) => handleGetClassPropsResponse(result)); |
| 119 } else if (command == "pl" && args.length == 2) { | 120 } else if (command == "pl" && args.length == 2) { |
| 120 var cmd = { "id": seqNum, "command": "getLibraryProperties", | 121 var cmd = { "id": seqNum, "command": "getLibraryProperties", |
| 121 "params": {"libraryId": Math.parseInt(args[1]) }}; | 122 "params": {"libraryId": Math.parseInt(args[1]) }}; |
| 122 sendCmd(cmd).then((result) => handleGetLibraryPropsResponse(result)); | 123 sendCmd(cmd).then((result) => handleGetLibraryPropsResponse(result)); |
| 124 } else if (command == "pg" && args.length == 2) { | |
| 125 var cmd = { "id": seqNum, "command": "getGlobalVariables", | |
| 126 "params": {"libraryId": Math.parseInt(args[1]) }}; | |
| 127 sendCmd(cmd).then((result) => handleGetGlobalVarsResponse(result)); | |
| 123 } else if (command == "gs" && args.length == 3) { | 128 } else if (command == "gs" && args.length == 3) { |
| 124 var cmd = { "id": seqNum, "command": "getScriptSource", | 129 var cmd = { "id": seqNum, "command": "getScriptSource", |
| 125 "params": { "libraryId": Math.parseInt(args[1]), | 130 "params": { "libraryId": Math.parseInt(args[1]), |
| 126 "url": args[2] }}; | 131 "url": args[2] }}; |
| 127 sendCmd(cmd).then((result) => handleGetSourceResponse(result)); | 132 sendCmd(cmd).then((result) => handleGetSourceResponse(result)); |
| 128 } else if (command == "epi" && args.length == 2) { | 133 } else if (command == "epi" && args.length == 2) { |
| 129 var cmd = { "id": seqNum, "command": "setPauseOnException", | 134 var cmd = { "id": seqNum, "command": "setPauseOnException", |
| 130 "params": { "exceptions": args[1] }}; | 135 "params": { "exceptions": args[1] }}; |
| 131 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 136 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 132 } else if (command == "q") { | 137 } else if (command == "q") { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 assert(globals != null); | 212 assert(globals != null); |
| 208 if (globals.length > 0) { | 213 if (globals.length > 0) { |
| 209 print(" global variables:"); | 214 print(" global variables:"); |
| 210 for (int i = 0; i < globals.length; i++) { | 215 for (int i = 0; i < globals.length; i++) { |
| 211 printNamedObject(globals[i]); | 216 printNamedObject(globals[i]); |
| 212 } | 217 } |
| 213 } | 218 } |
| 214 } | 219 } |
| 215 | 220 |
| 216 | 221 |
| 222 handleGetGlobalVarsResponse(response) { | |
| 223 List globals = response["result"]["globals"]; | |
| 224 for (int i = 0; i < globals.length; i++) { | |
| 225 printNamedObject(globals[i]); | |
| 226 } | |
| 227 } | |
| 228 | |
| 229 | |
| 217 handleGetSourceResponse(response) { | 230 handleGetSourceResponse(response) { |
| 218 Map result = response["result"]; | 231 Map result = response["result"]; |
| 219 String source = result["text"]; | 232 String source = result["text"]; |
| 220 print("Source text:\n$source\n--------"); | 233 print("Source text:\n$source\n--------"); |
| 221 } | 234 } |
| 222 | 235 |
| 223 | 236 |
| 224 void handleGetLibraryResponse(response) { | 237 void handleGetLibraryResponse(response) { |
| 225 Map result = response["result"]; | 238 Map result = response["result"]; |
| 226 List libs = result["libraries"]; | 239 List libs = result["libraries"]; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 void handleStackTraceResponse(response) { | 273 void handleStackTraceResponse(response) { |
| 261 Map result = response["result"]; | 274 Map result = response["result"]; |
| 262 List callFrames = result["callFrames"]; | 275 List callFrames = result["callFrames"]; |
| 263 assert(callFrames != null); | 276 assert(callFrames != null); |
| 264 printStackTrace(callFrames); | 277 printStackTrace(callFrames); |
| 265 } | 278 } |
| 266 | 279 |
| 267 | 280 |
| 268 void printStackFrame(frame_num, Map frame) { | 281 void printStackFrame(frame_num, Map frame) { |
| 269 var fname = frame["functionName"]; | 282 var fname = frame["functionName"]; |
| 283 var libId = frame["libraryId"]; | |
| 270 var url = frame["location"]["url"]; | 284 var url = frame["location"]["url"]; |
| 271 var line = frame["location"]["lineNumber"]; | 285 var line = frame["location"]["lineNumber"]; |
| 272 print("$frame_num $fname ($url:$line)"); | 286 print("$frame_num $fname ($url:$line) (lib $libId)"); |
| 273 List locals = frame["locals"]; | 287 List locals = frame["locals"]; |
| 274 for (int i = 0; i < locals.length; i++) { | 288 for (int i = 0; i < locals.length; i++) { |
| 275 printNamedObject(locals[i]); | 289 printNamedObject(locals[i]); |
| 276 } | 290 } |
| 277 } | 291 } |
| 278 | 292 |
| 279 | 293 |
| 280 void printStackTrace(List frames) { | 294 void printStackTrace(List frames) { |
| 281 for (int i = 0; i < frames.length; i++) { | 295 for (int i = 0; i < frames.length; i++) { |
| 282 printStackFrame(i, frames[i]); | 296 printStackFrame(i, frames[i]); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 }; | 396 }; |
| 383 vmInStream.onError = (err) { | 397 vmInStream.onError = (err) { |
| 384 print("Error in debug connection: $err"); | 398 print("Error in debug connection: $err"); |
| 385 quitShell(); | 399 quitShell(); |
| 386 }; | 400 }; |
| 387 vmInStream.onClosed = () { | 401 vmInStream.onClosed = () { |
| 388 print("VM debugger connection closed"); | 402 print("VM debugger connection closed"); |
| 389 quitShell(); | 403 quitShell(); |
| 390 }; | 404 }; |
| 391 } | 405 } |
| OLD | NEW |