| 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 "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 | 6 |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 *frame = reinterpret_cast<Dart_ActivationFrame>( | 99 *frame = reinterpret_cast<Dart_ActivationFrame>( |
| 100 stack_trace->FrameAt(frame_index)); | 100 stack_trace->FrameAt(frame_index)); |
| 101 return Api::Success(); | 101 return Api::Success(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 static Dart_PausedEventHandler* paused_event_handler = NULL; | 104 static Dart_PausedEventHandler* paused_event_handler = NULL; |
| 105 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; | 105 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; |
| 106 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; | 106 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; |
| 107 static Dart_IsolateEventHandler* isolate_event_handler = NULL; | 107 static Dart_IsolateEventHandler* isolate_event_handler = NULL; |
| 108 | 108 |
| 109 static Dart_BreakpointHandler* legacy_bp_handler = NULL; | |
| 110 | |
| 111 | 109 |
| 112 static void DebuggerEventHandler(DebuggerEvent* event) { | 110 static void DebuggerEventHandler(DebuggerEvent* event) { |
| 113 Isolate* isolate = Isolate::Current(); | 111 Isolate* isolate = Isolate::Current(); |
| 114 ASSERT(isolate != NULL); | 112 ASSERT(isolate != NULL); |
| 115 ASSERT(isolate->debugger() != NULL); | 113 ASSERT(isolate->debugger() != NULL); |
| 116 Dart_EnterScope(); | 114 Dart_EnterScope(); |
| 117 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); | 115 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); |
| 118 if (event->type() == DebuggerEvent::kBreakpointReached) { | 116 if (event->type() == DebuggerEvent::kBreakpointReached) { |
| 119 if (legacy_bp_handler != NULL) { | 117 if (paused_event_handler != NULL) { |
| 120 Dart_StackTrace stack_trace = | |
| 121 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); | |
| 122 (*legacy_bp_handler)(isolate_id, NULL, stack_trace); | |
| 123 } else if (paused_event_handler != NULL) { | |
| 124 Dart_CodeLocation location; | 118 Dart_CodeLocation location; |
| 125 ActivationFrame* top_frame = event->top_frame(); | 119 ActivationFrame* top_frame = event->top_frame(); |
| 126 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl()); | 120 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl()); |
| 127 const Library& lib = Library::Handle(top_frame->Library()); | 121 const Library& lib = Library::Handle(top_frame->Library()); |
| 128 location.library_id = lib.index(); | 122 location.library_id = lib.index(); |
| 129 location.token_pos = top_frame->TokenPos(); | 123 location.token_pos = top_frame->TokenPos(); |
| 130 intptr_t bp_id = 0; | 124 intptr_t bp_id = 0; |
| 131 if (event->breakpoint() != NULL) { | 125 if (event->breakpoint() != NULL) { |
| 132 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); | 126 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); |
| 133 bp_id = event->breakpoint()->id(); | 127 bp_id = event->breakpoint()->id(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (isolate_event_handler != NULL) { | 162 if (isolate_event_handler != NULL) { |
| 169 (*isolate_event_handler)(event->isolate_id(), kShutdown); | 163 (*isolate_event_handler)(event->isolate_id(), kShutdown); |
| 170 } | 164 } |
| 171 } else { | 165 } else { |
| 172 UNIMPLEMENTED(); | 166 UNIMPLEMENTED(); |
| 173 } | 167 } |
| 174 Dart_ExitScope(); | 168 Dart_ExitScope(); |
| 175 } | 169 } |
| 176 | 170 |
| 177 | 171 |
| 178 DART_EXPORT void Dart_SetBreakpointHandler(Dart_BreakpointHandler bp_handler) { | |
| 179 legacy_bp_handler = bp_handler; | |
| 180 Debugger::SetEventHandler(DebuggerEventHandler); | |
| 181 } | |
| 182 | |
| 183 | |
| 184 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) { | 172 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) { |
| 185 paused_event_handler = handler; | 173 paused_event_handler = handler; |
| 186 Debugger::SetEventHandler(DebuggerEventHandler); | 174 Debugger::SetEventHandler(DebuggerEventHandler); |
| 187 } | 175 } |
| 188 | 176 |
| 189 | 177 |
| 190 DART_EXPORT void Dart_SetBreakpointResolvedHandler( | 178 DART_EXPORT void Dart_SetBreakpointResolvedHandler( |
| 191 Dart_BreakpointResolvedHandler handler) { | 179 Dart_BreakpointResolvedHandler handler) { |
| 192 bp_resolved_handler = handler; | 180 bp_resolved_handler = handler; |
| 193 Debugger::SetEventHandler(DebuggerEventHandler); | 181 Debugger::SetEventHandler(DebuggerEventHandler); |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 return Api::CastIsolate(isolate); | 980 return Api::CastIsolate(isolate); |
| 993 } | 981 } |
| 994 | 982 |
| 995 | 983 |
| 996 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 984 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
| 997 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 985 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
| 998 return isolate->debugger()->GetIsolateId(); | 986 return isolate->debugger()->GetIsolateId(); |
| 999 } | 987 } |
| 1000 | 988 |
| 1001 } // namespace dart | 989 } // namespace dart |
| OLD | NEW |