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

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

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 | « no previous file | tools/ddbg.dart » ('j') | 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 #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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 buf->Printf(","); 383 buf->Printf(",");
384 } 384 }
385 FormatValueObj(buf, value); 385 FormatValueObj(buf, value);
386 } 386 }
387 buf->Printf("]}"); 387 buf->Printf("]}");
388 return NULL; 388 return NULL;
389 } 389 }
390 390
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 intptr_t trace_len = 0; 395 intptr_t trace_len = 0;
395 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 396 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
396 ASSERT_NOT_ERROR(res); 397 ASSERT_NOT_ERROR(res);
397 Dart_ActivationFrame frame; 398 Dart_ActivationFrame frame;
398 res = Dart_GetActivationFrame(trace, 0, &frame); 399 res = Dart_GetActivationFrame(trace, 0, &frame);
399 ASSERT_NOT_ERROR(res); 400 ASSERT_NOT_ERROR(res);
400 Dart_Handle script_url; 401 Dart_Handle script_url;
401 intptr_t token_number = 0; 402 intptr_t token_number = 0;
402 intptr_t line_number = 0; 403 intptr_t line_number = 0;
403 intptr_t library_id = 0; 404 intptr_t library_id = 0;
404 // TODO(hausner): Remove this call and line_number once Editor no 405 // TODO(hausner): Remove this call and line_number once Editor no
405 // longer depends on line number info. 406 // longer depends on line number info.
406 res = Dart_ActivationFrameInfo(frame, NULL, NULL, &line_number, NULL); 407 res = Dart_ActivationFrameInfo(frame, NULL, NULL, &line_number, NULL);
407 ASSERT_NOT_ERROR(res); 408 ASSERT_NOT_ERROR(res);
408 res = Dart_ActivationFrameGetLocation( 409 res = Dart_ActivationFrameGetLocation(
409 frame, &script_url, &library_id, &token_number); 410 frame, &script_url, &library_id, &token_number);
410 ASSERT_NOT_ERROR(res); 411 ASSERT_NOT_ERROR(res);
411 if (!Dart_IsNull(script_url)) { 412 if (!Dart_IsNull(script_url)) {
412 ASSERT(Dart_IsString(script_url)); 413 ASSERT(Dart_IsString(script_url));
413 msg->Printf("\"location\": { \"url\":"); 414 msg->Printf("%s\"location\": { \"url\":", prefix);
414 FormatEncodedString(msg, script_url); 415 FormatEncodedString(msg, script_url);
415 msg->Printf(",\"libraryId\":%"Pd",", library_id); 416 msg->Printf(",\"libraryId\":%"Pd",", library_id);
416 msg->Printf("\"tokenOffset\":%"Pd",", token_number); 417 msg->Printf("\"tokenOffset\":%"Pd",", token_number);
417 msg->Printf("\"lineNumber\":%"Pd"},", line_number); 418 msg->Printf("\"lineNumber\":%"Pd"}", line_number);
418 } 419 }
419 } 420 }
420 421
421 422
422 static void FormatCallFrames(dart::TextBuffer* msg, Dart_StackTrace trace) { 423 static void FormatCallFrames(dart::TextBuffer* msg, Dart_StackTrace trace) {
423 intptr_t trace_len = 0; 424 intptr_t trace_len = 0;
424 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 425 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
425 ASSERT_NOT_ERROR(res); 426 ASSERT_NOT_ERROR(res);
426 msg->Printf("\"callFrames\" : [ "); 427 msg->Printf("\"callFrames\" : [ ");
427 for (int i = 0; i < trace_len; i++) { 428 for (int i = 0; i < trace_len; i++) {
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 } 1001 }
1001 } 1002 }
1002 1003
1003 1004
1004 // TODO(hausner): Remove stack trace parameter once we remove the stack 1005 // TODO(hausner): Remove stack trace parameter once we remove the stack
1005 // trace from the paused event in the wire protocol. 1006 // trace from the paused event in the wire protocol.
1006 void DbgMsgQueue::SendBreakpointEvent(Dart_StackTrace trace) { 1007 void DbgMsgQueue::SendBreakpointEvent(Dart_StackTrace trace) {
1007 dart::TextBuffer msg(128); 1008 dart::TextBuffer msg(128);
1008 msg.Printf("{ \"event\": \"paused\", \"params\": { "); 1009 msg.Printf("{ \"event\": \"paused\", \"params\": { ");
1009 msg.Printf("\"reason\": \"breakpoint\", "); 1010 msg.Printf("\"reason\": \"breakpoint\", ");
1010 msg.Printf("\"id\": %"Pd64", ", isolate_id_); 1011 msg.Printf("\"isolateId\": %"Pd64"", isolate_id_);
1011 FormatLocationFromTrace(&msg, trace); 1012 FormatLocationFromTrace(&msg, trace, ", ");
1012 FormatCallFrames(&msg, trace);
1013 msg.Printf("}}"); 1013 msg.Printf("}}");
1014 DebuggerConnectionHandler::BroadcastMsg(&msg); 1014 DebuggerConnectionHandler::BroadcastMsg(&msg);
1015 } 1015 }
1016 1016
1017 1017
1018 // TODO(hausner): Remove stack trace parameter once we remove the stack 1018 // TODO(hausner): Remove stack trace parameter once we remove the stack
1019 // trace from the paused event in the wire protocol. 1019 // trace from the paused event in the wire protocol.
1020 void DbgMsgQueue::SendExceptionEvent(Dart_Handle exception, 1020 void DbgMsgQueue::SendExceptionEvent(Dart_Handle exception,
1021 Dart_StackTrace stack_trace) { 1021 Dart_StackTrace stack_trace) {
1022 intptr_t exception_id = Dart_CacheObject(exception); 1022 intptr_t exception_id = Dart_CacheObject(exception);
1023 ASSERT(exception_id >= 0); 1023 ASSERT(exception_id >= 0);
1024 dart::TextBuffer msg(128); 1024 dart::TextBuffer msg(128);
1025 msg.Printf("{ \"event\": \"paused\", \"params\": {"); 1025 msg.Printf("{ \"event\": \"paused\", \"params\": {");
1026 msg.Printf("\"reason\": \"exception\", "); 1026 msg.Printf("\"reason\": \"exception\", ");
1027 msg.Printf("\"id\": %"Pd64", ", isolate_id_); 1027 msg.Printf("\"isolateId\": %"Pd64", ", isolate_id_);
1028 msg.Printf("\"exception\":"); 1028 msg.Printf("\"exception\":");
1029 FormatRemoteObj(&msg, exception); 1029 FormatRemoteObj(&msg, exception);
1030 msg.Printf(", "); 1030 FormatLocationFromTrace(&msg, stack_trace, ", ");
1031 FormatLocationFromTrace(&msg, stack_trace);
1032 FormatCallFrames(&msg, stack_trace);
1033 msg.Printf("}}"); 1031 msg.Printf("}}");
1034 DebuggerConnectionHandler::BroadcastMsg(&msg); 1032 DebuggerConnectionHandler::BroadcastMsg(&msg);
1035 } 1033 }
1036 1034
1037 1035
1038 // TODO(hausner): Remove stack trace parameter once we remove the stack 1036 // TODO(hausner): Remove stack trace parameter once we remove the stack
1039 // trace from the interrupted event in the wire protocol. 1037 // trace from the interrupted event in the wire protocol.
1040 void DbgMsgQueue::SendIsolateEvent(Dart_IsolateId isolate_id, 1038 void DbgMsgQueue::SendIsolateEvent(Dart_IsolateId isolate_id,
1041 Dart_IsolateEvent kind) { 1039 Dart_IsolateEvent kind) {
1042 dart::TextBuffer msg(128); 1040 dart::TextBuffer msg(128);
1043 if (kind == kInterrupted) { 1041 if (kind == kInterrupted) {
1044 Dart_StackTrace trace; 1042 Dart_StackTrace trace;
1045 Dart_Handle res = Dart_GetStackTrace(&trace); 1043 Dart_Handle res = Dart_GetStackTrace(&trace);
1046 ASSERT_NOT_ERROR(res); 1044 ASSERT_NOT_ERROR(res);
1047 msg.Printf("{ \"event\": \"paused\", \"params\": { "); 1045 msg.Printf("{ \"event\": \"paused\", \"params\": { ");
1048 msg.Printf("\"reason\": \"interrupted\", "); 1046 msg.Printf("\"reason\": \"interrupted\", ");
1049 msg.Printf("\"id\": %"Pd64", ", isolate_id); 1047 msg.Printf("\"isolateId\": %"Pd64"", isolate_id);
1050 FormatLocationFromTrace(&msg, trace); 1048 FormatLocationFromTrace(&msg, trace, ", ");
1051 FormatCallFrames(&msg, trace);
1052 msg.Printf("}}"); 1049 msg.Printf("}}");
1053 } else { 1050 } else {
1054 msg.Printf("{ \"event\": \"isolate\", \"params\": { "); 1051 msg.Printf("{ \"event\": \"isolate\", \"params\": { ");
1055 if (kind == kCreated) { 1052 if (kind == kCreated) {
1056 msg.Printf("\"reason\": \"created\", "); 1053 msg.Printf("\"reason\": \"created\", ");
1057 } else { 1054 } else {
1058 ASSERT(kind == kShutdown); 1055 ASSERT(kind == kShutdown);
1059 msg.Printf("\"reason\": \"shutdown\", "); 1056 msg.Printf("\"reason\": \"shutdown\", ");
1060 } 1057 }
1061 msg.Printf("\"id\": %"Pd64" ", isolate_id); 1058 msg.Printf("\"id\": %"Pd64" ", isolate_id);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 msg_queue->SendIsolateEvent(isolate_id, kind); 1233 msg_queue->SendIsolateEvent(isolate_id, kind);
1237 if (kind == kInterrupted) { 1234 if (kind == kInterrupted) {
1238 msg_queue->HandleMessages(); 1235 msg_queue->HandleMessages();
1239 } else { 1236 } else {
1240 ASSERT(kind == kShutdown); 1237 ASSERT(kind == kShutdown);
1241 RemoveIsolateMsgQueue(isolate_id); 1238 RemoveIsolateMsgQueue(isolate_id);
1242 } 1239 }
1243 } 1240 }
1244 Dart_ExitScope(); 1241 Dart_ExitScope();
1245 } 1242 }
OLDNEW
« no previous file with comments | « no previous file | tools/ddbg.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698