| 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/debugger.h" | 5 #include "vm/debugger.h" |
| 6 #include "vm/heap_histogram.h" | 6 #include "vm/heap_histogram.h" |
| 7 #include "vm/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/message.h" | 8 #include "vm/message.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/object_id_ring.h" | 10 #include "vm/object_id_ring.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 handler(isolate, &js); | 111 handler(isolate, &js); |
| 112 const String& reply = String::Handle(String::New(js.ToCString())); | 112 const String& reply = String::Handle(String::New(js.ToCString())); |
| 113 ASSERT(!reply.IsNull()); | 113 ASSERT(!reply.IsNull()); |
| 114 PostReply(reply, reply_port); | 114 PostReply(reply, reply_port); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 static void PrintArgumentsAndOptions(const JSONObject& obj, JSONStream* js) { | 120 static void PrintArgumentsAndOptions(const JSONObject& obj, JSONStream* js) { |
| 121 JSONObject jsobj(obj, "message"); | 121 JSONObject jsobj(&obj, "message"); |
| 122 { | 122 { |
| 123 JSONArray jsarr(jsobj, "arguments"); | 123 JSONArray jsarr(&jsobj, "arguments"); |
| 124 for (intptr_t i = 0; i < js->num_arguments(); i++) { | 124 for (intptr_t i = 0; i < js->num_arguments(); i++) { |
| 125 jsarr.AddValue(js->GetArgument(i)); | 125 jsarr.AddValue(js->GetArgument(i)); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 { | 128 { |
| 129 JSONArray jsarr(jsobj, "option_keys"); | 129 JSONArray jsarr(&jsobj, "option_keys"); |
| 130 for (intptr_t i = 0; i < js->num_options(); i++) { | 130 for (intptr_t i = 0; i < js->num_options(); i++) { |
| 131 jsarr.AddValue(js->GetOptionKey(i)); | 131 jsarr.AddValue(js->GetOptionKey(i)); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 { | 134 { |
| 135 JSONArray jsarr(jsobj, "option_values"); | 135 JSONArray jsarr(&jsobj, "option_values"); |
| 136 for (intptr_t i = 0; i < js->num_options(); i++) { | 136 for (intptr_t i = 0; i < js->num_options(); i++) { |
| 137 jsarr.AddValue(js->GetOptionValue(i)); | 137 jsarr.AddValue(js->GetOptionValue(i)); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 | 142 |
| 143 static void PrintCollectionErrorResponse(const char* collection_name, | 143 static void PrintCollectionErrorResponse(const char* collection_name, |
| 144 JSONStream* js) { | 144 JSONStream* js) { |
| 145 JSONObject jsobj(js); | 145 JSONObject jsobj(js); |
| 146 jsobj.AddProperty("type", "error"); | 146 jsobj.AddProperty("type", "error"); |
| 147 jsobj.AddPropertyF("text", "Must specify collection object id: /%s/id", | 147 jsobj.AddPropertyF("text", "Must specify collection object id: /%s/id", |
| 148 collection_name); | 148 collection_name); |
| 149 } | 149 } |
| 150 | 150 |
| 151 | 151 |
| 152 static void HandleName(Isolate* isolate, JSONStream* js) { | 152 static void HandleName(Isolate* isolate, JSONStream* js) { |
| 153 JSONObject jsobj(js); | 153 JSONObject jsobj(js); |
| 154 jsobj.AddProperty("type", "IsolateName"); | 154 jsobj.AddProperty("type", "IsolateName"); |
| 155 jsobj.AddProperty("id", static_cast<intptr_t>(isolate->main_port())); | 155 jsobj.AddProperty("id", static_cast<intptr_t>(isolate->main_port())); |
| 156 jsobj.AddProperty("name", isolate->name()); | 156 jsobj.AddProperty("name", isolate->name()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 static void HandleStackTrace(Isolate* isolate, JSONStream* js) { | 160 static void HandleStackTrace(Isolate* isolate, JSONStream* js) { |
| 161 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 161 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
| 162 JSONObject jsobj(js); | 162 JSONObject jsobj(js); |
| 163 jsobj.AddProperty("type", "StackTrace"); | 163 jsobj.AddProperty("type", "StackTrace"); |
| 164 JSONArray jsarr(jsobj, "members"); | 164 JSONArray jsarr(&jsobj, "members"); |
| 165 intptr_t n_frames = stack->Length(); | 165 intptr_t n_frames = stack->Length(); |
| 166 String& url = String::Handle(); | 166 String& url = String::Handle(); |
| 167 String& function = String::Handle(); | 167 String& function = String::Handle(); |
| 168 for (int i = 0; i < n_frames; i++) { | 168 for (int i = 0; i < n_frames; i++) { |
| 169 ActivationFrame* frame = stack->FrameAt(i); | 169 ActivationFrame* frame = stack->FrameAt(i); |
| 170 url ^= frame->SourceUrl(); | 170 url ^= frame->SourceUrl(); |
| 171 function ^= frame->function().UserVisibleName(); | 171 function ^= frame->function().UserVisibleName(); |
| 172 JSONObject jsobj(jsarr); | 172 JSONObject jsobj(&jsarr); |
| 173 jsobj.AddProperty("name", function.ToCString()); | 173 jsobj.AddProperty("name", function.ToCString()); |
| 174 jsobj.AddProperty("url", url.ToCString()); | 174 jsobj.AddProperty("url", url.ToCString()); |
| 175 jsobj.AddProperty("line", frame->LineNumber()); | 175 jsobj.AddProperty("line", frame->LineNumber()); |
| 176 jsobj.AddProperty("function", frame->function()); | 176 jsobj.AddProperty("function", frame->function()); |
| 177 jsobj.AddProperty("code", frame->code()); | 177 jsobj.AddProperty("code", frame->code()); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 | 181 |
| 182 static void HandleObjectHistogram(Isolate* isolate, JSONStream* js) { | 182 static void HandleObjectHistogram(Isolate* isolate, JSONStream* js) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 for (intptr_t i = 0; i < num_message_handlers; i++) { | 273 for (intptr_t i = 0; i < num_message_handlers; i++) { |
| 274 const ServiceMessageHandlerEntry& entry = __message_handlers[i]; | 274 const ServiceMessageHandlerEntry& entry = __message_handlers[i]; |
| 275 if (!strcmp(command, entry.command)) { | 275 if (!strcmp(command, entry.command)) { |
| 276 return entry.handler; | 276 return entry.handler; |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 return HandleFallthrough; | 279 return HandleFallthrough; |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace dart | 282 } // namespace dart |
| OLD | NEW |