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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 return completer.future; | 51 return completer.future; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 void processCommand(String cmdLine) { | 55 void processCommand(String cmdLine) { |
| 56 seqNum++; | 56 seqNum++; |
| 57 var args = cmdLine.split(' '); | 57 var args = cmdLine.split(' '); |
| 58 if (args.length == 0) { | 58 if (args.length == 0) { |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 var cmd = args[0]; | 61 var command = args[0]; |
|
Bob Nystrom
2012/05/22 17:23:14
Nice change. :)
Bill Hesse
2012/05/23 08:49:20
Or I could have just removed the inner "var" decla
| |
| 62 if (cmd == "r") { | 62 if (command == "r") { |
| 63 var cmd = { "id": seqNum, "command": "resume" }; | 63 var cmd = { "id": seqNum, "command": "resume" }; |
| 64 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 64 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 65 } else if (cmd == "s") { | 65 } else if (command == "s") { |
| 66 var cmd = { "id": seqNum, "command": "stepOver" }; | 66 var cmd = { "id": seqNum, "command": "stepOver" }; |
| 67 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 67 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 68 } else if (cmd == "si") { | 68 } else if (command == "si") { |
| 69 var cmd = { "id": seqNum, "command": "stepInto" }; | 69 var cmd = { "id": seqNum, "command": "stepInto" }; |
| 70 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 70 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 71 } else if (cmd == "so") { | 71 } else if (command == "so") { |
| 72 var cmd = { "id": seqNum, "command": "stepOut" }; | 72 var cmd = { "id": seqNum, "command": "stepOut" }; |
| 73 sendCmd(cmd).then((result) => handleGenericResponse(result)); | 73 sendCmd(cmd).then((result) => handleGenericResponse(result)); |
| 74 } else if (cmd == "bt") { | 74 } else if (command == "bt") { |
| 75 var cmd = { "id": seqNum, "command": "getStackTrace" }; | 75 var cmd = { "id": seqNum, "command": "getStackTrace" }; |
| 76 sendCmd(cmd).then((result) => handleStackTraceResponse(result)); | 76 sendCmd(cmd).then((result) => handleStackTraceResponse(result)); |
| 77 } else if (cmd == "ll") { | 77 } else if (command == "ll") { |
| 78 var cmd = { "id": seqNum, "command": "getLibraryURLs" }; | 78 var cmd = { "id": seqNum, "command": "getLibraryURLs" }; |
| 79 sendCmd(cmd).then((result) => handleGetLibraryResponse(result)); | 79 sendCmd(cmd).then((result) => handleGetLibraryResponse(result)); |
| 80 } else if (cmd == "sbp") { | 80 } else if (command == "sbp") { |
| 81 if (args.length < 3) { | 81 if (args.length < 3) { |
| 82 return; | 82 return; |
| 83 } | 83 } |
| 84 var cmd = { "id": seqNum, | 84 var cmd = { "id": seqNum, |
| 85 "command": "setBreakpoint", | 85 "command": "setBreakpoint", |
| 86 "params": { "url": args[1], "line": Math.parseInt(args[2]) }}; | 86 "params": { "url": args[1], "line": Math.parseInt(args[2]) }}; |
| 87 sendCmd(cmd).then((result) => handleSetBpResponse(result)); | 87 sendCmd(cmd).then((result) => handleSetBpResponse(result)); |
| 88 } else if (cmd == "ls") { | 88 } else if (command == "ls") { |
| 89 if (args.length < 2) { | 89 if (args.length < 2) { |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 var cmd = { "id": seqNum, | 92 var cmd = { "id": seqNum, |
| 93 "command": "getScriptURLs", | 93 "command": "getScriptURLs", |
| 94 "params": { "library": args[1] }}; | 94 "params": { "library": args[1] }}; |
| 95 sendCmd(cmd).then((result) => handleGetScriptsResponse(result)); | 95 sendCmd(cmd).then((result) => handleGetScriptsResponse(result)); |
| 96 } else if (cmd == "q") { | 96 } else if (command == "q") { |
| 97 quitShell(); | 97 quitShell(); |
| 98 } else if (cmd == "h") { | 98 } else if (command == "h") { |
| 99 printHelp(); | 99 printHelp(); |
| 100 } else { | 100 } else { |
| 101 print("command '$cmd' not understood, try h for help"); | 101 print("command '$command' not understood, try h for help"); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| 106 void handleGetLibraryResponse(response) { | 106 void handleGetLibraryResponse(response) { |
| 107 var result = response["result"]; | 107 var result = response["result"]; |
| 108 assert(result != null); | 108 assert(result != null); |
| 109 var urls = result["urls"]; | 109 var urls = result["urls"]; |
| 110 assert(urls != null); | 110 assert(urls != null); |
| 111 assert(urls is List); | 111 assert(urls is List); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 }; | 247 }; |
| 248 vmInStream.onError = (err) { | 248 vmInStream.onError = (err) { |
| 249 print("Error in debug connection: $err"); | 249 print("Error in debug connection: $err"); |
| 250 quitShell(); | 250 quitShell(); |
| 251 }; | 251 }; |
| 252 vmInStream.onClosed = () { | 252 vmInStream.onClosed = () { |
| 253 print("VM debugger connection closed"); | 253 print("VM debugger connection closed"); |
| 254 quitShell(); | 254 quitShell(); |
| 255 }; | 255 }; |
| 256 } | 256 } |
| OLD | NEW |