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 #import("dart:math", prefix: "Math"); | 10 #import("dart:math", prefix: "Math"); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 po <id> Print object info for given id | 41 po <id> Print object info for given id |
| 42 pl <id> <idx> [<len>] Print list element/slice | 42 pl <id> <idx> [<len>] Print list element/slice |
| 43 pc <id> Print class info for given id | 43 pc <id> Print class info for given id |
| 44 ll List loaded libraries | 44 ll List loaded libraries |
| 45 plib <id> Print library info for given library id | 45 plib <id> Print library info for given library id |
| 46 slib <id> <true|false> Set library id debuggable | 46 slib <id> <true|false> Set library id debuggable |
| 47 pg <id> Print all global variables visible within given library id | 47 pg <id> Print all global variables visible within given library id |
| 48 ls <lib_id> List loaded scripts in library | 48 ls <lib_id> List loaded scripts in library |
| 49 gs <lib_id> <script_url> Get source text of script in library | 49 gs <lib_id> <script_url> Get source text of script in library |
| 50 epi <none|all|unhandled> Set exception pause info | 50 epi <none|all|unhandled> Set exception pause info |
| 51 i <id> Interrupt execution of given isolate id | |
|
hausner
2012/10/05 18:06:34
Don't you also want/need a command to list isolate
siva
2012/10/05 22:35:06
Yes, but I haven't added that yet. That is the nex
| |
| 51 h Print help | 52 h Print help |
| 52 """); | 53 """); |
| 53 } | 54 } |
| 54 | 55 |
| 55 | 56 |
| 56 void quitShell() { | 57 void quitShell() { |
| 57 vmStream.close(); | 58 vmStream.close(); |
| 58 vmSock.close(); | 59 vmSock.close(); |
| 59 stdin.close(); | 60 stdin.close(); |
| 60 } | 61 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 sendCmd(cmd).then((result) => handleGetGlobalVarsResponse(result)); | 151 sendCmd(cmd).then((result) => handleGetGlobalVarsResponse(result)); |
| 151 } else if (command == "gs" && args.length == 3) { | 152 } else if (command == "gs" && args.length == 3) { |
| 152 var cmd = { "id": seqNum, "command": "getScriptSource", | 153 var cmd = { "id": seqNum, "command": "getScriptSource", |
| 153 "params": { "libraryId": Math.parseInt(args[1]), | 154 "params": { "libraryId": Math.parseInt(args[1]), |
| 154 "url": args[2] }}; | 155 "url": args[2] }}; |
| 155 sendCmd(cmd).then((result) => handleGetSourceResponse(result)); | 156 sendCmd(cmd).then((result) => handleGetSourceResponse(result)); |
| 156 } else if (command == "epi" && args.length == 2) { | 157 } else if (command == "epi" && args.length == 2) { |
| 157 var cmd = { "id": seqNum, "command": "setPauseOnException", | 158 var cmd = { "id": seqNum, "command": "setPauseOnException", |
| 158 "params": { "exceptions": args[1] }}; | 159 "params": { "exceptions": args[1] }}; |
| 159 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 160 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 161 } else if (command == "i" && args.length == 2) { | |
| 162 var cmd = { "id": seqNum, "command": "interrupt", | |
| 163 "params": {"isolateId": Math.parseInt(args[1]) }}; | |
| 164 sendCmd(cmd).then((result) => handleGenericResponse(result)); | |
| 160 } else if (command == "q") { | 165 } else if (command == "q") { |
| 161 quitShell(); | 166 quitShell(); |
| 162 } else if (command == "h") { | 167 } else if (command == "h") { |
| 163 printHelp(); | 168 printHelp(); |
| 164 } else { | 169 } else { |
| 165 print("command '$command' not understood, try h for help"); | 170 print("command '$command' not understood, try h for help"); |
| 166 } | 171 } |
| 167 } | 172 } |
| 168 | 173 |
| 169 | 174 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 void printStackTrace(List frames) { | 354 void printStackTrace(List frames) { |
| 350 for (int i = 0; i < frames.length; i++) { | 355 for (int i = 0; i < frames.length; i++) { |
| 351 printStackFrame(i, frames[i]); | 356 printStackFrame(i, frames[i]); |
| 352 } | 357 } |
| 353 } | 358 } |
| 354 | 359 |
| 355 | 360 |
| 356 void handlePausedEvent(msg) { | 361 void handlePausedEvent(msg) { |
| 357 assert(msg["params"] != null); | 362 assert(msg["params"] != null); |
| 358 var reason = msg["params"]["reason"]; | 363 var reason = msg["params"]["reason"]; |
| 364 var id = msg["params"]["id"]; | |
| 359 stackTrace = msg["params"]["callFrames"]; | 365 stackTrace = msg["params"]["callFrames"]; |
| 360 assert(stackTrace != null); | 366 assert(stackTrace != null); |
| 361 assert(stackTrace.length >= 1); | 367 assert(stackTrace.length >= 1); |
| 362 curFrame = stackTrace[0]; | 368 curFrame = stackTrace[0]; |
| 363 if (reason == "breakpoint") { | 369 if (reason == "breakpoint") { |
| 364 print("VM paused on breakpoint"); | 370 print("Isolate $id paused on breakpoint"); |
| 371 } else if (reason == "interrupted") { | |
| 372 print("Isolate $id paused due to an interrupt"); | |
| 365 } else { | 373 } else { |
| 366 assert(reason == "exception"); | 374 assert(reason == "exception"); |
| 367 var excObj = msg["params"]["exception"]; | 375 var excObj = msg["params"]["exception"]; |
| 368 print("VM paused on exception"); | 376 print("Isolate $id paused on exception"); |
| 369 print(remoteObject(excObj)); | 377 print(remoteObject(excObj)); |
| 370 } | 378 } |
| 371 print("Stack trace:"); | 379 print("Stack trace:"); |
| 372 printStackTrace(stackTrace); | 380 printStackTrace(stackTrace); |
| 373 } | 381 } |
| 374 | 382 |
| 375 | 383 |
| 376 void processVmMessage(String json) { | 384 void processVmMessage(String json) { |
| 377 var msg = JSON.parse(json); | 385 var msg = JSON.parse(json); |
| 378 if (msg == null) { | 386 if (msg == null) { |
| 379 return; | 387 return; |
| 380 } | 388 } |
| 381 var event = msg["event"]; | 389 var event = msg["event"]; |
| 382 if (event == "paused") { | 390 if (event == "paused") { |
| 383 handlePausedEvent(msg); | 391 handlePausedEvent(msg); |
| 384 return; | 392 return; |
| 385 } | 393 } |
| 386 if (event == "breakpointResolved") { | 394 if (event == "breakpointResolved") { |
| 387 Map params = msg["params"]; | 395 Map params = msg["params"]; |
| 388 assert(params != null); | 396 assert(params != null); |
| 389 print("BP ${params["breakpointId"]} resolved and " | 397 print("BP ${params["breakpointId"]} resolved and " |
| 390 "set at line ${params["line"]}."); | 398 "set at line ${params["line"]}."); |
| 391 return; | 399 return; |
| 392 } | 400 } |
| 401 if (event == "isolate") { | |
| 402 Map params = msg["params"]; | |
| 403 assert(params != null); | |
| 404 print("Isolate ${params["id"]} has been ${params["reason"]}."); | |
| 405 return; | |
| 406 } | |
| 393 if (msg["id"] != null) { | 407 if (msg["id"] != null) { |
| 394 var id = msg["id"]; | 408 var id = msg["id"]; |
| 395 if (outstandingCommands.containsKey(id)) { | 409 if (outstandingCommands.containsKey(id)) { |
| 396 if (msg["error"] != null) { | 410 if (msg["error"] != null) { |
| 397 print("VM says: ${msg["error"]}"); | 411 print("VM says: ${msg["error"]}"); |
| 398 } else { | 412 } else { |
| 399 var completer = outstandingCommands[id]; | 413 var completer = outstandingCommands[id]; |
| 400 completer.complete(msg); | 414 completer.complete(msg); |
| 401 } | 415 } |
| 402 outstandingCommands.remove(id); | 416 outstandingCommands.remove(id); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 }; | 511 }; |
| 498 vmInStream.onError = (err) { | 512 vmInStream.onError = (err) { |
| 499 print("Error in debug connection: $err"); | 513 print("Error in debug connection: $err"); |
| 500 quitShell(); | 514 quitShell(); |
| 501 }; | 515 }; |
| 502 vmInStream.onClosed = () { | 516 vmInStream.onClosed = () { |
| 503 print("VM debugger connection closed"); | 517 print("VM debugger connection closed"); |
| 504 quitShell(); | 518 quitShell(); |
| 505 }; | 519 }; |
| 506 } | 520 } |
| OLD | NEW |