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

Side by Side Diff: runtime/vm/debugger_api_impl.cc

Issue 1978603002: Remove DebuggerEvent. Refactor remaining code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: before landing Created 4 years, 7 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
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/debugger_test.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 "include/dart_tools_api.h" 5 #include "include/dart_tools_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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 stack_trace->FrameAt(frame_index)); 103 stack_trace->FrameAt(frame_index));
104 return Api::Success(); 104 return Api::Success();
105 } 105 }
106 106
107 static Dart_PausedEventHandler* paused_event_handler = NULL; 107 static Dart_PausedEventHandler* paused_event_handler = NULL;
108 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; 108 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL;
109 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; 109 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL;
110 static Dart_IsolateEventHandler* isolate_event_handler = NULL; 110 static Dart_IsolateEventHandler* isolate_event_handler = NULL;
111 111
112 112
113 static void DebuggerEventHandler(DebuggerEvent* event) { 113 static void DebuggerEventHandler(ServiceEvent* event) {
114 Thread* thread = Thread::Current(); 114 Thread* thread = Thread::Current();
115 Isolate* isolate = thread->isolate(); 115 Isolate* isolate = thread->isolate();
116 ASSERT(isolate != NULL); 116 ASSERT(isolate != NULL);
117 Dart_EnterScope(); 117 Dart_EnterScope();
118 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); 118 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId();
119 if (event->type() == DebuggerEvent::kBreakpointReached) { 119 if (event->kind() == ServiceEvent::kPauseBreakpoint) {
120 if (paused_event_handler != NULL) { 120 if (paused_event_handler != NULL) {
121 Dart_CodeLocation location; 121 Dart_CodeLocation location;
122 ActivationFrame* top_frame = event->top_frame(); 122 ActivationFrame* top_frame = event->top_frame();
123 location.script_url = Api::NewHandle(thread, top_frame->SourceUrl()); 123 location.script_url = Api::NewHandle(thread, top_frame->SourceUrl());
124 const Library& lib = Library::Handle(top_frame->Library()); 124 const Library& lib = Library::Handle(top_frame->Library());
125 location.library_id = lib.index(); 125 location.library_id = lib.index();
126 location.token_pos = top_frame->TokenPos().Pos(); 126 location.token_pos = top_frame->TokenPos().Pos();
127 intptr_t bp_id = 0; 127 intptr_t bp_id = 0;
128 if (event->breakpoint() != NULL) { 128 if (event->breakpoint() != NULL) {
129 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); 129 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID);
130 bp_id = event->breakpoint()->id(); 130 bp_id = event->breakpoint()->id();
131 } 131 }
132 (*paused_event_handler)(isolate_id, bp_id, location); 132 (*paused_event_handler)(isolate_id, bp_id, location);
133 } 133 }
134 } else if (event->type() == DebuggerEvent::kBreakpointResolved) { 134 } else if (event->kind() == ServiceEvent::kBreakpointAdded ||
135 if (bp_resolved_handler != NULL) { 135 event->kind() == ServiceEvent::kBreakpointResolved) {
136 Breakpoint* bpt = event->breakpoint(); 136 Breakpoint* bpt = event->breakpoint();
137 ASSERT(bpt != NULL); 137 ASSERT(bpt != NULL);
138 if (bp_resolved_handler != NULL &&
139 bpt->bpt_location()->IsResolved() &&
140 !bpt->IsSingleShot()) {
138 Dart_CodeLocation location; 141 Dart_CodeLocation location;
139 Zone* zone = thread->zone(); 142 Zone* zone = thread->zone();
140 Library& library = Library::Handle(zone); 143 Library& library = Library::Handle(zone);
141 Script& script = Script::Handle(zone); 144 Script& script = Script::Handle(zone);
142 TokenPosition token_pos; 145 TokenPosition token_pos;
143 bpt->bpt_location()->GetCodeLocation(&library, &script, &token_pos); 146 bpt->bpt_location()->GetCodeLocation(&library, &script, &token_pos);
144 location.script_url = Api::NewHandle(thread, script.url()); 147 location.script_url = Api::NewHandle(thread, script.url());
145 location.library_id = library.index(); 148 location.library_id = library.index();
146 location.token_pos = token_pos.Pos(); 149 location.token_pos = token_pos.Pos();
147 (*bp_resolved_handler)(isolate_id, bpt->id(), location); 150 (*bp_resolved_handler)(isolate_id, bpt->id(), location);
148 } 151 }
149 } else if (event->type() == DebuggerEvent::kExceptionThrown) { 152 } else if (event->kind() == ServiceEvent::kBreakpointRemoved) {
153 // Ignore.
154 } else if (event->kind() == ServiceEvent::kPauseException) {
150 if (exc_thrown_handler != NULL) { 155 if (exc_thrown_handler != NULL) {
151 Dart_Handle exception = 156 Dart_Handle exception =
152 Api::NewHandle(thread, event->exception()->raw()); 157 Api::NewHandle(thread, event->exception()->raw());
153 Dart_StackTrace trace = 158 Dart_StackTrace trace =
154 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); 159 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace());
155 (*exc_thrown_handler)(isolate_id, exception, trace); 160 (*exc_thrown_handler)(isolate_id, exception, trace);
156 } 161 }
157 } else if (event->type() == DebuggerEvent::kIsolateCreated) { 162 } else if (event->kind() == ServiceEvent::kIsolateStart) {
158 if (isolate_event_handler != NULL) { 163 if (isolate_event_handler != NULL) {
159 (*isolate_event_handler)(event->isolate_id(), kCreated); 164 (*isolate_event_handler)(event->isolate_id(), kCreated);
160 } 165 }
161 } else if (event->type() == DebuggerEvent::kIsolateInterrupted) { 166 } else if (event->kind() == ServiceEvent::kPauseInterrupted) {
162 if (isolate_event_handler != NULL) { 167 if (isolate_event_handler != NULL) {
163 (*isolate_event_handler)(event->isolate_id(), kInterrupted); 168 (*isolate_event_handler)(event->isolate_id(), kInterrupted);
164 } 169 }
165 } else if (event->type() == DebuggerEvent::kIsolateShutdown) { 170 } else if (event->kind() == ServiceEvent::kIsolateExit) {
166 if (isolate_event_handler != NULL) { 171 if (isolate_event_handler != NULL) {
167 (*isolate_event_handler)(event->isolate_id(), kShutdown); 172 (*isolate_event_handler)(event->isolate_id(), kShutdown);
168 } 173 }
169 } else { 174 } else {
170 UNIMPLEMENTED(); 175 UNIMPLEMENTED();
171 } 176 }
172 Dart_ExitScope(); 177 Dart_ExitScope();
173 } 178 }
174 179
175 180
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 972
968 #else 973 #else
969 974
970 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) { 975 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) {
971 // NOOP. 976 // NOOP.
972 } 977 }
973 978
974 #endif // !PRODUCT 979 #endif // !PRODUCT
975 980
976 } // namespace dart 981 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/debugger_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698