OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "vm/service.h" | 5 #include "vm/service.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 }; | 726 }; |
727 | 727 |
728 | 728 |
729 static bool GetStack(Isolate* isolate, JSONStream* js) { | 729 static bool GetStack(Isolate* isolate, JSONStream* js) { |
730 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 730 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
731 // Do we want the complete script object and complete local variable objects? | 731 // Do we want the complete script object and complete local variable objects? |
732 // This is true for dump requests. | 732 // This is true for dump requests. |
733 const bool full = BoolParameter::Parse(js->LookupParam("full"), false); | 733 const bool full = BoolParameter::Parse(js->LookupParam("full"), false); |
734 JSONObject jsobj(js); | 734 JSONObject jsobj(js); |
735 jsobj.AddProperty("type", "Stack"); | 735 jsobj.AddProperty("type", "Stack"); |
736 JSONArray jsarr(&jsobj, "frames"); | 736 { |
737 JSONArray jsarr(&jsobj, "frames"); | |
737 | 738 |
738 intptr_t num_frames = stack->Length(); | 739 intptr_t num_frames = stack->Length(); |
739 for (intptr_t i = 0; i < num_frames; i++) { | 740 for (intptr_t i = 0; i < num_frames; i++) { |
740 ActivationFrame* frame = stack->FrameAt(i); | 741 ActivationFrame* frame = stack->FrameAt(i); |
741 JSONObject jsobj(&jsarr); | 742 JSONObject jsobj(&jsarr); |
742 frame->PrintToJSONObject(&jsobj, full); | 743 frame->PrintToJSONObject(&jsobj, full); |
743 // TODO(turnidge): Implement depth differently -- differentiate | 744 // TODO(turnidge): Implement depth differently -- differentiate |
744 // inlined frames. | 745 // inlined frames. |
745 jsobj.AddProperty("depth", i); | 746 jsobj.AddProperty("depth", i); |
747 } | |
746 } | 748 } |
749 | |
750 { | |
751 MessageHandler::AcquiredQueues aq; | |
752 isolate->message_handler()->AcquireQueues(&aq); | |
753 jsobj.AddProperty("messages", aq.queue()); | |
754 } | |
755 | |
747 return true; | 756 return true; |
748 } | 757 } |
749 | 758 |
750 | 759 |
751 static bool HandleCommonEcho(JSONObject* jsobj, JSONStream* js) { | 760 static bool HandleCommonEcho(JSONObject* jsobj, JSONStream* js) { |
752 jsobj->AddProperty("type", "_EchoResponse"); | 761 jsobj->AddProperty("type", "_EchoResponse"); |
753 if (js->HasParam("text")) { | 762 if (js->HasParam("text")) { |
754 jsobj->AddProperty("text", js->LookupParam("text")); | 763 jsobj->AddProperty("text", js->LookupParam("text")); |
755 } | 764 } |
756 return true; | 765 return true; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1174 intptr_t bpt_id = 0; | 1183 intptr_t bpt_id = 0; |
1175 SourceBreakpoint* bpt = NULL; | 1184 SourceBreakpoint* bpt = NULL; |
1176 if (GetIntegerId(rest, &bpt_id)) { | 1185 if (GetIntegerId(rest, &bpt_id)) { |
1177 bpt = isolate->debugger()->GetBreakpointById(bpt_id); | 1186 bpt = isolate->debugger()->GetBreakpointById(bpt_id); |
1178 } | 1187 } |
1179 return bpt; | 1188 return bpt; |
1180 } | 1189 } |
1181 return NULL; | 1190 return NULL; |
1182 } | 1191 } |
1183 | 1192 |
1184 | 1193 |
turnidge
2015/05/04 17:47:13
Maybe a short function-level comment.
Cutch
2015/05/04 19:56:51
Done.
| |
1194 static bool PrintMessage(JSONStream* js, Isolate* isolate, const char* id) { | |
1195 size_t end_pos = strcspn(id, "/"); | |
1196 const char* rest = NULL; | |
1197 if (end_pos < strlen(id)) { | |
1198 rest = id + end_pos + 1; // +1 for '/'. | |
1199 } | |
1200 if (strncmp("messages", id, end_pos) == 0) { | |
1201 if (rest == NULL) { | |
1202 return false; | |
1203 } | |
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.
| |
1204 intptr_t message_id = 0; | |
1205 if (GetIntegerId(rest, &message_id, 16)) { | |
1206 MessageHandler::AcquiredQueues aq; | |
1207 isolate->message_handler()->AcquireQueues(&aq); | |
1208 Message* message = aq.queue()->FindMessageById(message_id); | |
1209 if (message == NULL) { | |
1210 // Not found. | |
1211 return false; | |
1212 } | |
1213 SnapshotReader reader(message->data(), | |
1214 message->len(), | |
1215 Snapshot::kMessage, | |
1216 isolate, | |
1217 isolate->current_zone()); | |
1218 const Object& msg_obj = Object::Handle(reader.ReadObject()); | |
1219 msg_obj.PrintJSON(js); | |
1220 return true; | |
1221 } | |
1222 } | |
1223 return false; | |
1224 } | |
1185 | 1225 |
1186 | 1226 |
1187 static bool PrintInboundReferences(Isolate* isolate, | 1227 static bool PrintInboundReferences(Isolate* isolate, |
1188 Object* target, | 1228 Object* target, |
1189 intptr_t limit, | 1229 intptr_t limit, |
1190 JSONStream* js) { | 1230 JSONStream* js) { |
1191 ObjectGraph graph(isolate); | 1231 ObjectGraph graph(isolate); |
1192 Array& path = Array::Handle(Array::New(limit * 2)); | 1232 Array& path = Array::Handle(Array::New(limit * 2)); |
1193 intptr_t length = graph.InboundReferences(target, path); | 1233 intptr_t length = graph.InboundReferences(target, path); |
1194 JSONObject jsobj(js); | 1234 JSONObject jsobj(js); |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2324 return true; | 2364 return true; |
2325 } | 2365 } |
2326 | 2366 |
2327 // Handle non-heap objects. | 2367 // Handle non-heap objects. |
2328 SourceBreakpoint* bpt = LookupBreakpoint(isolate, id); | 2368 SourceBreakpoint* bpt = LookupBreakpoint(isolate, id); |
2329 if (bpt != NULL) { | 2369 if (bpt != NULL) { |
2330 bpt->PrintJSON(js); | 2370 bpt->PrintJSON(js); |
2331 return true; | 2371 return true; |
2332 } | 2372 } |
2333 | 2373 |
2374 if (PrintMessage(js, isolate, id)) { | |
2375 return true; | |
2376 } | |
2377 | |
2334 PrintError(js, "Unrecognized object id: %s\n", id); | 2378 PrintError(js, "Unrecognized object id: %s\n", id); |
2335 return true; | 2379 return true; |
2336 } | 2380 } |
2337 | 2381 |
2338 | 2382 |
2339 static const MethodParameter* get_class_list_params[] = { | 2383 static const MethodParameter* get_class_list_params[] = { |
2340 ISOLATE_PARAMETER, | 2384 ISOLATE_PARAMETER, |
2341 NULL, | 2385 NULL, |
2342 }; | 2386 }; |
2343 | 2387 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2582 ServiceMethodDescriptor& method = service_methods_[i]; | 2626 ServiceMethodDescriptor& method = service_methods_[i]; |
2583 if (strcmp(method_name, method.name) == 0) { | 2627 if (strcmp(method_name, method.name) == 0) { |
2584 return &method; | 2628 return &method; |
2585 } | 2629 } |
2586 } | 2630 } |
2587 return NULL; | 2631 return NULL; |
2588 } | 2632 } |
2589 | 2633 |
2590 | 2634 |
2591 } // namespace dart | 2635 } // namespace dart |
OLD | NEW |