| 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" as json; | 9 import "dart:json" as json; |
| 10 import "dart:utf"; | 10 import "dart:utf"; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 pl <id> <idx> [<len>] Print list element/slice | 41 pl <id> <idx> [<len>] Print list element/slice |
| 42 pc <id> Print class info for given id | 42 pc <id> Print class info for given id |
| 43 ll List loaded libraries | 43 ll List loaded libraries |
| 44 plib <id> Print library info for given library id | 44 plib <id> Print library info for given library id |
| 45 slib <id> <true|false> Set library id debuggable | 45 slib <id> <true|false> Set library id debuggable |
| 46 pg <id> Print all global variables visible within given library id | 46 pg <id> Print all global variables visible within given library id |
| 47 ls <lib_id> List loaded scripts in library | 47 ls <lib_id> List loaded scripts in library |
| 48 gs <lib_id> <script_url> Get source text of script in library | 48 gs <lib_id> <script_url> Get source text of script in library |
| 49 tok <lib_id> <script_url> Get line and token table of script in library | 49 tok <lib_id> <script_url> Get line and token table of script in library |
| 50 epi <none|all|unhandled> Set exception pause info | 50 epi <none|all|unhandled> Set exception pause info |
| 51 li List ids of all isolates in the VM |
| 51 i <id> Interrupt execution of given isolate id | 52 i <id> Interrupt execution of given isolate id |
| 52 h Print help | 53 h Print help |
| 53 """); | 54 """); |
| 54 } | 55 } |
| 55 | 56 |
| 56 | 57 |
| 57 void quitShell() { | 58 void quitShell() { |
| 58 vmSubscription.cancel(); | 59 vmSubscription.cancel(); |
| 59 vmSock.close(); | 60 vmSock.close(); |
| 60 stdinSubscription.cancel(); | 61 stdinSubscription.cancel(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 "params": { "isolateId" : isolate_id, | 187 "params": { "isolateId" : isolate_id, |
| 187 "libraryId": int.parse(args[1]), | 188 "libraryId": int.parse(args[1]), |
| 188 "url": args[2] } }; | 189 "url": args[2] } }; |
| 189 sendCmd(cmd).then((result) => handleGetLineTableResponse(result)); | 190 sendCmd(cmd).then((result) => handleGetLineTableResponse(result)); |
| 190 } else if (command == "epi" && args.length == 2) { | 191 } else if (command == "epi" && args.length == 2) { |
| 191 var cmd = { "id": seqNum, | 192 var cmd = { "id": seqNum, |
| 192 "command": "setPauseOnException", | 193 "command": "setPauseOnException", |
| 193 "params": { "isolateId" : isolate_id, | 194 "params": { "isolateId" : isolate_id, |
| 194 "exceptions": args[1] } }; | 195 "exceptions": args[1] } }; |
| 195 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 196 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 197 } else if (command == "li") { |
| 198 var cmd = { "id": seqNum, "command": "getIsolateIds" }; |
| 199 sendCmd(cmd).then((result) => handleGetIsolatesResponse(result)); |
| 196 } else if (command == "i" && args.length == 2) { | 200 } else if (command == "i" && args.length == 2) { |
| 197 var cmd = { "id": seqNum, | 201 var cmd = { "id": seqNum, |
| 198 "command": "interrupt", | 202 "command": "interrupt", |
| 199 "params": { "isolateId": int.parse(args[1]) } }; | 203 "params": { "isolateId": int.parse(args[1]) } }; |
| 200 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 204 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 201 } else if (command == "q") { | 205 } else if (command == "q") { |
| 202 quitShell(); | 206 quitShell(); |
| 203 } else if (command == "h") { | 207 } else if (command == "h") { |
| 204 printHelp(); | 208 printHelp(); |
| 205 } else { | 209 } else { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 334 } |
| 331 | 335 |
| 332 | 336 |
| 333 handleGetLineTableResponse(response) { | 337 handleGetLineTableResponse(response) { |
| 334 Map result = response["result"]; | 338 Map result = response["result"]; |
| 335 var info = result["lines"]; | 339 var info = result["lines"]; |
| 336 print("Line info table:\n$info"); | 340 print("Line info table:\n$info"); |
| 337 } | 341 } |
| 338 | 342 |
| 339 | 343 |
| 344 handleGetIsolatesResponse(response) { |
| 345 Map result = response["result"]; |
| 346 print("Isolates: ${result["isolateIds"]}"); |
| 347 } |
| 348 |
| 349 |
| 340 void handleGetLibraryResponse(response) { | 350 void handleGetLibraryResponse(response) { |
| 341 Map result = response["result"]; | 351 Map result = response["result"]; |
| 342 List libs = result["libraries"]; | 352 List libs = result["libraries"]; |
| 343 print("Loaded libraries:"); | 353 print("Loaded libraries:"); |
| 344 print(libs); | 354 print(libs); |
| 345 for (int i = 0; i < libs.length; i++) { | 355 for (int i = 0; i < libs.length; i++) { |
| 346 print(" ${libs[i]["id"]} ${libs[i]["url"]}"); | 356 print(" ${libs[i]["id"]} ${libs[i]["url"]}"); |
| 347 } | 357 } |
| 348 } | 358 } |
| 349 | 359 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 process.stdin.close(); | 603 process.stdin.close(); |
| 594 process.exitCode.then((int exitCode) { | 604 process.exitCode.then((int exitCode) { |
| 595 print('${arguments.join(" ")} exited with $exitCode'); | 605 print('${arguments.join(" ")} exited with $exitCode'); |
| 596 }); | 606 }); |
| 597 debuggerMain(); | 607 debuggerMain(); |
| 598 }); | 608 }); |
| 599 } else { | 609 } else { |
| 600 debuggerMain(); | 610 debuggerMain(); |
| 601 } | 611 } |
| 602 } | 612 } |
| OLD | NEW |