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

Side by Side Diff: tools/ddbg.dart

Issue 14105003: Debugger wire protocol cleanups (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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" as json; 9 import "dart:json" as json;
10 import "dart:utf"; 10 import "dart:utf";
11 import "dart:async"; 11 import "dart:async";
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 var stdinSubscription; 18 var stdinSubscription;
19 var vmSubscription; 19 var vmSubscription;
20 int seqNum = 0; 20 int seqNum = 0;
21 int isolate_id = -1; 21 int isolate_id = -1;
22 22
23 final verbose = false; 23 final verbose = false;
24 final printMessages = false; 24 final printMessages = false;
25 25
26 // The current stack trace, while the VM is paused. It's a list 26 // The location of the last paused event.
27 // of activation frames. 27 Map pausedLocation = null;
28 List stackTrace;
29
30 // The current activation frame, while the VM is paused.
31 Map curFrame;
32 28
33 29
34 void printHelp() { 30 void printHelp() {
35 print(""" 31 print("""
36 q Quit debugger shell 32 q Quit debugger shell
37 bt Show backtrace 33 bt Show backtrace
38 r Resume execution 34 r Resume execution
39 s Single step 35 s Single step
40 so Step over 36 so Step over
41 si Step into 37 si Step into
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return; 80 return;
85 } 81 }
86 var command = args[0]; 82 var command = args[0];
87 var simple_commands = 83 var simple_commands =
88 { 'r':'resume', 's':'stepOver', 'si':'stepInto', 'so':'stepOut'}; 84 { 'r':'resume', 's':'stepOver', 'si':'stepInto', 'so':'stepOut'};
89 if (simple_commands[command] != null) { 85 if (simple_commands[command] != null) {
90 var cmd = { "id": seqNum, 86 var cmd = { "id": seqNum,
91 "command": simple_commands[command], 87 "command": simple_commands[command],
92 "params": { "isolateId" : isolate_id } }; 88 "params": { "isolateId" : isolate_id } };
93 sendCmd(cmd).then((result) => handleGenericResponse(result)); 89 sendCmd(cmd).then((result) => handleGenericResponse(result));
94 stackTrace = curFrame = null;
95 } else if (command == "bt") { 90 } else if (command == "bt") {
96 var cmd = { "id": seqNum, 91 var cmd = { "id": seqNum,
97 "command": "getStackTrace", 92 "command": "getStackTrace",
98 "params": { "isolateId" : isolate_id } }; 93 "params": { "isolateId" : isolate_id } };
99 sendCmd(cmd).then((result) => handleStackTraceResponse(result)); 94 sendCmd(cmd).then((result) => handleStackTraceResponse(result));
100 } else if (command == "ll") { 95 } else if (command == "ll") {
101 var cmd = { "id": seqNum, 96 var cmd = { "id": seqNum,
102 "command": "getLibraries", 97 "command": "getLibraries",
103 "params": { "isolateId" : isolate_id } }; 98 "params": { "isolateId" : isolate_id } };
104 sendCmd(cmd).then((result) => handleGetLibraryResponse(result)); 99 sendCmd(cmd).then((result) => handleGetLibraryResponse(result));
105 } else if (command == "sbp" && args.length >= 2) { 100 } else if (command == "sbp" && args.length >= 2) {
106 var url, line; 101 var url, line;
107 if (args.length == 2) { 102 if (args.length == 2 && pausedLocation != null) {
108 url = stackTrace[0]["location"]["url"]; 103 url = pausedLocation["url"];
104 assert(url != null);
109 line = int.parse(args[1]); 105 line = int.parse(args[1]);
110 } else { 106 } else {
111 url = args[1]; 107 url = args[1];
112 line = int.parse(args[2]); 108 line = int.parse(args[2]);
113 } 109 }
114 var cmd = { "id": seqNum, 110 var cmd = { "id": seqNum,
115 "command": "setBreakpoint", 111 "command": "setBreakpoint",
116 "params": { "isolateId" : isolate_id, 112 "params": { "isolateId" : isolate_id,
117 "url": url, 113 "url": url,
118 "line": line }}; 114 "line": line }};
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 void printStackTrace(List frames) { 397 void printStackTrace(List frames) {
402 for (int i = 0; i < frames.length; i++) { 398 for (int i = 0; i < frames.length; i++) {
403 printStackFrame(i, frames[i]); 399 printStackFrame(i, frames[i]);
404 } 400 }
405 } 401 }
406 402
407 403
408 void handlePausedEvent(msg) { 404 void handlePausedEvent(msg) {
409 assert(msg["params"] != null); 405 assert(msg["params"] != null);
410 var reason = msg["params"]["reason"]; 406 var reason = msg["params"]["reason"];
411 isolate_id = msg["params"]["id"]; 407 isolate_id = msg["params"]["isolateId"];
412 stackTrace = msg["params"]["callFrames"]; 408 assert(isolate_id != null);
413 assert(stackTrace != null); 409 pausedLocation = msg["params"]["location"];
414 assert(stackTrace.length >= 1); 410 assert(pausedLocation != null);
415 curFrame = stackTrace[0];
416 if (reason == "breakpoint") { 411 if (reason == "breakpoint") {
417 print("Isolate $isolate_id paused on breakpoint"); 412 print("Isolate $isolate_id paused on breakpoint");
413 print("location: $pausedLocation");
418 } else if (reason == "interrupted") { 414 } else if (reason == "interrupted") {
419 print("Isolate $isolate_id paused due to an interrupt"); 415 print("Isolate $isolate_id paused due to an interrupt");
420 } else { 416 } else {
421 assert(reason == "exception"); 417 assert(reason == "exception");
422 var excObj = msg["params"]["exception"]; 418 var excObj = msg["params"]["exception"];
423 print("Isolate $isolate_id paused on exception"); 419 print("Isolate $isolate_id paused on exception");
424 print(remoteObject(excObj)); 420 print(remoteObject(excObj));
425 } 421 }
426 print("Stack trace:");
427 printStackTrace(stackTrace);
428 } 422 }
429 423
430 424
431 void processVmMessage(String jsonString) { 425 void processVmMessage(String jsonString) {
432 var msg = json.parse(jsonString); 426 var msg = json.parse(jsonString);
433 if (msg == null) { 427 if (msg == null) {
434 return; 428 return;
435 } 429 }
436 var event = msg["event"]; 430 var event = msg["event"];
437 if (event == "paused") { 431 if (event == "paused") {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 process.stdin.close(); 592 process.stdin.close();
599 process.exitCode.then((int exitCode) { 593 process.exitCode.then((int exitCode) {
600 print('${arguments.join(" ")} exited with $exitCode'); 594 print('${arguments.join(" ")} exited with $exitCode');
601 }); 595 });
602 debuggerMain(); 596 debuggerMain();
603 }); 597 });
604 } else { 598 } else {
605 debuggerMain(); 599 debuggerMain();
606 } 600 }
607 } 601 }
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