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

Side by Side Diff: vm/debugger_api_impl.cc

Issue 11026011: Add isolate event handler setup in order to be able to propagate isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 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
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
103 DART_EXPORT void Dart_SetBreakpointHandler( 103 DART_EXPORT void Dart_SetBreakpointHandler(
104 Dart_BreakpointHandler bp_handler) { 104 Dart_BreakpointHandler bp_handler) {
105 Isolate* isolate = Isolate::Current();
106 DARTSCOPE(isolate);
107 BreakpointHandler* handler = 105 BreakpointHandler* handler =
108 reinterpret_cast<BreakpointHandler*>(bp_handler); 106 reinterpret_cast<BreakpointHandler*>(bp_handler);
109 107 Debugger::SetBreakpointHandler(handler);
110 isolate->debugger()->SetBreakpointHandler(handler);
111 } 108 }
112 109
113 110
114 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; 111 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL;
115 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; 112 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL;
113 static Dart_IsolateEventHandler* isolate_event_handler = NULL;
114
116 115
117 static void DebuggerEventHandler(Debugger::DebuggerEvent* event) { 116 static void DebuggerEventHandler(Debugger::DebuggerEvent* event) {
118 Isolate* isolate = Isolate::Current(); 117 Isolate* isolate = Isolate::Current();
119 ASSERT(isolate != NULL); 118 ASSERT(isolate != NULL);
120 if (event->type == Debugger::kBreakpointResolved) { 119 if (event->type == Debugger::kBreakpointResolved) {
121 if (bp_resolved_handler == NULL) { 120 if (bp_resolved_handler == NULL) {
122 return; 121 return;
123 } 122 }
124 SourceBreakpoint* bpt = event->breakpoint; 123 SourceBreakpoint* bpt = event->breakpoint;
125 ASSERT(bpt != NULL); 124 ASSERT(bpt != NULL);
126 Dart_Handle url = Api::NewHandle(isolate, bpt->SourceUrl()); 125 Dart_Handle url = Api::NewHandle(isolate, bpt->SourceUrl());
127 (*bp_resolved_handler)(bpt->id(), url, bpt->LineNumber()); 126 (*bp_resolved_handler)(bpt->id(), url, bpt->LineNumber());
128 } else if (event->type == Debugger::kExceptionThrown) { 127 } else if (event->type == Debugger::kExceptionThrown) {
129 if (exc_thrown_handler == NULL) { 128 if (exc_thrown_handler == NULL) {
130 return; 129 return;
131 } 130 }
132 Dart_Handle exception = Api::NewHandle(isolate, event->exception->raw()); 131 Dart_Handle exception = Api::NewHandle(isolate, event->exception->raw());
133 Dart_StackTrace trace = 132 Dart_StackTrace trace =
134 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); 133 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace());
135 (*exc_thrown_handler)(exception, trace); 134 (*exc_thrown_handler)(exception, trace);
135 } else if (event->type == Debugger::kIsolateCreated) {
136 (*isolate_event_handler)(Api::CastIsolate(event->isolate), kCreated);
137 } else if (event->type == Debugger::kIsolateInterrupted) {
138 (*isolate_event_handler)(Api::CastIsolate(event->isolate), kInterrupted);
139 } else if (event->type == Debugger::kIsolateShutdown) {
140 (*isolate_event_handler)(Api::CastIsolate(event->isolate), kShutdown);
136 } else { 141 } else {
137 UNIMPLEMENTED(); 142 UNIMPLEMENTED();
138 } 143 }
139 } 144 }
140 145
141 146
142 DART_EXPORT void Dart_SetBreakpointResolvedHandler( 147 DART_EXPORT void Dart_SetBreakpointResolvedHandler(
143 Dart_BreakpointResolvedHandler handler) { 148 Dart_BreakpointResolvedHandler handler) {
144 bp_resolved_handler = handler; 149 bp_resolved_handler = handler;
145 Isolate* isolate = Isolate::Current(); 150 Debugger::SetEventHandler(DebuggerEventHandler);
146 DARTSCOPE(isolate);
147 isolate->debugger()->SetEventHandler(DebuggerEventHandler);
148 } 151 }
149 152
150 153
151 DART_EXPORT void Dart_SetExceptionThrownHandler( 154 DART_EXPORT void Dart_SetExceptionThrownHandler(
152 Dart_ExceptionThrownHandler handler) { 155 Dart_ExceptionThrownHandler handler) {
153 exc_thrown_handler = handler; 156 exc_thrown_handler = handler;
154 Isolate* isolate = Isolate::Current(); 157 Debugger::SetEventHandler(DebuggerEventHandler);
155 DARTSCOPE(isolate); 158 }
156 isolate->debugger()->SetEventHandler(DebuggerEventHandler); 159
160
161 DART_EXPORT void Dart_SetIsolateEventHandler(Dart_IsolateEventHandler handler) {
162 isolate_event_handler = handler;
163 Debugger::SetEventHandler(DebuggerEventHandler);
157 } 164 }
158 165
159 166
160 DART_EXPORT Dart_Handle Dart_SetExceptionPauseInfo( 167 DART_EXPORT Dart_Handle Dart_SetExceptionPauseInfo(
161 Dart_ExceptionPauseInfo pause_info) { 168 Dart_ExceptionPauseInfo pause_info) {
162 Isolate* isolate = Isolate::Current(); 169 Isolate* isolate = Isolate::Current();
163 DARTSCOPE(isolate); 170 DARTSCOPE(isolate);
164 isolate->debugger()->SetExceptionPauseInfo(pause_info); 171 isolate->debugger()->SetExceptionPauseInfo(pause_info);
165 return Api::True(isolate); 172 return Api::True(isolate);
166 } 173 }
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 if (lib.IsNull()) { 698 if (lib.IsNull()) {
692 return Api::NewError("%s: %"Pd" is not a valid library id", 699 return Api::NewError("%s: %"Pd" is not a valid library id",
693 CURRENT_FUNC, library_id); 700 CURRENT_FUNC, library_id);
694 } 701 }
695 lib.set_debuggable(is_debuggable); 702 lib.set_debuggable(is_debuggable);
696 return Api::True(isolate); 703 return Api::True(isolate);
697 } 704 }
698 705
699 706
700 } // namespace dart 707 } // namespace dart
OLDNEW
« vm/debugger.h ('K') | « vm/debugger.cc ('k') | vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698