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

Side by Side Diff: tools/ddbg.dart

Issue 10447045: Introduce library ids and info in the wire protocol (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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.cc ('K') | « runtime/vm/raw_object_snapshot.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 10
(...skipping 14 matching lines...) Expand all
25 25
26 26
27 void printHelp() { 27 void printHelp() {
28 print(""" 28 print("""
29 q Quit debugger shell 29 q Quit debugger shell
30 bt Show backtrace 30 bt Show backtrace
31 r Resume execution 31 r Resume execution
32 s Single step 32 s Single step
33 so Step over 33 so Step over
34 si Step into 34 si Step into
35 sbp [<file>] <line> Set breakpoint 35 sbp [<file>] <line> Set breakpoint
siva 2012/05/29 18:07:53 commands 'rbp' and 'pl' need to be added to this l
hausner 2012/05/29 19:48:18 Done.
36 po <id> Print object info for given id 36 po <id> Print object info for given id
37 pc <id> Print class info for given id 37 pc <id> Print class info for given id
38 ll List loaded libraries 38 ll List loaded libraries
39 ls <libname> List loaded scripts in library 39 ls <libname> List loaded scripts in library
40 h Print help 40 h Print help
41 """); 41 """);
42 } 42 }
43 43
44 44
45 void quitShell() { 45 void quitShell() {
(...skipping 25 matching lines...) Expand all
71 var simple_commands = 71 var simple_commands =
72 { 'r':'resume', 's':'stepOver', 'si':'stepInto', 'so':'stepOut'}; 72 { 'r':'resume', 's':'stepOver', 'si':'stepInto', 'so':'stepOut'};
73 if (simple_commands[command] != null) { 73 if (simple_commands[command] != null) {
74 var cmd = { "id": seqNum, "command": simple_commands[command]}; 74 var cmd = { "id": seqNum, "command": simple_commands[command]};
75 sendCmd(cmd).then((result) => handleGenericResponse(result)); 75 sendCmd(cmd).then((result) => handleGenericResponse(result));
76 stackTrace = curFrame = null; 76 stackTrace = curFrame = null;
77 } else if (command == "bt") { 77 } else if (command == "bt") {
78 var cmd = { "id": seqNum, "command": "getStackTrace" }; 78 var cmd = { "id": seqNum, "command": "getStackTrace" };
79 sendCmd(cmd).then((result) => handleStackTraceResponse(result)); 79 sendCmd(cmd).then((result) => handleStackTraceResponse(result));
80 } else if (command == "ll") { 80 } else if (command == "ll") {
81 var cmd = { "id": seqNum, "command": "getLibraryURLs" }; 81 var cmd = { "id": seqNum, "command": "getLibraries" };
82 sendCmd(cmd).then((result) => handleGetLibraryResponse(result)); 82 sendCmd(cmd).then((result) => handleGetLibraryResponse(result));
83 } else if (command == "sbp" && args.length >= 2) { 83 } else if (command == "sbp" && args.length >= 2) {
84 var url, line; 84 var url, line;
85 if (args.length == 2) { 85 if (args.length == 2) {
86 url = stackTrace[0]["location"]["url"]; 86 url = stackTrace[0]["location"]["url"];
87 line = Math.parseInt(args[1]); 87 line = Math.parseInt(args[1]);
88 } else { 88 } else {
89 url = args[1]; 89 url = args[1];
90 line = Math.parseInt(args[2]); 90 line = Math.parseInt(args[2]);
91 } 91 }
92 var cmd = { "id": seqNum, 92 var cmd = { "id": seqNum,
93 "command": "setBreakpoint", 93 "command": "setBreakpoint",
94 "params": { "url": url, "line": line }}; 94 "params": { "url": url, "line": line }};
95 sendCmd(cmd).then((result) => handleSetBpResponse(result)); 95 sendCmd(cmd).then((result) => handleSetBpResponse(result));
96 } else if (command == "rbp" && args.length == 2) {
97 var cmd = { "id": seqNum,
98 "command": "removeBreakpoint",
99 "params": { "breakpointId": Math.parseInt(args[1]) }};
100 sendCmd(cmd).then((result) => handleGenericResponse(result));
96 } else if (command == "ls" && args.length == 2) { 101 } else if (command == "ls" && args.length == 2) {
97 var cmd = { "id": seqNum, 102 var cmd = { "id": seqNum,
98 "command": "getScriptURLs", 103 "command": "getScriptURLs",
99 "params": { "library": args[1] }}; 104 "params": { "libraryId": Math.parseInt(args[1]) }};
100 sendCmd(cmd).then((result) => handleGetScriptsResponse(result)); 105 sendCmd(cmd).then((result) => handleGetScriptsResponse(result));
101 } else if (command == "po" && args.length == 2) { 106 } else if (command == "po" && args.length == 2) {
102 var cmd = { "id": seqNum, "command": "getObjectProperties", 107 var cmd = { "id": seqNum, "command": "getObjectProperties",
103 "params": {"objectId": Math.parseInt(args[1]) }}; 108 "params": {"objectId": Math.parseInt(args[1]) }};
104 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result)); 109 sendCmd(cmd).then((result) => handleGetObjPropsResponse(result));
105 } else if (command == "pc" && args.length == 2) { 110 } else if (command == "pc" && args.length == 2) {
106 var cmd = { "id": seqNum, "command": "getClassProperties", 111 var cmd = { "id": seqNum, "command": "getClassProperties",
107 "params": {"classId": Math.parseInt(args[1]) }}; 112 "params": {"classId": Math.parseInt(args[1]) }};
108 sendCmd(cmd).then((result) => handleGetClassPropsResponse(result)); 113 sendCmd(cmd).then((result) => handleGetClassPropsResponse(result));
114 } else if (command == "pl" && args.length == 2) {
115 var cmd = { "id": seqNum, "command": "getLibraryProperties",
116 "params": {"libraryId": Math.parseInt(args[1]) }};
117 sendCmd(cmd).then((result) => handleGetLibraryPropsResponse(result));
109 } else if (command == "q") { 118 } else if (command == "q") {
110 quitShell(); 119 quitShell();
111 } else if (command == "h") { 120 } else if (command == "h") {
112 printHelp(); 121 printHelp();
113 } else { 122 } else {
114 print("command '$command' not understood, try h for help"); 123 print("command '$command' not understood, try h for help");
115 } 124 }
116 } 125 }
117 126
118 127
119 printNamedObject(obj) { 128 printNamedObject(obj) {
120 var name = obj["name"]; 129 var name = obj["name"];
121 var value = obj["value"]; 130 var value = obj["value"];
122 var kind = value["kind"]; 131 var kind = value["kind"];
123 var text = value["text"]; 132 var text = value["text"];
124 var id = value["objectId"]; 133 var id = value["objectId"];
125 if (kind == "string") { 134 if (kind == "string") {
126 print(" $name = '$text'"); 135 print(" $name = '$text'");
127 } else if (kind == "object") { 136 } else if (kind == "object") {
128 print(" $name (id:$id) = $text"); 137 print(" $name (id:$id) = $text");
129 } else { 138 } else {
130 print(" $name = $text"); 139 print(" $name = $text");
131 } 140 }
132 } 141 }
133 142
134 143
135 handleGetObjPropsResponse(response) { 144 handleGetObjPropsResponse(response) {
136 Map props = response["result"]; 145 Map props = response["result"];
137 int class_id = props["classId"]; 146 int class_id = props["classId"];
147 if (class_id == -1) {
148 print(" null");
149 return;
150 }
138 List fields = props["fields"]; 151 List fields = props["fields"];
139 print(" class id: $class_id"); 152 print(" class id: $class_id");
140 for (int i = 0; i < fields.length; i++) { 153 for (int i = 0; i < fields.length; i++) {
141 printNamedObject(fields[i]); 154 printNamedObject(fields[i]);
142 } 155 }
143 } 156 }
144 157
145 158
146 handleGetClassPropsResponse(response) { 159 handleGetClassPropsResponse(response) {
147 Map props = response["result"]; 160 Map props = response["result"];
148 assert(props["name"] != null); 161 assert(props["name"] != null);
149 int libId = props["libraryId"]; 162 int libId = props["libraryId"];
150 assert(libId != null); 163 assert(libId != null);
151 print(" class ${props["name"]} (library id: $libId)"); 164 print(" class ${props["name"]} (library id: $libId)");
152 List fields = props["fields"]; 165 List fields = props["fields"];
153 if (fields.length > 0) { 166 if (fields.length > 0) {
154 print(" static fields:"); 167 print(" static fields:");
155 for (int i = 0; i < fields.length; i++) { 168 for (int i = 0; i < fields.length; i++) {
156 printNamedObject(fields[i]); 169 printNamedObject(fields[i]);
157 } 170 }
158 } 171 }
159 } 172 }
160 173
161 174
175 handleGetLibraryPropsResponse(response) {
176 Map props = response["result"];
177 assert(props["url"] != null);
178 print(" library url=${props["url"]}");
179 List imports = props["imports"];
180 assert(imports != null);
181 if (imports.length > 0) {
182 print(" imports:");
183 for (int i = 0; i < imports.length; i++) {
184 print(" id ${imports[i]["libraryId"]} prefix ${imports[i]["prefix"]}");
185 }
186 }
187 List globals = props["globals"];
188 assert(globals != null);
189 if (globals.length > 0) {
190 print(" global variables:");
191 for (int i = 0; i < globals.length; i++) {
192 printNamedObject(globals[i]);
193 }
194 }
195 }
196
197
162 void handleGetLibraryResponse(response) { 198 void handleGetLibraryResponse(response) {
163 Map result = response["result"]; 199 Map result = response["result"];
164 List urls = result["urls"]; 200 List libs = result["libraries"];
165 print("Loaded libraries:"); 201 print("Loaded libraries:");
166 for (int i = 0; i < urls.length; i++) { 202 print(libs);
167 print(" $i ${urls[i]}"); 203 for (int i = 0; i < libs.length; i++) {
204 print(" ${libs[i]["id"]} ${libs[i]["url"]}");
168 } 205 }
169 } 206 }
170 207
171 208
172 void handleGetScriptsResponse(response) { 209 void handleGetScriptsResponse(response) {
173 Map result = response["result"]; 210 Map result = response["result"];
174 List urls = result["urls"]; 211 List urls = result["urls"];
175 print("Loaded scripts:"); 212 print("Loaded scripts:");
176 for (int i = 0; i < urls.length; i++) { 213 for (int i = 0; i < urls.length; i++) {
177 print(" $i ${urls[i]}"); 214 print(" $i ${urls[i]}");
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 }; 344 };
308 vmInStream.onError = (err) { 345 vmInStream.onError = (err) {
309 print("Error in debug connection: $err"); 346 print("Error in debug connection: $err");
310 quitShell(); 347 quitShell();
311 }; 348 };
312 vmInStream.onClosed = () { 349 vmInStream.onClosed = () {
313 print("VM debugger connection closed"); 350 print("VM debugger connection closed");
314 quitShell(); 351 quitShell();
315 }; 352 };
316 } 353 }
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698