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

Side by Side Diff: tools/ddbg.dart

Issue 23102019: Evaluate expression in the context of a class (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« runtime/vm/object.h ('K') | « runtime/vm/object.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:convert";
8 import "dart:io"; 9 import "dart:io";
9 import "dart:json" as json; 10 import "dart:json" as json;
10 import "dart:utf"; 11 import "dart:utf";
11 import "dart:async"; 12 import "dart:async";
12 13
13 14
14 Map<int, Completer> outstandingCommands; 15 Map<int, Completer> outstandingCommands;
15 16
16 Socket vmSock; 17 Socket vmSock;
17 String vmData; 18 String vmData;
(...skipping 13 matching lines...) Expand all
31 print(""" 32 print("""
32 q Quit debugger shell 33 q Quit debugger shell
33 bt Show backtrace 34 bt Show backtrace
34 r Resume execution 35 r Resume execution
35 s Single step 36 s Single step
36 so Step over 37 so Step over
37 si Step into 38 si Step into
38 sbp [<file>] <line> Set breakpoint 39 sbp [<file>] <line> Set breakpoint
39 rbp <id> Remove breakpoint with given id 40 rbp <id> Remove breakpoint with given id
40 po <id> Print object info for given id 41 po <id> Print object info for given id
41 eval <id> <expr> Evaluate expr on object id 42 eval obj <id> <expr> Evaluate expr on object id
43 eval cls <id> <expr> Evaluate expr on class id
42 pl <id> <idx> [<len>] Print list element/slice 44 pl <id> <idx> [<len>] Print list element/slice
43 pc <id> Print class info for given id 45 pc <id> Print class info for given id
44 ll List loaded libraries 46 ll List loaded libraries
45 plib <id> Print library info for given library id 47 plib <id> Print library info for given library id
46 slib <id> <true|false> Set library id debuggable 48 slib <id> <true|false> Set library id debuggable
47 pg <id> Print all global variables visible within given library id 49 pg <id> Print all global variables visible within given library id
48 ls <lib_id> List loaded scripts in library 50 ls <lib_id> List loaded scripts in library
49 gs <lib_id> <script_url> Get source text of script in library 51 gs <lib_id> <script_url> Get source text of script in library
50 tok <lib_id> <script_url> Get line and token table of script in library 52 tok <lib_id> <script_url> Get line and token table of script in library
51 epi <none|all|unhandled> Set exception pause info 53 epi <none|all|unhandled> Set exception pause info
(...skipping 15 matching lines...) Expand all
67 var completer = new Completer(); 69 var completer = new Completer();
68 int id = cmd["id"]; 70 int id = cmd["id"];
69 outstandingCommands[id] = completer; 71 outstandingCommands[id] = completer;
70 if (verbose) { 72 if (verbose) {
71 print("sending: '${json.stringify(cmd)}'"); 73 print("sending: '${json.stringify(cmd)}'");
72 } 74 }
73 vmSock.write(json.stringify(cmd)); 75 vmSock.write(json.stringify(cmd));
74 return completer.future; 76 return completer.future;
75 } 77 }
76 78
79 void huh() {
80
81 }
77 82
78 void processCommand(String cmdLine) { 83 void processCommand(String cmdLine) {
84
85 void huh() {
86 print("'$cmdLine' not understood, try h for help");
87 }
88
79 seqNum++; 89 seqNum++;
80 var args = cmdLine.split(' '); 90 var args = cmdLine.split(' ');
81 if (args.length == 0) { 91 if (args.length == 0) {
82 return; 92 return;
83 } 93 }
84 var command = args[0]; 94 var command = args[0];
85 var simple_commands = 95 var simple_commands =
86 { 'r':'resume', 's':'stepOver', 'si':'stepInto', 'so':'stepOut'}; 96 { 'r':'resume', 's':'stepOver', 'si':'stepInto', 'so':'stepOut'};
87 if (simple_commands[command] != null) { 97 if (simple_commands[command] != null) {
88 var cmd = { "id": seqNum, 98 var cmd = { "id": seqNum,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 "command": "removeBreakpoint", 130 "command": "removeBreakpoint",
121 "params": { "isolateId" : isolate_id, 131 "params": { "isolateId" : isolate_id,
122 "breakpointId": int.parse(args[1]) } }; 132 "breakpointId": int.parse(args[1]) } };
123 sendCmd(cmd).then((result) => handleGenericResponse(result)); 133 sendCmd(cmd).then((result) => handleGenericResponse(result));
124 } else if (command == "ls" && args.length == 2) { 134 } else if (command == "ls" && args.length == 2) {
125 var cmd = { "id": seqNum, 135 var cmd = { "id": seqNum,
126 "command": "getScriptURLs", 136 "command": "getScriptURLs",
127 "params": { "isolateId" : isolate_id, 137 "params": { "isolateId" : isolate_id,
128 "libraryId": int.parse(args[1]) } }; 138 "libraryId": int.parse(args[1]) } };
129 sendCmd(cmd).then((result) => handleGetScriptsResponse(result)); 139 sendCmd(cmd).then((result) => handleGetScriptsResponse(result));
130 } else if (command == "eval" && args.length > 2) { 140 } else if (command == "eval" && args.length > 3) {
131 var expr = args.getRange(2, args.length).join(" "); 141 var expr = args.getRange(3, args.length).join(" ");
142 var target = args[1];
143 if (target == "obj") {
144 target = "objectId";
145 } else if (target == "cls") {
146 target = "classId";
147 } else {
148 huh();
149 return;
150 }
132 var cmd = { "id": seqNum, 151 var cmd = { "id": seqNum,
133 "command": "evaluateExpr", 152 "command": "evaluateExpr",
134 "params": { "isolateId": isolate_id, 153 "params": { "isolateId": isolate_id,
135 "objectId": int.parse(args[1]), 154 target: int.parse(args[2]),
136 "expression": expr } }; 155 "expression": expr } };
156
137 sendCmd(cmd).then((result) => handleEvalResponse(result)); 157 sendCmd(cmd).then((result) => handleEvalResponse(result));
138 } else if (command == "po" && args.length == 2) { 158 } else if (command == "po" && args.length == 2) {
139 var cmd = { "id": seqNum, 159 var cmd = { "id": seqNum,
140 "command": "getObjectProperties", 160 "command": "getObjectProperties",
141 "params": { "isolateId" : isolate_id, 161 "params": { "isolateId" : isolate_id,
142 "objectId": int.parse(args[1]) } }; 162 "objectId": int.parse(args[1]) } };
143 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result)); 163 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result));
144 } else if (command == "pl" && args.length >= 3) { 164 } else if (command == "pl" && args.length >= 3) {
145 var cmd; 165 var cmd;
146 if (args.length == 3) { 166 if (args.length == 3) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } else if (command == "i" && args.length == 2) { 229 } else if (command == "i" && args.length == 2) {
210 var cmd = { "id": seqNum, 230 var cmd = { "id": seqNum,
211 "command": "interrupt", 231 "command": "interrupt",
212 "params": { "isolateId": int.parse(args[1]) } }; 232 "params": { "isolateId": int.parse(args[1]) } };
213 sendCmd(cmd).then((result) => handleGenericResponse(result)); 233 sendCmd(cmd).then((result) => handleGenericResponse(result));
214 } else if (command == "q") { 234 } else if (command == "q") {
215 quitShell(); 235 quitShell();
216 } else if (command == "h") { 236 } else if (command == "h") {
217 printHelp(); 237 printHelp();
218 } else { 238 } else {
219 print("command '$command' not understood, try h for help"); 239 huh();
220 } 240 }
221 } 241 }
222 242
223 243
224 String remoteObject(value) { 244 String remoteObject(value) {
225 var kind = value["kind"]; 245 var kind = value["kind"];
226 var text = value["text"]; 246 var text = value["text"];
227 var id = value["objectId"]; 247 var id = value["objectId"];
228 if (kind == "string") { 248 if (kind == "string") {
229 return "(string, id $id) '$text'"; 249 return "(string, id $id) '$text'";
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 onDone: () { 618 onDone: () {
599 print("VM debugger connection closed"); 619 print("VM debugger connection closed");
600 quitShell(); 620 quitShell();
601 }, 621 },
602 onError: (err) { 622 onError: (err) {
603 print("Error in debug connection: $err"); 623 print("Error in debug connection: $err");
604 // TODO(floitsch): do we want to print the stack trace? 624 // TODO(floitsch): do we want to print the stack trace?
605 quitShell(); 625 quitShell();
606 }); 626 });
607 stdinSubscription = stdin.transform(new StringDecoder()) 627 stdinSubscription = stdin.transform(new StringDecoder())
608 .transform(new LineTransformer()) 628 .transform(new LineSplitter())
609 .listen((String line) => processCommand(line)); 629 .listen((String line) => processCommand(line));
610 }); 630 });
611 } 631 }
612 632
613 void main() { 633 void main() {
614 Options options = new Options(); 634 Options options = new Options();
615 List<String> arguments = options.arguments; 635 List<String> arguments = options.arguments;
616 if (arguments.length > 0) { 636 if (arguments.length > 0) {
617 arguments = <String>['--debug', '--verbose_debug']..addAll(arguments); 637 arguments = <String>['--debug', '--verbose_debug']..addAll(arguments);
618 Process.start(options.executable, arguments).then((Process process) { 638 Process.start(options.executable, arguments).then((Process process) {
619 process.stdin.close(); 639 process.stdin.close();
620 process.exitCode.then((int exitCode) { 640 process.exitCode.then((int exitCode) {
621 print('${arguments.join(" ")} exited with $exitCode'); 641 print('${arguments.join(" ")} exited with $exitCode');
622 }); 642 });
623 debuggerMain(); 643 debuggerMain();
624 }); 644 });
625 } else { 645 } else {
626 debuggerMain(); 646 debuggerMain();
627 } 647 }
628 } 648 }
OLDNEW
« runtime/vm/object.h ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698