Index: runtime/vm/service.cc |
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
index 036bb832f9b9ae2f61ed7538a2e18acb884a27a6..0e9410f2a57783e81920f5e0f0a2a929d55a8784 100644 |
--- a/runtime/vm/service.cc |
+++ b/runtime/vm/service.cc |
@@ -733,17 +733,26 @@ static bool GetStack(Isolate* isolate, JSONStream* js) { |
const bool full = BoolParameter::Parse(js->LookupParam("full"), false); |
JSONObject jsobj(js); |
jsobj.AddProperty("type", "Stack"); |
- JSONArray jsarr(&jsobj, "frames"); |
+ { |
+ JSONArray jsarr(&jsobj, "frames"); |
+ |
+ intptr_t num_frames = stack->Length(); |
+ for (intptr_t i = 0; i < num_frames; i++) { |
+ ActivationFrame* frame = stack->FrameAt(i); |
+ JSONObject jsobj(&jsarr); |
+ frame->PrintToJSONObject(&jsobj, full); |
+ // TODO(turnidge): Implement depth differently -- differentiate |
+ // inlined frames. |
+ jsobj.AddProperty("depth", i); |
+ } |
+ } |
- intptr_t num_frames = stack->Length(); |
- for (intptr_t i = 0; i < num_frames; i++) { |
- ActivationFrame* frame = stack->FrameAt(i); |
- JSONObject jsobj(&jsarr); |
- frame->PrintToJSONObject(&jsobj, full); |
- // TODO(turnidge): Implement depth differently -- differentiate |
- // inlined frames. |
- jsobj.AddProperty("depth", i); |
+ { |
+ MessageHandler::AcquiredQueues aq; |
+ isolate->message_handler()->AcquireQueues(&aq); |
+ jsobj.AddProperty("messages", aq.queue()); |
} |
+ |
return true; |
} |
@@ -1182,6 +1191,37 @@ static SourceBreakpoint* LookupBreakpoint(Isolate* isolate, const char* id) { |
} |
turnidge
2015/05/04 17:47:13
Maybe a short function-level comment.
Cutch
2015/05/04 19:56:51
Done.
|
+static bool PrintMessage(JSONStream* js, Isolate* isolate, const char* id) { |
+ size_t end_pos = strcspn(id, "/"); |
+ const char* rest = NULL; |
+ if (end_pos < strlen(id)) { |
+ rest = id + end_pos + 1; // +1 for '/'. |
+ } |
+ if (strncmp("messages", id, end_pos) == 0) { |
+ if (rest == NULL) { |
+ return false; |
+ } |
turnidge
2015/05/04 17:47:13
I see that this code is very similar to code I wro
Cutch
2015/05/04 19:56:51
Done.
|
+ intptr_t message_id = 0; |
+ if (GetIntegerId(rest, &message_id, 16)) { |
+ MessageHandler::AcquiredQueues aq; |
+ isolate->message_handler()->AcquireQueues(&aq); |
+ Message* message = aq.queue()->FindMessageById(message_id); |
+ if (message == NULL) { |
+ // Not found. |
+ return false; |
+ } |
+ SnapshotReader reader(message->data(), |
+ message->len(), |
+ Snapshot::kMessage, |
+ isolate, |
+ isolate->current_zone()); |
+ const Object& msg_obj = Object::Handle(reader.ReadObject()); |
+ msg_obj.PrintJSON(js); |
+ return true; |
+ } |
+ } |
+ return false; |
+} |
static bool PrintInboundReferences(Isolate* isolate, |
@@ -2331,6 +2371,10 @@ static bool GetObject(Isolate* isolate, JSONStream* js) { |
return true; |
} |
+ if (PrintMessage(js, isolate, id)) { |
+ return true; |
+ } |
+ |
PrintError(js, "Unrecognized object id: %s\n", id); |
return true; |
} |