| 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 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 | 972 |
| 973 | 973 |
| 974 void DbgMsgQueue::SendQueuedMsgs() { | 974 void DbgMsgQueue::SendQueuedMsgs() { |
| 975 if (queued_output_messages_.length() > 0) { | 975 if (queued_output_messages_.length() > 0) { |
| 976 DebuggerConnectionHandler::BroadcastMsg(&queued_output_messages_); | 976 DebuggerConnectionHandler::BroadcastMsg(&queued_output_messages_); |
| 977 queued_output_messages_.Clear(); | 977 queued_output_messages_.Clear(); |
| 978 } | 978 } |
| 979 } | 979 } |
| 980 | 980 |
| 981 | 981 |
| 982 // TODO(hausner): Remove stack trace parameter once we remove the stack | 982 void DbgMsgQueue::SendBreakpointEvent(const Dart_CodeLocation& location) { |
| 983 // trace from the paused event in the wire protocol. | |
| 984 void DbgMsgQueue::SendBreakpointEvent(Dart_StackTrace trace) { | |
| 985 dart::TextBuffer msg(128); | 983 dart::TextBuffer msg(128); |
| 986 msg.Printf("{ \"event\": \"paused\", \"params\": { "); | 984 msg.Printf("{ \"event\": \"paused\", \"params\": { "); |
| 987 msg.Printf("\"reason\": \"breakpoint\", "); | 985 msg.Printf("\"reason\": \"breakpoint\", "); |
| 988 msg.Printf("\"isolateId\": %"Pd64"", isolate_id_); | 986 msg.Printf("\"isolateId\": %"Pd64"", isolate_id_); |
| 989 FormatLocationFromTrace(&msg, trace, ", "); | 987 if (!Dart_IsNull(location.script_url)) { |
| 988 ASSERT(Dart_IsString(location.script_url)); |
| 989 msg.Printf(",\"location\": { \"url\":"); |
| 990 FormatEncodedString(&msg, location.script_url); |
| 991 msg.Printf(",\"libraryId\":%d,", location.library_id); |
| 992 msg.Printf("\"tokenOffset\":%d}", location.token_pos); |
| 993 } |
| 990 msg.Printf("}}"); | 994 msg.Printf("}}"); |
| 991 DebuggerConnectionHandler::BroadcastMsg(&msg); | 995 DebuggerConnectionHandler::BroadcastMsg(&msg); |
| 992 } | 996 } |
| 993 | 997 |
| 994 | 998 |
| 995 // TODO(hausner): Remove stack trace parameter once we remove the stack | 999 // TODO(hausner): Remove stack trace parameter once we remove the stack |
| 996 // trace from the paused event in the wire protocol. | 1000 // trace from the paused event in the wire protocol. |
| 997 void DbgMsgQueue::SendExceptionEvent(Dart_Handle exception, | 1001 void DbgMsgQueue::SendExceptionEvent(Dart_Handle exception, |
| 998 Dart_StackTrace stack_trace) { | 1002 Dart_StackTrace stack_trace) { |
| 999 intptr_t exception_id = Dart_CacheObject(exception); | 1003 intptr_t exception_id = Dart_CacheObject(exception); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 | 1044 |
| 1041 | 1045 |
| 1042 DbgMsgQueue* DbgMsgQueueList::list_ = NULL; | 1046 DbgMsgQueue* DbgMsgQueueList::list_ = NULL; |
| 1043 dart::Mutex DbgMsgQueueList::msg_queue_list_lock_; | 1047 dart::Mutex DbgMsgQueueList::msg_queue_list_lock_; |
| 1044 | 1048 |
| 1045 | 1049 |
| 1046 void DbgMsgQueueList::Initialize() { | 1050 void DbgMsgQueueList::Initialize() { |
| 1047 // Setup handlers for isolate events, breakpoints, exceptions and | 1051 // Setup handlers for isolate events, breakpoints, exceptions and |
| 1048 // delayed breakpoints. | 1052 // delayed breakpoints. |
| 1049 Dart_SetIsolateEventHandler(IsolateEventHandler); | 1053 Dart_SetIsolateEventHandler(IsolateEventHandler); |
| 1050 Dart_SetBreakpointHandler(BreakpointHandler); | 1054 Dart_SetPausedEventHandler(PausedEventHandler); |
| 1051 Dart_SetBreakpointResolvedHandler(BptResolvedHandler); | 1055 Dart_SetBreakpointResolvedHandler(BptResolvedHandler); |
| 1052 Dart_SetExceptionThrownHandler(ExceptionThrownHandler); | 1056 Dart_SetExceptionThrownHandler(ExceptionThrownHandler); |
| 1053 } | 1057 } |
| 1054 | 1058 |
| 1055 | 1059 |
| 1056 int32_t DbgMsgQueueList::LookupIsolateCommand(const char* buf, | 1060 int32_t DbgMsgQueueList::LookupIsolateCommand(const char* buf, |
| 1057 int32_t buflen) { | 1061 int32_t buflen) { |
| 1058 // Check if we have a isolate specific debugger command. | 1062 // Check if we have a isolate specific debugger command. |
| 1059 int32_t i = 0; | 1063 int32_t i = 0; |
| 1060 while (debugger_commands[i].cmd_string != NULL) { | 1064 while (debugger_commands[i].cmd_string != NULL) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 msg.Printf("\"breakpointId\": %"Pd", \"url\":", bp_id); | 1165 msg.Printf("\"breakpointId\": %"Pd", \"url\":", bp_id); |
| 1162 FormatEncodedString(&msg, url); | 1166 FormatEncodedString(&msg, url); |
| 1163 msg.Printf(",\"line\": %"Pd" }}", line_number); | 1167 msg.Printf(",\"line\": %"Pd" }}", line_number); |
| 1164 DbgMsgQueue* msg_queue = GetIsolateMsgQueue(isolate_id); | 1168 DbgMsgQueue* msg_queue = GetIsolateMsgQueue(isolate_id); |
| 1165 ASSERT(msg_queue != NULL); | 1169 ASSERT(msg_queue != NULL); |
| 1166 msg_queue->QueueOutputMsg(&msg); | 1170 msg_queue->QueueOutputMsg(&msg); |
| 1167 Dart_ExitScope(); | 1171 Dart_ExitScope(); |
| 1168 } | 1172 } |
| 1169 | 1173 |
| 1170 | 1174 |
| 1171 void DbgMsgQueueList::BreakpointHandler(Dart_IsolateId isolate_id, | 1175 void DbgMsgQueueList::PausedEventHandler(Dart_IsolateId isolate_id, |
| 1172 Dart_Breakpoint bpt, | 1176 const Dart_CodeLocation& loc) { |
| 1173 Dart_StackTrace trace) { | |
| 1174 DebuggerConnectionHandler::WaitForConnection(); | 1177 DebuggerConnectionHandler::WaitForConnection(); |
| 1175 Dart_EnterScope(); | 1178 Dart_EnterScope(); |
| 1176 DbgMsgQueue* msg_queue = GetIsolateMsgQueue(isolate_id); | 1179 DbgMsgQueue* msg_queue = GetIsolateMsgQueue(isolate_id); |
| 1177 ASSERT(msg_queue != NULL); | 1180 ASSERT(msg_queue != NULL); |
| 1178 msg_queue->SendQueuedMsgs(); | 1181 msg_queue->SendQueuedMsgs(); |
| 1179 msg_queue->SendBreakpointEvent(trace); | 1182 msg_queue->SendBreakpointEvent(loc); |
| 1180 msg_queue->HandleMessages(); | 1183 msg_queue->HandleMessages(); |
| 1181 Dart_ExitScope(); | 1184 Dart_ExitScope(); |
| 1182 } | 1185 } |
| 1183 | 1186 |
| 1184 | 1187 |
| 1185 void DbgMsgQueueList::ExceptionThrownHandler(Dart_IsolateId isolate_id, | 1188 void DbgMsgQueueList::ExceptionThrownHandler(Dart_IsolateId isolate_id, |
| 1186 Dart_Handle exception, | 1189 Dart_Handle exception, |
| 1187 Dart_StackTrace stack_trace) { | 1190 Dart_StackTrace stack_trace) { |
| 1188 DebuggerConnectionHandler::WaitForConnection(); | 1191 DebuggerConnectionHandler::WaitForConnection(); |
| 1189 Dart_EnterScope(); | 1192 Dart_EnterScope(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1210 msg_queue->SendIsolateEvent(isolate_id, kind); | 1213 msg_queue->SendIsolateEvent(isolate_id, kind); |
| 1211 if (kind == kInterrupted) { | 1214 if (kind == kInterrupted) { |
| 1212 msg_queue->HandleMessages(); | 1215 msg_queue->HandleMessages(); |
| 1213 } else { | 1216 } else { |
| 1214 ASSERT(kind == kShutdown); | 1217 ASSERT(kind == kShutdown); |
| 1215 RemoveIsolateMsgQueue(isolate_id); | 1218 RemoveIsolateMsgQueue(isolate_id); |
| 1216 } | 1219 } |
| 1217 } | 1220 } |
| 1218 Dart_ExitScope(); | 1221 Dart_ExitScope(); |
| 1219 } | 1222 } |
| OLD | NEW |