| OLD | NEW |
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } else if (Dart_IsError(text)) { | 203 } else if (Dart_IsError(text)) { |
| 204 buf->Printf("#ERROR"); | 204 buf->Printf("#ERROR"); |
| 205 } else { | 205 } else { |
| 206 FormatEncodedCharsTrunc(buf, text, max_chars); | 206 FormatEncodedCharsTrunc(buf, text, max_chars); |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 static void FormatValue(dart::TextBuffer* buf, Dart_Handle object) { | 212 static void FormatValue(dart::TextBuffer* buf, Dart_Handle object) { |
| 213 if (Dart_IsInteger(object)) { | 213 if (Dart_IsNumber(object)) { |
| 214 buf->Printf("\"kind\":\"integer\","); | 214 buf->Printf("\"kind\":\"number\","); |
| 215 } else if (Dart_IsString(object)) { | 215 } else if (Dart_IsString(object)) { |
| 216 buf->Printf("\"kind\":\"string\","); | 216 buf->Printf("\"kind\":\"string\","); |
| 217 } else if (Dart_IsBoolean(object)) { | 217 } else if (Dart_IsBoolean(object)) { |
| 218 buf->Printf("\"kind\":\"boolean\","); | 218 buf->Printf("\"kind\":\"boolean\","); |
| 219 } else if (Dart_IsList(object)) { | 219 } else if (Dart_IsList(object)) { |
| 220 intptr_t len = 0; | 220 intptr_t len = 0; |
| 221 Dart_Handle res = Dart_ListLength(object, &len); | 221 Dart_Handle res = Dart_ListLength(object, &len); |
| 222 ASSERT_NOT_ERROR(res); | 222 ASSERT_NOT_ERROR(res); |
| 223 buf->Printf("\"kind\":\"list\",\"length\":%"Pd",", len); | 223 buf->Printf("\"kind\":\"list\",\"length\":%"Pd",", len); |
| 224 } else { | 224 } else { |
| 225 buf->Printf("\"kind\":\"object\","); | 225 buf->Printf("\"kind\":\"object\","); |
| 226 intptr_t class_id = 0; |
| 227 Dart_Handle res = Dart_GetObjClassId(object, &class_id); |
| 228 if (!Dart_IsError(res)) { |
| 229 buf->Printf("\"classId\":%"Pd",", class_id); |
| 230 } |
| 226 } | 231 } |
| 227 buf->Printf("\"text\":\""); | 232 buf->Printf("\"text\":\""); |
| 228 const intptr_t max_chars = 250; | 233 const intptr_t max_chars = 250; |
| 229 FormatTextualValue(buf, object, max_chars); | 234 FormatTextualValue(buf, object, max_chars); |
| 230 buf->Printf("\""); | 235 buf->Printf("\""); |
| 231 } | 236 } |
| 232 | 237 |
| 233 | 238 |
| 234 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) { | 239 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) { |
| 235 buf->Printf("{"); | 240 buf->Printf("{"); |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 | 1161 |
| 1157 | 1162 |
| 1158 void DbgMsgQueueList::BptResolvedHandler(Dart_IsolateId isolate_id, | 1163 void DbgMsgQueueList::BptResolvedHandler(Dart_IsolateId isolate_id, |
| 1159 intptr_t bp_id, | 1164 intptr_t bp_id, |
| 1160 const Dart_CodeLocation& location) { | 1165 const Dart_CodeLocation& location) { |
| 1161 Dart_EnterScope(); | 1166 Dart_EnterScope(); |
| 1162 dart::TextBuffer msg(128); | 1167 dart::TextBuffer msg(128); |
| 1163 msg.Printf("{ \"event\": \"breakpointResolved\", \"params\": {"); | 1168 msg.Printf("{ \"event\": \"breakpointResolved\", \"params\": {"); |
| 1164 msg.Printf("\"breakpointId\": %"Pd"", bp_id); | 1169 msg.Printf("\"breakpointId\": %"Pd"", bp_id); |
| 1165 | 1170 |
| 1166 // TODO(hausner): remove url and line elements. | |
| 1167 msg.Printf(", \"url\":"); | |
| 1168 FormatEncodedString(&msg, location.script_url); | |
| 1169 int line_number = GetIntValue(Dart_GetBreakpointLine(bp_id)); | |
| 1170 msg.Printf(",\"line\":%d", line_number); | |
| 1171 | |
| 1172 msg.Printf(", \"isolateId\":%"Pd64"", isolate_id); | 1171 msg.Printf(", \"isolateId\":%"Pd64"", isolate_id); |
| 1173 ASSERT(!Dart_IsNull(location.script_url)); | 1172 ASSERT(!Dart_IsNull(location.script_url)); |
| 1174 ASSERT(Dart_IsString(location.script_url)); | 1173 ASSERT(Dart_IsString(location.script_url)); |
| 1175 msg.Printf(", \"location\":{\"url\":"); | 1174 msg.Printf(", \"location\":{\"url\":"); |
| 1176 FormatEncodedString(&msg, location.script_url); | 1175 FormatEncodedString(&msg, location.script_url); |
| 1177 msg.Printf(",\"libraryId\":%d", location.library_id); | 1176 msg.Printf(",\"libraryId\":%d", location.library_id); |
| 1178 msg.Printf(",\"tokenOffset\":%d}}}", location.token_pos); | 1177 msg.Printf(",\"tokenOffset\":%d}}}", location.token_pos); |
| 1179 | 1178 |
| 1180 DbgMsgQueue* msg_queue = GetIsolateMsgQueue(isolate_id); | 1179 DbgMsgQueue* msg_queue = GetIsolateMsgQueue(isolate_id); |
| 1181 ASSERT(msg_queue != NULL); | 1180 ASSERT(msg_queue != NULL); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 msg_queue->SendIsolateEvent(isolate_id, kind); | 1224 msg_queue->SendIsolateEvent(isolate_id, kind); |
| 1226 if (kind == kInterrupted) { | 1225 if (kind == kInterrupted) { |
| 1227 msg_queue->HandleMessages(); | 1226 msg_queue->HandleMessages(); |
| 1228 } else { | 1227 } else { |
| 1229 ASSERT(kind == kShutdown); | 1228 ASSERT(kind == kShutdown); |
| 1230 RemoveIsolateMsgQueue(isolate_id); | 1229 RemoveIsolateMsgQueue(isolate_id); |
| 1231 } | 1230 } |
| 1232 } | 1231 } |
| 1233 Dart_ExitScope(); | 1232 Dart_ExitScope(); |
| 1234 } | 1233 } |
| OLD | NEW |