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

Side by Side Diff: runtime/bin/dbg_message.cc

Issue 23072026: fix cpp11 compile errors (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (Dart_IsNumber(object)) { 225 if (Dart_IsNumber(object)) {
226 buf->Printf("\"kind\":\"number\","); 226 buf->Printf("\"kind\":\"number\",");
227 } else if (Dart_IsString(object)) { 227 } else if (Dart_IsString(object)) {
228 buf->Printf("\"kind\":\"string\","); 228 buf->Printf("\"kind\":\"string\",");
229 } else if (Dart_IsBoolean(object)) { 229 } else if (Dart_IsBoolean(object)) {
230 buf->Printf("\"kind\":\"boolean\","); 230 buf->Printf("\"kind\":\"boolean\",");
231 } else if (Dart_IsList(object)) { 231 } else if (Dart_IsList(object)) {
232 intptr_t len = 0; 232 intptr_t len = 0;
233 Dart_Handle res = Dart_ListLength(object, &len); 233 Dart_Handle res = Dart_ListLength(object, &len);
234 ASSERT_NOT_ERROR(res); 234 ASSERT_NOT_ERROR(res);
235 buf->Printf("\"kind\":\"list\",\"length\":%"Pd",", len); 235 buf->Printf("\"kind\":\"list\",\"length\":%" Pd ",", len);
236 } else { 236 } else {
237 buf->Printf("\"kind\":\"object\","); 237 buf->Printf("\"kind\":\"object\",");
238 intptr_t class_id = 0; 238 intptr_t class_id = 0;
239 Dart_Handle res = Dart_GetObjClassId(object, &class_id); 239 Dart_Handle res = Dart_GetObjClassId(object, &class_id);
240 if (!Dart_IsError(res)) { 240 if (!Dart_IsError(res)) {
241 buf->Printf("\"classId\":%"Pd",", class_id); 241 buf->Printf("\"classId\":%" Pd ",", class_id);
242 } 242 }
243 } 243 }
244 buf->Printf("\"text\":\""); 244 buf->Printf("\"text\":\"");
245 const intptr_t max_chars = 250; 245 const intptr_t max_chars = 250;
246 FormatTextualValue(buf, object, max_chars); 246 FormatTextualValue(buf, object, max_chars);
247 buf->Printf("\""); 247 buf->Printf("\"");
248 } 248 }
249 249
250 250
251 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) { 251 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) {
252 buf->Printf("{"); 252 buf->Printf("{");
253 FormatValue(buf, object); 253 FormatValue(buf, object);
254 buf->Printf("}"); 254 buf->Printf("}");
255 } 255 }
256 256
257 257
258 static void FormatRemoteObj(dart::TextBuffer* buf, Dart_Handle object) { 258 static void FormatRemoteObj(dart::TextBuffer* buf, Dart_Handle object) {
259 intptr_t obj_id = Dart_CacheObject(object); 259 intptr_t obj_id = Dart_CacheObject(object);
260 ASSERT(obj_id >= 0); 260 ASSERT(obj_id >= 0);
261 buf->Printf("{\"objectId\":%"Pd",", obj_id); 261 buf->Printf("{\"objectId\":%" Pd ",", obj_id);
262 FormatValue(buf, object); 262 FormatValue(buf, object);
263 buf->Printf("}"); 263 buf->Printf("}");
264 } 264 }
265 265
266 266
267 static void FormatNamedValue(dart::TextBuffer* buf, 267 static void FormatNamedValue(dart::TextBuffer* buf,
268 Dart_Handle object_name, 268 Dart_Handle object_name,
269 Dart_Handle object) { 269 Dart_Handle object) {
270 ASSERT(Dart_IsString(object_name)); 270 ASSERT(Dart_IsString(object_name));
271 buf->Printf("{\"name\":\"%s\",", GetStringChars(object_name)); 271 buf->Printf("{\"name\":\"%s\",", GetStringChars(object_name));
(...skipping 29 matching lines...) Expand all
301 intptr_t cls_id) { 301 intptr_t cls_id) {
302 Dart_Handle name, static_fields; 302 Dart_Handle name, static_fields;
303 intptr_t super_id = -1; 303 intptr_t super_id = -1;
304 intptr_t library_id = -1; 304 intptr_t library_id = -1;
305 Dart_Handle res = 305 Dart_Handle res =
306 Dart_GetClassInfo(cls_id, &name, &library_id, &super_id, &static_fields); 306 Dart_GetClassInfo(cls_id, &name, &library_id, &super_id, &static_fields);
307 RETURN_IF_ERROR(res); 307 RETURN_IF_ERROR(res);
308 RETURN_IF_ERROR(name); 308 RETURN_IF_ERROR(name);
309 buf->Printf("{\"name\":\"%s\",", GetStringChars(name)); 309 buf->Printf("{\"name\":\"%s\",", GetStringChars(name));
310 if (super_id > 0) { 310 if (super_id > 0) {
311 buf->Printf("\"superclassId\":%"Pd",", super_id); 311 buf->Printf("\"superclassId\":%" Pd ",", super_id);
312 } 312 }
313 buf->Printf("\"libraryId\":%"Pd",", library_id); 313 buf->Printf("\"libraryId\":%" Pd ",", library_id);
314 RETURN_IF_ERROR(static_fields); 314 RETURN_IF_ERROR(static_fields);
315 buf->Printf("\"fields\":"); 315 buf->Printf("\"fields\":");
316 FormatNamedValueList(buf, static_fields); 316 FormatNamedValueList(buf, static_fields);
317 buf->Printf("}"); 317 buf->Printf("}");
318 return NULL; 318 return NULL;
319 } 319 }
320 320
321 321
322 static const char* FormatLibraryProps(dart::TextBuffer* buf, 322 static const char* FormatLibraryProps(dart::TextBuffer* buf,
323 intptr_t lib_id) { 323 intptr_t lib_id) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 367
368 static const char* FormatObjProps(dart::TextBuffer* buf, 368 static const char* FormatObjProps(dart::TextBuffer* buf,
369 Dart_Handle object) { 369 Dart_Handle object) {
370 intptr_t class_id; 370 intptr_t class_id;
371 if (Dart_IsNull(object)) { 371 if (Dart_IsNull(object)) {
372 buf->Printf("{\"classId\":-1,\"fields\":[]}"); 372 buf->Printf("{\"classId\":-1,\"fields\":[]}");
373 return NULL; 373 return NULL;
374 } 374 }
375 Dart_Handle res = Dart_GetObjClassId(object, &class_id); 375 Dart_Handle res = Dart_GetObjClassId(object, &class_id);
376 RETURN_IF_ERROR(res); 376 RETURN_IF_ERROR(res);
377 buf->Printf("{\"classId\": %"Pd",", class_id); 377 buf->Printf("{\"classId\": %" Pd ",", class_id);
378 buf->Printf("\"kind\":\"object\",\"fields\":"); 378 buf->Printf("\"kind\":\"object\",\"fields\":");
379 Dart_Handle fields = Dart_GetInstanceFields(object); 379 Dart_Handle fields = Dart_GetInstanceFields(object);
380 RETURN_IF_ERROR(fields); 380 RETURN_IF_ERROR(fields);
381 FormatNamedValueList(buf, fields); 381 FormatNamedValueList(buf, fields);
382 buf->Printf("}"); 382 buf->Printf("}");
383 return NULL; 383 return NULL;
384 } 384 }
385 385
386 386
387 static const char* FormatListSlice(dart::TextBuffer* buf, 387 static const char* FormatListSlice(dart::TextBuffer* buf,
388 Dart_Handle list, 388 Dart_Handle list,
389 intptr_t list_length, 389 intptr_t list_length,
390 intptr_t index, 390 intptr_t index,
391 intptr_t slice_length) { 391 intptr_t slice_length) {
392 intptr_t end_index = index + slice_length; 392 intptr_t end_index = index + slice_length;
393 ASSERT(end_index <= list_length); 393 ASSERT(end_index <= list_length);
394 buf->Printf("{\"index\":%"Pd",", index); 394 buf->Printf("{\"index\":%" Pd ",", index);
395 buf->Printf("\"length\":%"Pd",", slice_length); 395 buf->Printf("\"length\":%" Pd ",", slice_length);
396 buf->Printf("\"elements\":["); 396 buf->Printf("\"elements\":[");
397 for (intptr_t i = index; i < end_index; i++) { 397 for (intptr_t i = index; i < end_index; i++) {
398 Dart_Handle value = Dart_ListGetAt(list, i); 398 Dart_Handle value = Dart_ListGetAt(list, i);
399 if (i > index) { 399 if (i > index) {
400 buf->Printf(","); 400 buf->Printf(",");
401 } 401 }
402 FormatValueObj(buf, value); 402 FormatValueObj(buf, value);
403 } 403 }
404 buf->Printf("]}"); 404 buf->Printf("]}");
405 return NULL; 405 return NULL;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 Dart_Handle bp_id = Dart_SetBreakpoint(url, line_number); 919 Dart_Handle bp_id = Dart_SetBreakpoint(url, line_number);
920 if (Dart_IsError(bp_id)) { 920 if (Dart_IsError(bp_id)) {
921 in_msg->SendErrorReply(msg_id, Dart_GetError(bp_id)); 921 in_msg->SendErrorReply(msg_id, Dart_GetError(bp_id));
922 return false; 922 return false;
923 } 923 }
924 ASSERT(Dart_IsInteger(bp_id)); 924 ASSERT(Dart_IsInteger(bp_id));
925 uint64_t bp_id_value; 925 uint64_t bp_id_value;
926 Dart_Handle res = Dart_IntegerToUint64(bp_id, &bp_id_value); 926 Dart_Handle res = Dart_IntegerToUint64(bp_id, &bp_id_value);
927 ASSERT_NOT_ERROR(res); 927 ASSERT_NOT_ERROR(res);
928 dart::TextBuffer msg(64); 928 dart::TextBuffer msg(64);
929 msg.Printf("{ \"id\": %d, \"result\": { \"breakpointId\": %"Pu64" }}", 929 msg.Printf("{ \"id\": %d, \"result\": { \"breakpointId\": %" Pu64 " }}",
930 msg_id, bp_id_value); 930 msg_id, bp_id_value);
931 in_msg->SendReply(&msg); 931 in_msg->SendReply(&msg);
932 return false; 932 return false;
933 } 933 }
934 934
935 935
936 bool DbgMessage::HandlePauseOnExcCmd(DbgMessage* in_msg) { 936 bool DbgMessage::HandlePauseOnExcCmd(DbgMessage* in_msg) {
937 ASSERT(in_msg != NULL); 937 ASSERT(in_msg != NULL);
938 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); 938 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
939 int msg_id = msg_parser.MessageId(); 939 int msg_id = msg_parser.MessageId();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 DebuggerConnectionHandler::BroadcastMsg(&queued_output_messages_); 1042 DebuggerConnectionHandler::BroadcastMsg(&queued_output_messages_);
1043 queued_output_messages_.Clear(); 1043 queued_output_messages_.Clear();
1044 } 1044 }
1045 } 1045 }
1046 1046
1047 1047
1048 void DbgMsgQueue::SendBreakpointEvent(const Dart_CodeLocation& location) { 1048 void DbgMsgQueue::SendBreakpointEvent(const Dart_CodeLocation& location) {
1049 dart::TextBuffer msg(128); 1049 dart::TextBuffer msg(128);
1050 msg.Printf("{ \"event\": \"paused\", \"params\": { "); 1050 msg.Printf("{ \"event\": \"paused\", \"params\": { ");
1051 msg.Printf("\"reason\": \"breakpoint\", "); 1051 msg.Printf("\"reason\": \"breakpoint\", ");
1052 msg.Printf("\"isolateId\": %"Pd64"", isolate_id_); 1052 msg.Printf("\"isolateId\": %" Pd64 "", isolate_id_);
1053 if (!Dart_IsNull(location.script_url)) { 1053 if (!Dart_IsNull(location.script_url)) {
1054 ASSERT(Dart_IsString(location.script_url)); 1054 ASSERT(Dart_IsString(location.script_url));
1055 msg.Printf(",\"location\": { \"url\":"); 1055 msg.Printf(",\"location\": { \"url\":");
1056 FormatEncodedString(&msg, location.script_url); 1056 FormatEncodedString(&msg, location.script_url);
1057 msg.Printf(",\"libraryId\":%d,", location.library_id); 1057 msg.Printf(",\"libraryId\":%d,", location.library_id);
1058 msg.Printf("\"tokenOffset\":%d}", location.token_pos); 1058 msg.Printf("\"tokenOffset\":%d}", location.token_pos);
1059 } 1059 }
1060 msg.Printf("}}"); 1060 msg.Printf("}}");
1061 DebuggerConnectionHandler::BroadcastMsg(&msg); 1061 DebuggerConnectionHandler::BroadcastMsg(&msg);
1062 } 1062 }
1063 1063
1064 1064
1065 // TODO(hausner): Remove stack trace parameter once we remove the stack 1065 // TODO(hausner): Remove stack trace parameter once we remove the stack
1066 // trace from the paused event in the wire protocol. 1066 // trace from the paused event in the wire protocol.
1067 void DbgMsgQueue::SendExceptionEvent(Dart_Handle exception, 1067 void DbgMsgQueue::SendExceptionEvent(Dart_Handle exception,
1068 Dart_StackTrace stack_trace) { 1068 Dart_StackTrace stack_trace) {
1069 intptr_t exception_id = Dart_CacheObject(exception); 1069 intptr_t exception_id = Dart_CacheObject(exception);
1070 ASSERT(exception_id >= 0); 1070 ASSERT(exception_id >= 0);
1071 dart::TextBuffer msg(128); 1071 dart::TextBuffer msg(128);
1072 msg.Printf("{ \"event\": \"paused\", \"params\": {"); 1072 msg.Printf("{ \"event\": \"paused\", \"params\": {");
1073 msg.Printf("\"reason\": \"exception\", "); 1073 msg.Printf("\"reason\": \"exception\", ");
1074 msg.Printf("\"isolateId\": %"Pd64", ", isolate_id_); 1074 msg.Printf("\"isolateId\": %" Pd64 ", ", isolate_id_);
1075 msg.Printf("\"exception\":"); 1075 msg.Printf("\"exception\":");
1076 FormatRemoteObj(&msg, exception); 1076 FormatRemoteObj(&msg, exception);
1077 FormatLocationFromTrace(&msg, stack_trace, ", "); 1077 FormatLocationFromTrace(&msg, stack_trace, ", ");
1078 msg.Printf("}}"); 1078 msg.Printf("}}");
1079 DebuggerConnectionHandler::BroadcastMsg(&msg); 1079 DebuggerConnectionHandler::BroadcastMsg(&msg);
1080 } 1080 }
1081 1081
1082 1082
1083 // TODO(hausner): Remove stack trace parameter once we remove the stack 1083 // TODO(hausner): Remove stack trace parameter once we remove the stack
1084 // trace from the interrupted event in the wire protocol. 1084 // trace from the interrupted event in the wire protocol.
1085 void DbgMsgQueue::SendIsolateEvent(Dart_IsolateId isolate_id, 1085 void DbgMsgQueue::SendIsolateEvent(Dart_IsolateId isolate_id,
1086 Dart_IsolateEvent kind) { 1086 Dart_IsolateEvent kind) {
1087 dart::TextBuffer msg(128); 1087 dart::TextBuffer msg(128);
1088 if (kind == kInterrupted) { 1088 if (kind == kInterrupted) {
1089 Dart_StackTrace trace; 1089 Dart_StackTrace trace;
1090 Dart_Handle res = Dart_GetStackTrace(&trace); 1090 Dart_Handle res = Dart_GetStackTrace(&trace);
1091 ASSERT_NOT_ERROR(res); 1091 ASSERT_NOT_ERROR(res);
1092 msg.Printf("{ \"event\": \"paused\", \"params\": { "); 1092 msg.Printf("{ \"event\": \"paused\", \"params\": { ");
1093 msg.Printf("\"reason\": \"interrupted\", "); 1093 msg.Printf("\"reason\": \"interrupted\", ");
1094 msg.Printf("\"isolateId\": %"Pd64"", isolate_id); 1094 msg.Printf("\"isolateId\": %" Pd64 "", isolate_id);
1095 FormatLocationFromTrace(&msg, trace, ", "); 1095 FormatLocationFromTrace(&msg, trace, ", ");
1096 msg.Printf("}}"); 1096 msg.Printf("}}");
1097 } else { 1097 } else {
1098 msg.Printf("{ \"event\": \"isolate\", \"params\": { "); 1098 msg.Printf("{ \"event\": \"isolate\", \"params\": { ");
1099 if (kind == kCreated) { 1099 if (kind == kCreated) {
1100 msg.Printf("\"reason\": \"created\", "); 1100 msg.Printf("\"reason\": \"created\", ");
1101 } else { 1101 } else {
1102 ASSERT(kind == kShutdown); 1102 ASSERT(kind == kShutdown);
1103 msg.Printf("\"reason\": \"shutdown\", "); 1103 msg.Printf("\"reason\": \"shutdown\", ");
1104 } 1104 }
1105 msg.Printf("\"id\": %"Pd64" ", isolate_id); 1105 msg.Printf("\"id\": %" Pd64 " ", isolate_id);
1106 msg.Printf("}}"); 1106 msg.Printf("}}");
1107 } 1107 }
1108 DebuggerConnectionHandler::BroadcastMsg(&msg); 1108 DebuggerConnectionHandler::BroadcastMsg(&msg);
1109 } 1109 }
1110 1110
1111 1111
1112 DbgMsgQueue* DbgMsgQueueList::list_ = NULL; 1112 DbgMsgQueue* DbgMsgQueueList::list_ = NULL;
1113 dart::Mutex* DbgMsgQueueList::msg_queue_list_lock_ = new dart::Mutex(); 1113 dart::Mutex* DbgMsgQueueList::msg_queue_list_lock_ = new dart::Mutex();
1114 1114
1115 1115
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 UNREACHABLE(); 1220 UNREACHABLE();
1221 } 1221 }
1222 1222
1223 1223
1224 void DbgMsgQueueList::ListIsolateIds(dart::TextBuffer* msg) { 1224 void DbgMsgQueueList::ListIsolateIds(dart::TextBuffer* msg) {
1225 MutexLocker ml(msg_queue_list_lock_); 1225 MutexLocker ml(msg_queue_list_lock_);
1226 if (list_ == NULL) { 1226 if (list_ == NULL) {
1227 return; // No items in the list. 1227 return; // No items in the list.
1228 } 1228 }
1229 DbgMsgQueue* queue = list_; 1229 DbgMsgQueue* queue = list_;
1230 msg->Printf("%"Pd64"", queue->isolate_id()); 1230 msg->Printf("%" Pd64 "", queue->isolate_id());
1231 queue = queue->next(); 1231 queue = queue->next();
1232 while (queue != NULL) { 1232 while (queue != NULL) {
1233 msg->Printf(",%"Pd64"", queue->isolate_id()); 1233 msg->Printf(",%" Pd64 "", queue->isolate_id());
1234 queue = queue->next(); 1234 queue = queue->next();
1235 } 1235 }
1236 } 1236 }
1237 1237
1238 1238
1239 void DbgMsgQueueList::BptResolvedHandler(Dart_IsolateId isolate_id, 1239 void DbgMsgQueueList::BptResolvedHandler(Dart_IsolateId isolate_id,
1240 intptr_t bp_id, 1240 intptr_t bp_id,
1241 const Dart_CodeLocation& location) { 1241 const Dart_CodeLocation& location) {
1242 Dart_EnterScope(); 1242 Dart_EnterScope();
1243 dart::TextBuffer msg(128); 1243 dart::TextBuffer msg(128);
1244 msg.Printf("{ \"event\": \"breakpointResolved\", \"params\": {"); 1244 msg.Printf("{ \"event\": \"breakpointResolved\", \"params\": {");
1245 msg.Printf("\"breakpointId\": %"Pd"", bp_id); 1245 msg.Printf("\"breakpointId\": %" Pd "", bp_id);
1246 1246
1247 msg.Printf(", \"isolateId\":%"Pd64"", isolate_id); 1247 msg.Printf(", \"isolateId\":%" Pd64 "", isolate_id);
1248 ASSERT(!Dart_IsNull(location.script_url)); 1248 ASSERT(!Dart_IsNull(location.script_url));
1249 ASSERT(Dart_IsString(location.script_url)); 1249 ASSERT(Dart_IsString(location.script_url));
1250 msg.Printf(", \"location\":{\"url\":"); 1250 msg.Printf(", \"location\":{\"url\":");
1251 FormatEncodedString(&msg, location.script_url); 1251 FormatEncodedString(&msg, location.script_url);
1252 msg.Printf(",\"libraryId\":%d", location.library_id); 1252 msg.Printf(",\"libraryId\":%d", location.library_id);
1253 msg.Printf(",\"tokenOffset\":%d}}}", location.token_pos); 1253 msg.Printf(",\"tokenOffset\":%d}}}", location.token_pos);
1254 1254
1255 DbgMsgQueue* msg_queue = GetIsolateMsgQueue(isolate_id); 1255 DbgMsgQueue* msg_queue = GetIsolateMsgQueue(isolate_id);
1256 ASSERT(msg_queue != NULL); 1256 ASSERT(msg_queue != NULL);
1257 msg_queue->QueueOutputMsg(&msg); 1257 msg_queue->QueueOutputMsg(&msg);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 } else { 1303 } else {
1304 ASSERT(kind == kShutdown); 1304 ASSERT(kind == kShutdown);
1305 RemoveIsolateMsgQueue(isolate_id); 1305 RemoveIsolateMsgQueue(isolate_id);
1306 } 1306 }
1307 } 1307 }
1308 Dart_ExitScope(); 1308 Dart_ExitScope();
1309 } 1309 }
1310 1310
1311 } // namespace bin 1311 } // namespace bin
1312 } // namespace dart 1312 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698