| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return completer.future; | 60 return completer.future; |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 void processCommand(String cmdLine) { | 64 void processCommand(String cmdLine) { |
| 65 seqNum++; | 65 seqNum++; |
| 66 var args = cmdLine.split(' '); | 66 var args = cmdLine.split(' '); |
| 67 if (args.length == 0) { | 67 if (args.length == 0) { |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 var cmd = args[0]; | 70 var command = args[0]; |
| 71 if (cmd == "r") { | 71 if (command == "r") { |
| 72 var cmd = { "id": seqNum, "command": "resume" }; | 72 var cmd = { "id": seqNum, "command": "resume" }; |
| 73 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 73 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 74 stackTrace = curFrame = null; | 74 stackTrace = curFrame = null; |
| 75 } else if (cmd == "s") { | 75 } else if (command == "s") { |
| 76 var cmd = { "id": seqNum, "command": "stepOver" }; | 76 var cmd = { "id": seqNum, "command": "stepOver" }; |
| 77 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 77 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 78 stackTrace = curFrame = null; | 78 stackTrace = curFrame = null; |
| 79 } else if (cmd == "si") { | 79 } else if (command == "si") { |
| 80 var cmd = { "id": seqNum, "command": "stepInto" }; | 80 var cmd = { "id": seqNum, "command": "stepInto" }; |
| 81 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 81 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 82 stackTrace = curFrame = null; | 82 stackTrace = curFrame = null; |
| 83 } else if (cmd == "so") { | 83 } else if (command == "so") { |
| 84 var cmd = { "id": seqNum, "command": "stepOut" }; | 84 var cmd = { "id": seqNum, "command": "stepOut" }; |
| 85 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 85 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 86 stackTrace = curFrame = null; | 86 stackTrace = curFrame = null; |
| 87 } else if (cmd == "bt") { | 87 } else if (command == "bt") { |
| 88 var cmd = { "id": seqNum, "command": "getStackTrace" }; | 88 var cmd = { "id": seqNum, "command": "getStackTrace" }; |
| 89 sendCmd(cmd).then((result) => handleStackTraceResponse(result)); | 89 sendCmd(cmd).then((result) => handleStackTraceResponse(result)); |
| 90 } else if (cmd == "ll") { | 90 } else if (command == "ll") { |
| 91 var cmd = { "id": seqNum, "command": "getLibraryURLs" }; | 91 var cmd = { "id": seqNum, "command": "getLibraryURLs" }; |
| 92 sendCmd(cmd).then((result) => handleGetLibraryResponse(result)); | 92 sendCmd(cmd).then((result) => handleGetLibraryResponse(result)); |
| 93 } else if (cmd == "sbp" && args.length >= 2) { | 93 } else if (command == "sbp" && args.length >= 2) { |
| 94 var url, line; | 94 var url, line; |
| 95 if (args.length == 2) { | 95 if (args.length == 2) { |
| 96 url = stackTrace[0]["location"]["url"]; | 96 url = stackTrace[0]["location"]["url"]; |
| 97 line = Math.parseInt(args[1]); | 97 line = Math.parseInt(args[1]); |
| 98 } else { | 98 } else { |
| 99 url = args[1]; | 99 url = args[1]; |
| 100 line = Math.parseInt(args[2]); | 100 line = Math.parseInt(args[2]); |
| 101 } | 101 } |
| 102 var cmd = { "id": seqNum, | 102 var cmd = { "id": seqNum, |
| 103 "command": "setBreakpoint", | 103 "command": "setBreakpoint", |
| 104 "params": { "url": url, "line": line }}; | 104 "params": { "url": url, "line": line }}; |
| 105 sendCmd(cmd).then((result) => handleSetBpResponse(result)); | 105 sendCmd(cmd).then((result) => handleSetBpResponse(result)); |
| 106 } else if (cmd == "ls" && args.length == 2) { | 106 } else if (command == "ls" && args.length == 2) { |
| 107 var cmd = { "id": seqNum, | 107 var cmd = { "id": seqNum, |
| 108 "command": "getScriptURLs", | 108 "command": "getScriptURLs", |
| 109 "params": { "library": args[1] }}; | 109 "params": { "library": args[1] }}; |
| 110 sendCmd(cmd).then((result) => handleGetScriptsResponse(result)); | 110 sendCmd(cmd).then((result) => handleGetScriptsResponse(result)); |
| 111 } else if (cmd == "po" && args.length == 2) { | 111 } else if (command == "po" && args.length == 2) { |
| 112 var cmd = { "id": seqNum, "command": "getObjectProperties", | 112 var cmd = { "id": seqNum, "command": "getObjectProperties", |
| 113 "params": {"objectId": Math.parseInt(args[1]) }}; | 113 "params": {"objectId": Math.parseInt(args[1]) }}; |
| 114 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result)); | 114 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result)); |
| 115 } else if (cmd == "pc" && args.length == 2) { | 115 } else if (command == "pc" && args.length == 2) { |
| 116 var cmd = { "id": seqNum, "command": "getClassProperties", | 116 var cmd = { "id": seqNum, "command": "getClassProperties", |
| 117 "params": {"classId": Math.parseInt(args[1]) }}; | 117 "params": {"classId": Math.parseInt(args[1]) }}; |
| 118 sendCmd(cmd).then((result) => handleGetClassPropsResponse(result)); | 118 sendCmd(cmd).then((result) => handleGetClassPropsResponse(result)); |
| 119 } else if (cmd == "q") { | 119 } else if (command == "q") { |
| 120 quitShell(); | 120 quitShell(); |
| 121 } else if (cmd == "h") { | 121 } else if (command == "h") { |
| 122 printHelp(); | 122 printHelp(); |
| 123 } else { | 123 } else { |
| 124 print("command '$cmd' not understood, try h for help"); | 124 print("command '$command' not understood, try h for help"); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| 129 printNamedObject(obj) { | 129 printNamedObject(obj) { |
| 130 var name = obj["name"]; | 130 var name = obj["name"]; |
| 131 var value = obj["value"]; | 131 var value = obj["value"]; |
| 132 var kind = value["kind"]; | 132 var kind = value["kind"]; |
| 133 var text = value["text"]; | 133 var text = value["text"]; |
| 134 var id = value["objectId"]; | 134 var id = value["objectId"]; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 }; | 317 }; |
| 318 vmInStream.onError = (err) { | 318 vmInStream.onError = (err) { |
| 319 print("Error in debug connection: $err"); | 319 print("Error in debug connection: $err"); |
| 320 quitShell(); | 320 quitShell(); |
| 321 }; | 321 }; |
| 322 vmInStream.onClosed = () { | 322 vmInStream.onClosed = () { |
| 323 print("VM debugger connection closed"); | 323 print("VM debugger connection closed"); |
| 324 quitShell(); | 324 quitShell(); |
| 325 }; | 325 }; |
| 326 } | 326 } |
| OLD | NEW |