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

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

Issue 14298002: Deprecate old debugger breakpoint handler (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | « runtime/vm/debugger.cc ('k') | runtime/vm/debugger_api_impl_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_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/debugger.h" 9 #include "vm/debugger.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); 92 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace);
93 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) { 93 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) {
94 return Api::NewError("argument 'frame_index' is out of range for %s", 94 return Api::NewError("argument 'frame_index' is out of range for %s",
95 CURRENT_FUNC); 95 CURRENT_FUNC);
96 } 96 }
97 *frame = reinterpret_cast<Dart_ActivationFrame>( 97 *frame = reinterpret_cast<Dart_ActivationFrame>(
98 stack_trace->ActivationFrameAt(frame_index)); 98 stack_trace->ActivationFrameAt(frame_index));
99 return Api::True(isolate); 99 return Api::True(isolate);
100 } 100 }
101 101
102 102 static Dart_PausedEventHandler* paused_event_handler = NULL;
103 DART_EXPORT void Dart_SetBreakpointHandler(Dart_BreakpointHandler bp_handler) {
104 BreakpointHandler* handler =
105 reinterpret_cast<BreakpointHandler*>(bp_handler);
106 Debugger::SetBreakpointHandler(handler);
107 }
108
109
110 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; 103 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL;
111 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; 104 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL;
112 static Dart_IsolateEventHandler* isolate_event_handler = NULL; 105 static Dart_IsolateEventHandler* isolate_event_handler = NULL;
113 106
107 static Dart_BreakpointHandler* legacy_bp_handler = NULL;
108
114 109
115 static void DebuggerEventHandler(Debugger::DebuggerEvent* event) { 110 static void DebuggerEventHandler(Debugger::DebuggerEvent* event) {
116 Isolate* isolate = Isolate::Current(); 111 Isolate* isolate = Isolate::Current();
117 ASSERT(isolate != NULL); 112 ASSERT(isolate != NULL);
118 ASSERT(isolate->debugger() != NULL); 113 ASSERT(isolate->debugger() != NULL);
119 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); 114 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId();
120 if (event->type == Debugger::kBreakpointResolved) { 115 if (event->type == Debugger::kBreakpointReached) {
116 if (legacy_bp_handler != NULL) {
117 Dart_StackTrace stack_trace =
118 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace());
119 (*legacy_bp_handler)(isolate_id, NULL, stack_trace);
120 return;
121 }
122 if (paused_event_handler == NULL) {
123 return;
124 }
125 Dart_CodeLocation location;
126 ActivationFrame* top_frame = event->top_frame;
127 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl());
128 const Library& lib = Library::Handle(top_frame->Library());
129 location.library_id = lib.index();
130 location.token_pos = top_frame->TokenPos();
131 (*paused_event_handler)(isolate_id, location);
132 } else if (event->type == Debugger::kBreakpointResolved) {
121 if (bp_resolved_handler == NULL) { 133 if (bp_resolved_handler == NULL) {
122 return; 134 return;
123 } 135 }
124 SourceBreakpoint* bpt = event->breakpoint; 136 SourceBreakpoint* bpt = event->breakpoint;
125 ASSERT(bpt != NULL); 137 ASSERT(bpt != NULL);
126 Dart_Handle url = Api::NewHandle(isolate, bpt->SourceUrl()); 138 Dart_Handle url = Api::NewHandle(isolate, bpt->SourceUrl());
127 (*bp_resolved_handler)(isolate_id, bpt->id(), url, bpt->LineNumber()); 139 (*bp_resolved_handler)(isolate_id, bpt->id(), url, bpt->LineNumber());
128 } else if (event->type == Debugger::kExceptionThrown) { 140 } else if (event->type == Debugger::kExceptionThrown) {
129 if (exc_thrown_handler == NULL) { 141 if (exc_thrown_handler == NULL) {
130 return; 142 return;
(...skipping 13 matching lines...) Expand all
144 } else if (event->type == Debugger::kIsolateShutdown) { 156 } else if (event->type == Debugger::kIsolateShutdown) {
145 if (isolate_event_handler != NULL) { 157 if (isolate_event_handler != NULL) {
146 (*isolate_event_handler)(event->isolate_id, kShutdown); 158 (*isolate_event_handler)(event->isolate_id, kShutdown);
147 } 159 }
148 } else { 160 } else {
149 UNIMPLEMENTED(); 161 UNIMPLEMENTED();
150 } 162 }
151 } 163 }
152 164
153 165
166 DART_EXPORT void Dart_SetBreakpointHandler(Dart_BreakpointHandler bp_handler) {
167 legacy_bp_handler = bp_handler;
168 Debugger::SetEventHandler(DebuggerEventHandler);
169 }
170
171
172 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) {
173 paused_event_handler = handler;
174 Debugger::SetEventHandler(DebuggerEventHandler);
175 }
176
177
154 DART_EXPORT void Dart_SetBreakpointResolvedHandler( 178 DART_EXPORT void Dart_SetBreakpointResolvedHandler(
155 Dart_BreakpointResolvedHandler handler) { 179 Dart_BreakpointResolvedHandler handler) {
156 bp_resolved_handler = handler; 180 bp_resolved_handler = handler;
157 Debugger::SetEventHandler(DebuggerEventHandler); 181 Debugger::SetEventHandler(DebuggerEventHandler);
158 } 182 }
159 183
160 184
161 DART_EXPORT void Dart_SetExceptionThrownHandler( 185 DART_EXPORT void Dart_SetExceptionThrownHandler(
162 Dart_ExceptionThrownHandler handler) { 186 Dart_ExceptionThrownHandler handler) {
163 exc_thrown_handler = handler; 187 exc_thrown_handler = handler;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 769
746 770
747 DART_EXPORT char* Dart_GetVmStatus(const char* request) { 771 DART_EXPORT char* Dart_GetVmStatus(const char* request) {
748 if (strncmp(request, "/isolate/", 9) == 0) { 772 if (strncmp(request, "/isolate/", 9) == 0) {
749 return Isolate::GetStatus(request); 773 return Isolate::GetStatus(request);
750 } 774 }
751 return NULL; 775 return NULL;
752 } 776 }
753 777
754 } // namespace dart 778 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698