Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tools/ddbg.dart

Issue 11094017: 1. Add isolate id parameter to all the debugger commands in the debugger wire protocol so that the … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/dbg_message.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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");
11 #import("dart:utf"); 11 #import("dart:utf");
12 12
13 13
14 Map<int, Completer> outstandingCommands; 14 Map<int, Completer> outstandingCommands;
15 15
16 Socket vmSock; 16 Socket vmSock;
17 String vmData; 17 String vmData;
18 OutputStream vmStream; 18 OutputStream vmStream;
19 int seqNum = 0; 19 int seqNum = 0;
20 int isolate_id = -1;
20 21
21 bool verbose = false; 22 bool verbose = false;
22 23
23 // The current stack trace, while the VM is paused. It's a list 24 // The current stack trace, while the VM is paused. It's a list
24 // of activation frames. 25 // of activation frames.
25 List stackTrace; 26 List stackTrace;
26 27
27 // The current activation frame, while the VM is paused. 28 // The current activation frame, while the VM is paused.
28 Map curFrame; 29 Map curFrame;
29 30
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 void processCommand(String cmdLine) { 77 void processCommand(String cmdLine) {
77 seqNum++; 78 seqNum++;
78 var args = cmdLine.split(' '); 79 var args = cmdLine.split(' ');
79 if (args.length == 0) { 80 if (args.length == 0) {
80 return; 81 return;
81 } 82 }
82 var command = args[0]; 83 var command = args[0];
83 var simple_commands = 84 var simple_commands =
84 { 'r':'resume', 's':'stepOver', 'si':'stepInto', 'so':'stepOut'}; 85 { 'r':'resume', 's':'stepOver', 'si':'stepInto', 'so':'stepOut'};
85 if (simple_commands[command] != null) { 86 if (simple_commands[command] != null) {
86 var cmd = { "id": seqNum, "command": simple_commands[command]}; 87 var cmd = { "id": seqNum,
88 "command": simple_commands[command],
89 "params": { "isolateId" : isolate_id } };
87 sendCmd(cmd).then((result) => handleGenericResponse(result)); 90 sendCmd(cmd).then((result) => handleGenericResponse(result));
88 stackTrace = curFrame = null; 91 stackTrace = curFrame = null;
89 } else if (command == "bt") { 92 } else if (command == "bt") {
90 var cmd = { "id": seqNum, "command": "getStackTrace" }; 93 var cmd = { "id": seqNum,
94 "command": "getStackTrace",
95 "params": { "isolateId" : isolate_id } };
91 sendCmd(cmd).then((result) => handleStackTraceResponse(result)); 96 sendCmd(cmd).then((result) => handleStackTraceResponse(result));
92 } else if (command == "ll") { 97 } else if (command == "ll") {
93 var cmd = { "id": seqNum, "command": "getLibraries" }; 98 var cmd = { "id": seqNum,
99 "command": "getLibraries",
100 "params": { "isolateId" : isolate_id } };
94 sendCmd(cmd).then((result) => handleGetLibraryResponse(result)); 101 sendCmd(cmd).then((result) => handleGetLibraryResponse(result));
95 } else if (command == "sbp" && args.length >= 2) { 102 } else if (command == "sbp" && args.length >= 2) {
96 var url, line; 103 var url, line;
97 if (args.length == 2) { 104 if (args.length == 2) {
98 url = stackTrace[0]["location"]["url"]; 105 url = stackTrace[0]["location"]["url"];
99 line = Math.parseInt(args[1]); 106 line = Math.parseInt(args[1]);
100 } else { 107 } else {
101 url = args[1]; 108 url = args[1];
102 line = Math.parseInt(args[2]); 109 line = Math.parseInt(args[2]);
103 } 110 }
104 var cmd = { "id": seqNum, 111 var cmd = { "id": seqNum,
105 "command": "setBreakpoint", 112 "command": "setBreakpoint",
106 "params": { "url": url, "line": line }}; 113 "params": { "isolateId" : isolate_id,
114 "url": url,
115 "line": line }};
107 sendCmd(cmd).then((result) => handleSetBpResponse(result)); 116 sendCmd(cmd).then((result) => handleSetBpResponse(result));
108 } else if (command == "rbp" && args.length == 2) { 117 } else if (command == "rbp" && args.length == 2) {
109 var cmd = { "id": seqNum, 118 var cmd = { "id": seqNum,
110 "command": "removeBreakpoint", 119 "command": "removeBreakpoint",
111 "params": { "breakpointId": Math.parseInt(args[1]) }}; 120 "params": { "isolateId" : isolate_id,
121 "breakpointId": Math.parseInt(args[1]) } };
112 sendCmd(cmd).then((result) => handleGenericResponse(result)); 122 sendCmd(cmd).then((result) => handleGenericResponse(result));
113 } else if (command == "ls" && args.length == 2) { 123 } else if (command == "ls" && args.length == 2) {
114 var cmd = { "id": seqNum, 124 var cmd = { "id": seqNum,
115 "command": "getScriptURLs", 125 "command": "getScriptURLs",
116 "params": { "libraryId": Math.parseInt(args[1]) }}; 126 "params": { "isolateId" : isolate_id,
127 "libraryId": Math.parseInt(args[1]) } };
117 sendCmd(cmd).then((result) => handleGetScriptsResponse(result)); 128 sendCmd(cmd).then((result) => handleGetScriptsResponse(result));
118 } else if (command == "po" && args.length == 2) { 129 } else if (command == "po" && args.length == 2) {
119 var cmd = { "id": seqNum, "command": "getObjectProperties", 130 var cmd = { "id": seqNum,
120 "params": {"objectId": Math.parseInt(args[1]) }}; 131 "command": "getObjectProperties",
132 "params": { "isolateId" : isolate_id,
133 "objectId": Math.parseInt(args[1]) } };
121 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result)); 134 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result));
122 } else if (command == "pl" && args.length >= 3) { 135 } else if (command == "pl" && args.length >= 3) {
123 var cmd; 136 var cmd;
124 if (args.length == 3) { 137 if (args.length == 3) {
125 cmd = { "id": seqNum, "command": "getListElements", 138 cmd = { "id": seqNum,
126 "params": {"objectId": Math.parseInt(args[1]), 139 "command": "getListElements",
127 "index": Math.parseInt(args[2]) }}; 140 "params": { "isolateId" : isolate_id,
141 "objectId": Math.parseInt(args[1]),
142 "index": Math.parseInt(args[2]) } };
128 } else { 143 } else {
129 cmd = { "id": seqNum, "command": "getListElements", 144 cmd = { "id": seqNum,
130 "params": {"objectId": Math.parseInt(args[1]), 145 "command": "getListElements",
131 "index": Math.parseInt(args[2]), 146 "params": { "isolateId" : isolate_id,
132 "length": Math.parseInt(args[3]) }}; 147 "objectId": Math.parseInt(args[1]),
148 "index": Math.parseInt(args[2]),
149 "length": Math.parseInt(args[3]) } };
133 } 150 }
134 sendCmd(cmd).then((result) => handleGetListResponse(result)); 151 sendCmd(cmd).then((result) => handleGetListResponse(result));
135 } else if (command == "pc" && args.length == 2) { 152 } else if (command == "pc" && args.length == 2) {
136 var cmd = { "id": seqNum, "command": "getClassProperties", 153 var cmd = { "id": seqNum,
137 "params": {"classId": Math.parseInt(args[1]) }}; 154 "command": "getClassProperties",
155 "params": { "isolateId" : isolate_id,
156 "classId": Math.parseInt(args[1]) } };
138 sendCmd(cmd).then((result) => handleGetClassPropsResponse(result)); 157 sendCmd(cmd).then((result) => handleGetClassPropsResponse(result));
139 } else if (command == "plib" && args.length == 2) { 158 } else if (command == "plib" && args.length == 2) {
140 var cmd = { "id": seqNum, "command": "getLibraryProperties", 159 var cmd = { "id": seqNum,
141 "params": {"libraryId": Math.parseInt(args[1]) }}; 160 "command": "getLibraryProperties",
161 "params": {"isolateId" : isolate_id,
162 "libraryId": Math.parseInt(args[1]) } };
142 sendCmd(cmd).then((result) => handleGetLibraryPropsResponse(result)); 163 sendCmd(cmd).then((result) => handleGetLibraryPropsResponse(result));
143 } else if (command == "slib" && args.length == 3) { 164 } else if (command == "slib" && args.length == 3) {
144 var cmd = { "id": seqNum, "command": "setLibraryProperties", 165 var cmd = { "id": seqNum,
145 "params": {"libraryId": Math.parseInt(args[1]), 166 "command": "setLibraryProperties",
146 "debuggingEnabled": args[2] }}; 167 "params": {"isolateId" : isolate_id,
168 "libraryId": Math.parseInt(args[1]),
169 "debuggingEnabled": args[2] } };
147 sendCmd(cmd).then((result) => handleSetLibraryPropsResponse(result)); 170 sendCmd(cmd).then((result) => handleSetLibraryPropsResponse(result));
148 } else if (command == "pg" && args.length == 2) { 171 } else if (command == "pg" && args.length == 2) {
149 var cmd = { "id": seqNum, "command": "getGlobalVariables", 172 var cmd = { "id": seqNum,
150 "params": {"libraryId": Math.parseInt(args[1]) }}; 173 "command": "getGlobalVariables",
174 "params": { "isolateId" : isolate_id,
175 "libraryId": Math.parseInt(args[1]) } };
151 sendCmd(cmd).then((result) => handleGetGlobalVarsResponse(result)); 176 sendCmd(cmd).then((result) => handleGetGlobalVarsResponse(result));
152 } else if (command == "gs" && args.length == 3) { 177 } else if (command == "gs" && args.length == 3) {
153 var cmd = { "id": seqNum, "command": "getScriptSource", 178 var cmd = { "id": seqNum,
154 "params": { "libraryId": Math.parseInt(args[1]), 179 "command": "getScriptSource",
155 "url": args[2] }}; 180 "params": { "isolateId" : isolate_id,
181 "libraryId": Math.parseInt(args[1]),
182 "url": args[2] } };
156 sendCmd(cmd).then((result) => handleGetSourceResponse(result)); 183 sendCmd(cmd).then((result) => handleGetSourceResponse(result));
157 } else if (command == "epi" && args.length == 2) { 184 } else if (command == "epi" && args.length == 2) {
158 var cmd = { "id": seqNum, "command": "setPauseOnException", 185 var cmd = { "id": seqNum,
159 "params": { "exceptions": args[1] }}; 186 "command": "setPauseOnException",
187 "params": { "isolateId" : isolate_id,
188 "exceptions": args[1] } };
160 sendCmd(cmd).then((result) => handleGenericResponse(result)); 189 sendCmd(cmd).then((result) => handleGenericResponse(result));
161 } else if (command == "i" && args.length == 2) { 190 } else if (command == "i" && args.length == 2) {
162 var cmd = { "id": seqNum, "command": "interrupt", 191 var cmd = { "id": seqNum,
163 "params": {"isolateId": Math.parseInt(args[1]) }}; 192 "command": "interrupt",
193 "params": { "isolateId": Math.parseInt(args[1]) } };
164 sendCmd(cmd).then((result) => handleGenericResponse(result)); 194 sendCmd(cmd).then((result) => handleGenericResponse(result));
165 } else if (command == "q") { 195 } else if (command == "q") {
166 quitShell(); 196 quitShell();
167 } else if (command == "h") { 197 } else if (command == "h") {
168 printHelp(); 198 printHelp();
169 } else { 199 } else {
170 print("command '$command' not understood, try h for help"); 200 print("command '$command' not understood, try h for help");
171 } 201 }
172 } 202 }
173 203
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 void printStackTrace(List frames) { 384 void printStackTrace(List frames) {
355 for (int i = 0; i < frames.length; i++) { 385 for (int i = 0; i < frames.length; i++) {
356 printStackFrame(i, frames[i]); 386 printStackFrame(i, frames[i]);
357 } 387 }
358 } 388 }
359 389
360 390
361 void handlePausedEvent(msg) { 391 void handlePausedEvent(msg) {
362 assert(msg["params"] != null); 392 assert(msg["params"] != null);
363 var reason = msg["params"]["reason"]; 393 var reason = msg["params"]["reason"];
364 var id = msg["params"]["id"]; 394 isolate_id = msg["params"]["id"];
365 stackTrace = msg["params"]["callFrames"]; 395 stackTrace = msg["params"]["callFrames"];
366 assert(stackTrace != null); 396 assert(stackTrace != null);
367 assert(stackTrace.length >= 1); 397 assert(stackTrace.length >= 1);
368 curFrame = stackTrace[0]; 398 curFrame = stackTrace[0];
369 if (reason == "breakpoint") { 399 if (reason == "breakpoint") {
370 print("Isolate $id paused on breakpoint"); 400 print("Isolate $isolate_id paused on breakpoint");
371 } else if (reason == "interrupted") { 401 } else if (reason == "interrupted") {
372 print("Isolate $id paused due to an interrupt"); 402 print("Isolate $isolate_id paused due to an interrupt");
373 } else { 403 } else {
374 assert(reason == "exception"); 404 assert(reason == "exception");
375 var excObj = msg["params"]["exception"]; 405 var excObj = msg["params"]["exception"];
376 print("Isolate $id paused on exception"); 406 print("Isolate $isolate_id paused on exception");
377 print(remoteObject(excObj)); 407 print(remoteObject(excObj));
378 } 408 }
379 print("Stack trace:"); 409 print("Stack trace:");
380 printStackTrace(stackTrace); 410 printStackTrace(stackTrace);
381 } 411 }
382 412
383 413
384 void processVmMessage(String json) { 414 void processVmMessage(String json) {
385 var msg = JSON.parse(json); 415 var msg = JSON.parse(json);
386 if (msg == null) { 416 if (msg == null) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 }; 541 };
512 vmInStream.onError = (err) { 542 vmInStream.onError = (err) {
513 print("Error in debug connection: $err"); 543 print("Error in debug connection: $err");
514 quitShell(); 544 quitShell();
515 }; 545 };
516 vmInStream.onClosed = () { 546 vmInStream.onClosed = () {
517 print("VM debugger connection closed"); 547 print("VM debugger connection closed");
518 quitShell(); 548 quitShell();
519 }; 549 };
520 } 550 }
OLDNEW
« no previous file with comments | « runtime/bin/dbg_message.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698