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

Unified Diff: runtime/vm/service.cc

Issue 1122503003: Display isolate message queue in Observatory debugger (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698