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

Side by Side Diff: runtime/bin/dbg_message.cc

Issue 13975018: More cleanups in debugger API and wire protocol (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 | « no previous file | runtime/include/dart_debugger_api.h » ('j') | runtime/include/dart_debugger_api.h » ('J')
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 #include "bin/dbg_connection.h" 5 #include "bin/dbg_connection.h"
6 #include "bin/dbg_message.h" 6 #include "bin/dbg_message.h"
7 #include "bin/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 static void FormatLocationFromTrace(dart::TextBuffer* msg, 392 static void FormatLocationFromTrace(dart::TextBuffer* msg,
393 Dart_StackTrace trace, 393 Dart_StackTrace trace,
394 const char* prefix) { 394 const char* prefix) {
395 intptr_t trace_len = 0; 395 intptr_t trace_len = 0;
396 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 396 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
397 ASSERT_NOT_ERROR(res); 397 ASSERT_NOT_ERROR(res);
398 Dart_ActivationFrame frame; 398 Dart_ActivationFrame frame;
399 res = Dart_GetActivationFrame(trace, 0, &frame); 399 res = Dart_GetActivationFrame(trace, 0, &frame);
400 ASSERT_NOT_ERROR(res); 400 ASSERT_NOT_ERROR(res);
401 Dart_Handle script_url; 401 Dart_CodeLocation location;
402 intptr_t token_number = 0; 402 res = Dart_ActivationFrameGetLocation(frame, NULL, &location);
403 intptr_t line_number = 0;
404 intptr_t library_id = 0;
405 // TODO(hausner): Remove this call and line_number once Editor no
406 // longer depends on line number info.
407 res = Dart_ActivationFrameInfo(frame, NULL, NULL, &line_number, NULL);
408 ASSERT_NOT_ERROR(res); 403 ASSERT_NOT_ERROR(res);
409 res = Dart_ActivationFrameGetLocation( 404 if (!Dart_IsNull(location.script_url)) {
410 frame, &script_url, &library_id, &token_number); 405 ASSERT(Dart_IsString(location.script_url));
411 ASSERT_NOT_ERROR(res);
412 if (!Dart_IsNull(script_url)) {
413 ASSERT(Dart_IsString(script_url));
414 msg->Printf("%s\"location\": { \"url\":", prefix); 406 msg->Printf("%s\"location\": { \"url\":", prefix);
415 FormatEncodedString(msg, script_url); 407 FormatEncodedString(msg, location.script_url);
416 msg->Printf(",\"libraryId\":%"Pd",", library_id); 408 msg->Printf(",\"libraryId\":%d,", location.library_id);
417 msg->Printf("\"tokenOffset\":%"Pd",", token_number); 409 msg->Printf("\"tokenOffset\":%d}", location.token_pos);
418 msg->Printf("\"lineNumber\":%"Pd"}", line_number);
419 } 410 }
420 } 411 }
421 412
422 413
423 static void FormatCallFrames(dart::TextBuffer* msg, Dart_StackTrace trace) { 414 static void FormatCallFrames(dart::TextBuffer* msg, Dart_StackTrace trace) {
424 intptr_t trace_len = 0; 415 intptr_t trace_len = 0;
425 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 416 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
426 ASSERT_NOT_ERROR(res); 417 ASSERT_NOT_ERROR(res);
427 msg->Printf("\"callFrames\" : [ "); 418 msg->Printf("\"callFrames\" : [ ");
428 for (int i = 0; i < trace_len; i++) { 419 for (int i = 0; i < trace_len; i++) {
429 Dart_ActivationFrame frame; 420 Dart_ActivationFrame frame;
430 res = Dart_GetActivationFrame(trace, i, &frame); 421 res = Dart_GetActivationFrame(trace, i, &frame);
431 ASSERT_NOT_ERROR(res); 422 ASSERT_NOT_ERROR(res);
432 Dart_Handle func_name; 423 Dart_Handle func_name;
433 Dart_Handle script_url; 424 Dart_CodeLocation location;
434 intptr_t line_number = 0; 425 res = Dart_ActivationFrameGetLocation(frame, &func_name, &location);
435 intptr_t token_number = 0;
436 intptr_t library_id = 0;
437 res = Dart_ActivationFrameInfo(
438 frame, &func_name, NULL, &line_number, &library_id);
439 ASSERT_NOT_ERROR(res); 426 ASSERT_NOT_ERROR(res);
440
441 ASSERT(Dart_IsString(func_name)); 427 ASSERT(Dart_IsString(func_name));
442 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : ""); 428 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : "");
443 FormatEncodedString(msg, func_name); 429 FormatEncodedString(msg, func_name);
444 // TODO(hausner): Remove this libraryId field when Editor 430 if (!Dart_IsNull(location.script_url)) {
445 // no longer depends on it. 431 ASSERT(Dart_IsString(location.script_url));
446 msg->Printf(",\"libraryId\": %"Pd",", library_id);
447
448 res = Dart_ActivationFrameGetLocation(
449 frame, &script_url, NULL, &token_number);
450 ASSERT_NOT_ERROR(res);
451 if (!Dart_IsNull(script_url)) {
452 ASSERT(Dart_IsString(script_url));
453 msg->Printf("\"location\": { \"url\":"); 432 msg->Printf("\"location\": { \"url\":");
454 FormatEncodedString(msg, script_url); 433 FormatEncodedString(msg, location.script_url);
455 msg->Printf(",\"libraryId\": %"Pd",", library_id); 434 msg->Printf(",\"libraryId\":%d,", location.library_id);
456 msg->Printf("\"tokenOffset\":%"Pd",", token_number); 435 msg->Printf("\"tokenOffset\":%d},", location.token_pos);
457 msg->Printf("\"lineNumber\":%"Pd"},", line_number);
458 } 436 }
459
460 Dart_Handle locals = Dart_GetLocalVariables(frame); 437 Dart_Handle locals = Dart_GetLocalVariables(frame);
461 ASSERT_NOT_ERROR(locals); 438 ASSERT_NOT_ERROR(locals);
462 msg->Printf("\"locals\":"); 439 msg->Printf("\"locals\":");
463 FormatNamedValueList(msg, locals); 440 FormatNamedValueList(msg, locals);
464 msg->Printf("}"); 441 msg->Printf("}");
465 } 442 }
466 msg->Printf("]"); 443 msg->Printf("]");
467 } 444 }
468 445
469 446
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 msg_queue->SendIsolateEvent(isolate_id, kind); 1210 msg_queue->SendIsolateEvent(isolate_id, kind);
1234 if (kind == kInterrupted) { 1211 if (kind == kInterrupted) {
1235 msg_queue->HandleMessages(); 1212 msg_queue->HandleMessages();
1236 } else { 1213 } else {
1237 ASSERT(kind == kShutdown); 1214 ASSERT(kind == kShutdown);
1238 RemoveIsolateMsgQueue(isolate_id); 1215 RemoveIsolateMsgQueue(isolate_id);
1239 } 1216 }
1240 } 1217 }
1241 Dart_ExitScope(); 1218 Dart_ExitScope();
1242 } 1219 }
OLDNEW
« no previous file with comments | « no previous file | runtime/include/dart_debugger_api.h » ('j') | runtime/include/dart_debugger_api.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698