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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; | 109 static Dart_BreakpointHandler* legacy_bp_handler = NULL; |
110 | 110 |
111 | 111 |
112 static void DebuggerEventHandler(Debugger::DebuggerEvent* event) { | 112 static void DebuggerEventHandler(DebuggerEvent* event) { |
113 Isolate* isolate = Isolate::Current(); | 113 Isolate* isolate = Isolate::Current(); |
114 ASSERT(isolate != NULL); | 114 ASSERT(isolate != NULL); |
115 ASSERT(isolate->debugger() != NULL); | 115 ASSERT(isolate->debugger() != NULL); |
116 Dart_EnterScope(); | 116 Dart_EnterScope(); |
117 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); | 117 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); |
118 if (event->type == Debugger::kBreakpointReached) { | 118 if (event->type() == DebuggerEvent::kBreakpointReached) { |
119 if (legacy_bp_handler != NULL) { | 119 if (legacy_bp_handler != NULL) { |
120 Dart_StackTrace stack_trace = | 120 Dart_StackTrace stack_trace = |
121 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); | 121 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); |
122 (*legacy_bp_handler)(isolate_id, NULL, stack_trace); | 122 (*legacy_bp_handler)(isolate_id, NULL, stack_trace); |
123 } else if (paused_event_handler != NULL) { | 123 } else if (paused_event_handler != NULL) { |
124 Dart_CodeLocation location; | 124 Dart_CodeLocation location; |
125 ActivationFrame* top_frame = event->top_frame; | 125 ActivationFrame* top_frame = event->top_frame(); |
126 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl()); | 126 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl()); |
127 const Library& lib = Library::Handle(top_frame->Library()); | 127 const Library& lib = Library::Handle(top_frame->Library()); |
128 location.library_id = lib.index(); | 128 location.library_id = lib.index(); |
129 location.token_pos = top_frame->TokenPos(); | 129 location.token_pos = top_frame->TokenPos(); |
130 intptr_t bp_id = 0; | 130 intptr_t bp_id = 0; |
131 if (event->breakpoint != NULL) { | 131 if (event->breakpoint() != NULL) { |
132 ASSERT(event->breakpoint->id() != ILLEGAL_BREAKPOINT_ID); | 132 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); |
133 bp_id = event->breakpoint->id(); | 133 bp_id = event->breakpoint()->id(); |
134 } | 134 } |
135 (*paused_event_handler)(isolate_id, bp_id, location); | 135 (*paused_event_handler)(isolate_id, bp_id, location); |
136 } | 136 } |
137 } else if (event->type == Debugger::kBreakpointResolved) { | 137 } else if (event->type() == DebuggerEvent::kBreakpointResolved) { |
138 if (bp_resolved_handler != NULL) { | 138 if (bp_resolved_handler != NULL) { |
139 SourceBreakpoint* bpt = event->breakpoint; | 139 SourceBreakpoint* bpt = event->breakpoint(); |
140 ASSERT(bpt != NULL); | 140 ASSERT(bpt != NULL); |
141 Dart_CodeLocation location; | 141 Dart_CodeLocation location; |
142 Library& library = Library::Handle(isolate); | 142 Library& library = Library::Handle(isolate); |
143 Script& script = Script::Handle(isolate); | 143 Script& script = Script::Handle(isolate); |
144 intptr_t token_pos; | 144 intptr_t token_pos; |
145 bpt->GetCodeLocation(&library, &script, &token_pos); | 145 bpt->GetCodeLocation(&library, &script, &token_pos); |
146 location.script_url = Api::NewHandle(isolate, script.url()); | 146 location.script_url = Api::NewHandle(isolate, script.url()); |
147 location.library_id = library.index(); | 147 location.library_id = library.index(); |
148 location.token_pos = token_pos; | 148 location.token_pos = token_pos; |
149 (*bp_resolved_handler)(isolate_id, bpt->id(), location); | 149 (*bp_resolved_handler)(isolate_id, bpt->id(), location); |
150 } | 150 } |
151 } else if (event->type == Debugger::kExceptionThrown) { | 151 } else if (event->type() == DebuggerEvent::kExceptionThrown) { |
152 if (exc_thrown_handler != NULL) { | 152 if (exc_thrown_handler != NULL) { |
153 Dart_Handle exception = Api::NewHandle(isolate, event->exception->raw()); | 153 Dart_Handle exception = |
| 154 Api::NewHandle(isolate, event->exception()->raw()); |
154 Dart_StackTrace trace = | 155 Dart_StackTrace trace = |
155 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); | 156 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); |
156 (*exc_thrown_handler)(isolate_id, exception, trace); | 157 (*exc_thrown_handler)(isolate_id, exception, trace); |
157 } | 158 } |
158 } else if (event->type == Debugger::kIsolateCreated) { | 159 } else if (event->type() == DebuggerEvent::kIsolateCreated) { |
159 if (isolate_event_handler != NULL) { | 160 if (isolate_event_handler != NULL) { |
160 (*isolate_event_handler)(event->isolate_id, kCreated); | 161 (*isolate_event_handler)(event->isolate_id(), kCreated); |
161 } | 162 } |
162 } else if (event->type == Debugger::kIsolateInterrupted) { | 163 } else if (event->type() == DebuggerEvent::kIsolateInterrupted) { |
163 if (isolate_event_handler != NULL) { | 164 if (isolate_event_handler != NULL) { |
164 (*isolate_event_handler)(event->isolate_id, kInterrupted); | 165 (*isolate_event_handler)(event->isolate_id(), kInterrupted); |
165 } | 166 } |
166 } else if (event->type == Debugger::kIsolateShutdown) { | 167 } else if (event->type() == DebuggerEvent::kIsolateShutdown) { |
167 if (isolate_event_handler != NULL) { | 168 if (isolate_event_handler != NULL) { |
168 (*isolate_event_handler)(event->isolate_id, kShutdown); | 169 (*isolate_event_handler)(event->isolate_id(), kShutdown); |
169 } | 170 } |
170 } else { | 171 } else { |
171 UNIMPLEMENTED(); | 172 UNIMPLEMENTED(); |
172 } | 173 } |
173 Dart_ExitScope(); | 174 Dart_ExitScope(); |
174 } | 175 } |
175 | 176 |
176 | 177 |
177 DART_EXPORT void Dart_SetBreakpointHandler(Dart_BreakpointHandler bp_handler) { | 178 DART_EXPORT void Dart_SetBreakpointHandler(Dart_BreakpointHandler bp_handler) { |
178 legacy_bp_handler = bp_handler; | 179 legacy_bp_handler = bp_handler; |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 return Api::CastIsolate(isolate); | 980 return Api::CastIsolate(isolate); |
980 } | 981 } |
981 | 982 |
982 | 983 |
983 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 984 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
984 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 985 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
985 return isolate->debugger()->GetIsolateId(); | 986 return isolate->debugger()->GetIsolateId(); |
986 } | 987 } |
987 | 988 |
988 } // namespace dart | 989 } // namespace dart |
OLD | NEW |