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_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 18 matching lines...) Expand all Loading... |
29 CURRENT_FUNC, #param); \ | 29 CURRENT_FUNC, #param); \ |
30 } else if (tmp.IsApiError()) { \ | 30 } else if (tmp.IsApiError()) { \ |
31 return param; \ | 31 return param; \ |
32 } else if (!tmp.Is##type()) { \ | 32 } else if (!tmp.Is##type()) { \ |
33 return Api::NewError("%s expects argument '%s' to be of type %s.", \ | 33 return Api::NewError("%s expects argument '%s' to be of type %s.", \ |
34 CURRENT_FUNC, #param, #type); \ | 34 CURRENT_FUNC, #param, #type); \ |
35 } \ | 35 } \ |
36 var ^= tmp.raw(); \ | 36 var ^= tmp.raw(); \ |
37 } while (0) | 37 } while (0) |
38 | 38 |
39 | |
40 #define CHECK_AND_CAST(type, var, param) \ | 39 #define CHECK_AND_CAST(type, var, param) \ |
41 type* var = NULL; \ | 40 type* var = NULL; \ |
42 do { \ | 41 do { \ |
43 if (param == NULL) { \ | 42 if (param == NULL) { \ |
44 return Api::NewError("%s expects argument '%s' to be non-null.", \ | 43 return Api::NewError("%s expects argument '%s' to be non-null.", \ |
45 CURRENT_FUNC, #param); \ | 44 CURRENT_FUNC, #param); \ |
46 } \ | 45 } \ |
47 var = reinterpret_cast<type*>(param); \ | 46 var = reinterpret_cast<type*>(param); \ |
48 } while (0) | 47 } while (0) |
49 | 48 |
50 | |
51 #define CHECK_NOT_NULL(param) \ | 49 #define CHECK_NOT_NULL(param) \ |
52 if (param == NULL) { \ | 50 if (param == NULL) { \ |
53 return Api::NewError("%s expects argument '%s' to be non-null.", \ | 51 return Api::NewError("%s expects argument '%s' to be non-null.", \ |
54 CURRENT_FUNC, #param); \ | 52 CURRENT_FUNC, #param); \ |
55 } | 53 } |
56 | 54 |
57 #define CHECK_DEBUGGER(isolate) \ | 55 #define CHECK_DEBUGGER(isolate) \ |
58 if (isolate->debugger() == NULL) { \ | 56 if (isolate->debugger() == NULL) { \ |
59 return Api::NewError("%s requires debugger support.", CURRENT_FUNC); \ | 57 return Api::NewError("%s requires debugger support.", CURRENT_FUNC); \ |
60 } | 58 } |
61 | 59 |
62 | |
63 DART_EXPORT intptr_t Dart_CacheObject(Dart_Handle object_in) { | 60 DART_EXPORT intptr_t Dart_CacheObject(Dart_Handle object_in) { |
64 DARTSCOPE(Thread::Current()); | 61 DARTSCOPE(Thread::Current()); |
65 Isolate* I = T->isolate(); | 62 Isolate* I = T->isolate(); |
66 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(object_in)); | 63 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(object_in)); |
67 if (obj.IsApiError() || (I->debugger() == NULL)) { | 64 if (obj.IsApiError() || (I->debugger() == NULL)) { |
68 return -1; | 65 return -1; |
69 } | 66 } |
70 return I->debugger()->CacheObject(obj); | 67 return I->debugger()->CacheObject(obj); |
71 } | 68 } |
72 | 69 |
73 | |
74 DART_EXPORT Dart_Handle Dart_GetCachedObject(intptr_t obj_id) { | 70 DART_EXPORT Dart_Handle Dart_GetCachedObject(intptr_t obj_id) { |
75 DARTSCOPE(Thread::Current()); | 71 DARTSCOPE(Thread::Current()); |
76 Isolate* I = T->isolate(); | 72 Isolate* I = T->isolate(); |
77 CHECK_DEBUGGER(I); | 73 CHECK_DEBUGGER(I); |
78 if (!I->debugger()->IsValidObjectId(obj_id)) { | 74 if (!I->debugger()->IsValidObjectId(obj_id)) { |
79 return Api::NewError("%s: object id %" Pd " is invalid", CURRENT_FUNC, | 75 return Api::NewError("%s: object id %" Pd " is invalid", CURRENT_FUNC, |
80 obj_id); | 76 obj_id); |
81 } | 77 } |
82 return Api::NewHandle(T, I->debugger()->GetCachedObject(obj_id)); | 78 return Api::NewHandle(T, I->debugger()->GetCachedObject(obj_id)); |
83 } | 79 } |
84 | 80 |
85 | |
86 DART_EXPORT Dart_Handle Dart_StackTraceLength(Dart_StackTrace trace, | 81 DART_EXPORT Dart_Handle Dart_StackTraceLength(Dart_StackTrace trace, |
87 intptr_t* length) { | 82 intptr_t* length) { |
88 DARTSCOPE(Thread::Current()); | 83 DARTSCOPE(Thread::Current()); |
89 CHECK_NOT_NULL(length); | 84 CHECK_NOT_NULL(length); |
90 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); | 85 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); |
91 *length = stack_trace->Length(); | 86 *length = stack_trace->Length(); |
92 return Api::Success(); | 87 return Api::Success(); |
93 } | 88 } |
94 | 89 |
95 | |
96 DART_EXPORT Dart_Handle Dart_GetActivationFrame(Dart_StackTrace trace, | 90 DART_EXPORT Dart_Handle Dart_GetActivationFrame(Dart_StackTrace trace, |
97 int frame_index, | 91 int frame_index, |
98 Dart_ActivationFrame* frame) { | 92 Dart_ActivationFrame* frame) { |
99 DARTSCOPE(Thread::Current()); | 93 DARTSCOPE(Thread::Current()); |
100 CHECK_NOT_NULL(frame); | 94 CHECK_NOT_NULL(frame); |
101 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); | 95 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); |
102 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) { | 96 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) { |
103 return Api::NewError("argument 'frame_index' is out of range for %s", | 97 return Api::NewError("argument 'frame_index' is out of range for %s", |
104 CURRENT_FUNC); | 98 CURRENT_FUNC); |
105 } | 99 } |
106 *frame = | 100 *frame = |
107 reinterpret_cast<Dart_ActivationFrame>(stack_trace->FrameAt(frame_index)); | 101 reinterpret_cast<Dart_ActivationFrame>(stack_trace->FrameAt(frame_index)); |
108 return Api::Success(); | 102 return Api::Success(); |
109 } | 103 } |
110 | 104 |
111 static Dart_PausedEventHandler* paused_event_handler = NULL; | 105 static Dart_PausedEventHandler* paused_event_handler = NULL; |
112 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; | 106 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; |
113 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; | 107 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; |
114 static Dart_IsolateEventHandler* isolate_event_handler = NULL; | 108 static Dart_IsolateEventHandler* isolate_event_handler = NULL; |
115 | 109 |
116 | |
117 static void DebuggerEventHandler(ServiceEvent* event) { | 110 static void DebuggerEventHandler(ServiceEvent* event) { |
118 Thread* thread = Thread::Current(); | 111 Thread* thread = Thread::Current(); |
119 Isolate* isolate = thread->isolate(); | 112 Isolate* isolate = thread->isolate(); |
120 ASSERT(isolate != NULL); | 113 ASSERT(isolate != NULL); |
121 Dart_EnterScope(); | 114 Dart_EnterScope(); |
122 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); | 115 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); |
123 if (event->kind() == ServiceEvent::kPauseBreakpoint) { | 116 if (event->kind() == ServiceEvent::kPauseBreakpoint) { |
124 if (paused_event_handler != NULL) { | 117 if (paused_event_handler != NULL) { |
125 Dart_CodeLocation location; | 118 Dart_CodeLocation location; |
126 ActivationFrame* top_frame = event->top_frame(); | 119 ActivationFrame* top_frame = event->top_frame(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 (*isolate_event_handler)(event->isolate_id(), kShutdown); | 167 (*isolate_event_handler)(event->isolate_id(), kShutdown); |
175 } | 168 } |
176 } else if (event->kind() == ServiceEvent::kPausePostRequest) { | 169 } else if (event->kind() == ServiceEvent::kPausePostRequest) { |
177 // Ignore. | 170 // Ignore. |
178 } else { | 171 } else { |
179 UNIMPLEMENTED(); | 172 UNIMPLEMENTED(); |
180 } | 173 } |
181 Dart_ExitScope(); | 174 Dart_ExitScope(); |
182 } | 175 } |
183 | 176 |
184 | |
185 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) { | 177 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) { |
186 paused_event_handler = handler; | 178 paused_event_handler = handler; |
187 Debugger::SetEventHandler(DebuggerEventHandler); | 179 Debugger::SetEventHandler(DebuggerEventHandler); |
188 } | 180 } |
189 | 181 |
190 | |
191 DART_EXPORT void Dart_SetBreakpointResolvedHandler( | 182 DART_EXPORT void Dart_SetBreakpointResolvedHandler( |
192 Dart_BreakpointResolvedHandler handler) { | 183 Dart_BreakpointResolvedHandler handler) { |
193 bp_resolved_handler = handler; | 184 bp_resolved_handler = handler; |
194 Debugger::SetEventHandler(DebuggerEventHandler); | 185 Debugger::SetEventHandler(DebuggerEventHandler); |
195 } | 186 } |
196 | 187 |
197 | |
198 DART_EXPORT void Dart_SetExceptionThrownHandler( | 188 DART_EXPORT void Dart_SetExceptionThrownHandler( |
199 Dart_ExceptionThrownHandler handler) { | 189 Dart_ExceptionThrownHandler handler) { |
200 exc_thrown_handler = handler; | 190 exc_thrown_handler = handler; |
201 Debugger::SetEventHandler(DebuggerEventHandler); | 191 Debugger::SetEventHandler(DebuggerEventHandler); |
202 } | 192 } |
203 | 193 |
204 | |
205 DART_EXPORT void Dart_SetIsolateEventHandler(Dart_IsolateEventHandler handler) { | 194 DART_EXPORT void Dart_SetIsolateEventHandler(Dart_IsolateEventHandler handler) { |
206 isolate_event_handler = handler; | 195 isolate_event_handler = handler; |
207 Debugger::SetEventHandler(DebuggerEventHandler); | 196 Debugger::SetEventHandler(DebuggerEventHandler); |
208 } | 197 } |
209 | 198 |
210 | |
211 DART_EXPORT Dart_Handle | 199 DART_EXPORT Dart_Handle |
212 Dart_SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { | 200 Dart_SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { |
213 DARTSCOPE(Thread::Current()); | 201 DARTSCOPE(Thread::Current()); |
214 Isolate* I = T->isolate(); | 202 Isolate* I = T->isolate(); |
215 CHECK_DEBUGGER(I); | 203 CHECK_DEBUGGER(I); |
216 I->debugger()->SetExceptionPauseInfo(pause_info); | 204 I->debugger()->SetExceptionPauseInfo(pause_info); |
217 return Api::Success(); | 205 return Api::Success(); |
218 } | 206 } |
219 | 207 |
220 | |
221 DART_EXPORT Dart_ExceptionPauseInfo Dart_GetExceptionPauseInfo() { | 208 DART_EXPORT Dart_ExceptionPauseInfo Dart_GetExceptionPauseInfo() { |
222 DARTSCOPE(Thread::Current()); | 209 DARTSCOPE(Thread::Current()); |
223 Isolate* I = T->isolate(); | 210 Isolate* I = T->isolate(); |
224 if (I->debugger() == NULL) { | 211 if (I->debugger() == NULL) { |
225 return kNoPauseOnExceptions; | 212 return kNoPauseOnExceptions; |
226 } | 213 } |
227 return I->debugger()->GetExceptionPauseInfo(); | 214 return I->debugger()->GetExceptionPauseInfo(); |
228 } | 215 } |
229 | 216 |
230 | |
231 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace) { | 217 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace) { |
232 DARTSCOPE(Thread::Current()); | 218 DARTSCOPE(Thread::Current()); |
233 Isolate* I = T->isolate(); | 219 Isolate* I = T->isolate(); |
234 CHECK_DEBUGGER(I); | 220 CHECK_DEBUGGER(I); |
235 CHECK_NOT_NULL(trace); | 221 CHECK_NOT_NULL(trace); |
236 *trace = | 222 *trace = |
237 reinterpret_cast<Dart_StackTrace>(I->debugger()->CurrentStackTrace()); | 223 reinterpret_cast<Dart_StackTrace>(I->debugger()->CurrentStackTrace()); |
238 return Api::Success(); | 224 return Api::Success(); |
239 } | 225 } |
240 | 226 |
241 | |
242 DART_EXPORT Dart_Handle Dart_GetStackTraceFromError(Dart_Handle handle, | 227 DART_EXPORT Dart_Handle Dart_GetStackTraceFromError(Dart_Handle handle, |
243 Dart_StackTrace* trace) { | 228 Dart_StackTrace* trace) { |
244 DARTSCOPE(Thread::Current()); | 229 DARTSCOPE(Thread::Current()); |
245 CHECK_DEBUGGER(T->isolate()); | 230 CHECK_DEBUGGER(T->isolate()); |
246 CHECK_NOT_NULL(trace); | 231 CHECK_NOT_NULL(trace); |
247 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle)); | 232 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle)); |
248 if (obj.IsUnhandledException()) { | 233 if (obj.IsUnhandledException()) { |
249 const UnhandledException& error = UnhandledException::Cast(obj); | 234 const UnhandledException& error = UnhandledException::Cast(obj); |
250 StackTrace& dart_stacktrace = StackTrace::Handle(Z); | 235 StackTrace& dart_stacktrace = StackTrace::Handle(Z); |
251 dart_stacktrace ^= error.stacktrace(); | 236 dart_stacktrace ^= error.stacktrace(); |
252 if (dart_stacktrace.IsNull()) { | 237 if (dart_stacktrace.IsNull()) { |
253 *trace = NULL; | 238 *trace = NULL; |
254 } else { | 239 } else { |
255 Isolate* I = T->isolate(); | 240 Isolate* I = T->isolate(); |
256 *trace = reinterpret_cast<Dart_StackTrace>( | 241 *trace = reinterpret_cast<Dart_StackTrace>( |
257 I->debugger()->StackTraceFrom(dart_stacktrace)); | 242 I->debugger()->StackTraceFrom(dart_stacktrace)); |
258 } | 243 } |
259 return Api::Success(); | 244 return Api::Success(); |
260 } else { | 245 } else { |
261 return Api::NewError( | 246 return Api::NewError( |
262 "Can only get stacktraces from error handles or " | 247 "Can only get stacktraces from error handles or " |
263 "instances of Error."); | 248 "instances of Error."); |
264 } | 249 } |
265 } | 250 } |
266 | 251 |
267 | |
268 DART_EXPORT Dart_Handle | 252 DART_EXPORT Dart_Handle |
269 Dart_ActivationFrameInfo(Dart_ActivationFrame activation_frame, | 253 Dart_ActivationFrameInfo(Dart_ActivationFrame activation_frame, |
270 Dart_Handle* function_name, | 254 Dart_Handle* function_name, |
271 Dart_Handle* script_url, | 255 Dart_Handle* script_url, |
272 intptr_t* line_number, | 256 intptr_t* line_number, |
273 intptr_t* column_number) { | 257 intptr_t* column_number) { |
274 DARTSCOPE(Thread::Current()); | 258 DARTSCOPE(Thread::Current()); |
275 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 259 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
276 if (function_name != NULL) { | 260 if (function_name != NULL) { |
277 *function_name = Api::NewHandle(T, frame->QualifiedFunctionName()); | 261 *function_name = Api::NewHandle(T, frame->QualifiedFunctionName()); |
278 } | 262 } |
279 if (script_url != NULL) { | 263 if (script_url != NULL) { |
280 *script_url = Api::NewHandle(T, frame->SourceUrl()); | 264 *script_url = Api::NewHandle(T, frame->SourceUrl()); |
281 } | 265 } |
282 if (line_number != NULL) { | 266 if (line_number != NULL) { |
283 *line_number = frame->LineNumber(); | 267 *line_number = frame->LineNumber(); |
284 } | 268 } |
285 if (column_number != NULL) { | 269 if (column_number != NULL) { |
286 *column_number = frame->ColumnNumber(); | 270 *column_number = frame->ColumnNumber(); |
287 } | 271 } |
288 return Api::Success(); | 272 return Api::Success(); |
289 } | 273 } |
290 | 274 |
291 | |
292 DART_EXPORT Dart_Handle | 275 DART_EXPORT Dart_Handle |
293 Dart_ActivationFrameGetLocation(Dart_ActivationFrame activation_frame, | 276 Dart_ActivationFrameGetLocation(Dart_ActivationFrame activation_frame, |
294 Dart_Handle* function_name, | 277 Dart_Handle* function_name, |
295 Dart_Handle* function, | 278 Dart_Handle* function, |
296 Dart_CodeLocation* location) { | 279 Dart_CodeLocation* location) { |
297 // TODO(hausner): Implement a way to recognize when there | 280 // TODO(hausner): Implement a way to recognize when there |
298 // is no source code for the code in the frame. | 281 // is no source code for the code in the frame. |
299 DARTSCOPE(Thread::Current()); | 282 DARTSCOPE(Thread::Current()); |
300 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 283 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
301 if (function_name != NULL) { | 284 if (function_name != NULL) { |
(...skipping 17 matching lines...) Expand all Loading... |
319 uintptr_t* frame_pointer) { | 302 uintptr_t* frame_pointer) { |
320 DARTSCOPE(Thread::Current()); | 303 DARTSCOPE(Thread::Current()); |
321 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 304 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
322 | 305 |
323 if (frame_pointer != NULL) { | 306 if (frame_pointer != NULL) { |
324 *frame_pointer = static_cast<uintptr_t>(frame->fp()); | 307 *frame_pointer = static_cast<uintptr_t>(frame->fp()); |
325 } | 308 } |
326 return Api::Success(); | 309 return Api::Success(); |
327 } | 310 } |
328 | 311 |
329 | |
330 DART_EXPORT Dart_Handle Dart_GetFunctionOrigin(Dart_Handle function_in) { | 312 DART_EXPORT Dart_Handle Dart_GetFunctionOrigin(Dart_Handle function_in) { |
331 DARTSCOPE(Thread::Current()); | 313 DARTSCOPE(Thread::Current()); |
332 UNWRAP_AND_CHECK_PARAM(Function, function, function_in); | 314 UNWRAP_AND_CHECK_PARAM(Function, function, function_in); |
333 | 315 |
334 const Class& cls = Class::Handle(Z, function.origin()); | 316 const Class& cls = Class::Handle(Z, function.origin()); |
335 if (!cls.IsTopLevel()) { | 317 if (!cls.IsTopLevel()) { |
336 return Dart_NewInteger(cls.id()); | 318 return Dart_NewInteger(cls.id()); |
337 } | 319 } |
338 return Api::Null(); | 320 return Api::Null(); |
339 } | 321 } |
340 | 322 |
341 | |
342 DART_EXPORT Dart_Handle | 323 DART_EXPORT Dart_Handle |
343 Dart_GetLocalVariables(Dart_ActivationFrame activation_frame) { | 324 Dart_GetLocalVariables(Dart_ActivationFrame activation_frame) { |
344 DARTSCOPE(Thread::Current()); | 325 DARTSCOPE(Thread::Current()); |
345 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 326 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
346 return Api::NewHandle(T, frame->GetLocalVariables()); | 327 return Api::NewHandle(T, frame->GetLocalVariables()); |
347 } | 328 } |
348 | 329 |
349 | |
350 DART_EXPORT Dart_Handle Dart_SetBreakpoint(Dart_Handle script_url_in, | 330 DART_EXPORT Dart_Handle Dart_SetBreakpoint(Dart_Handle script_url_in, |
351 intptr_t line_number) { | 331 intptr_t line_number) { |
352 DARTSCOPE(Thread::Current()); | 332 DARTSCOPE(Thread::Current()); |
353 Isolate* I = T->isolate(); | 333 Isolate* I = T->isolate(); |
354 CHECK_DEBUGGER(I); | 334 CHECK_DEBUGGER(I); |
355 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 335 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
356 | 336 |
357 Debugger* debugger = I->debugger(); | 337 Debugger* debugger = I->debugger(); |
358 Breakpoint* bpt = debugger->SetBreakpointAtLine(script_url, line_number); | 338 Breakpoint* bpt = debugger->SetBreakpointAtLine(script_url, line_number); |
359 if (bpt == NULL) { | 339 if (bpt == NULL) { |
360 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", | 340 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", |
361 CURRENT_FUNC, line_number, script_url.ToCString()); | 341 CURRENT_FUNC, line_number, script_url.ToCString()); |
362 } | 342 } |
363 return Dart_NewInteger(bpt->id()); | 343 return Dart_NewInteger(bpt->id()); |
364 } | 344 } |
365 | 345 |
366 | |
367 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { | 346 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { |
368 DARTSCOPE(Thread::Current()); | 347 DARTSCOPE(Thread::Current()); |
369 Isolate* I = T->isolate(); | 348 Isolate* I = T->isolate(); |
370 CHECK_DEBUGGER(I); | 349 CHECK_DEBUGGER(I); |
371 Debugger* debugger = I->debugger(); | 350 Debugger* debugger = I->debugger(); |
372 | 351 |
373 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); | 352 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); |
374 if (bpt == NULL) { | 353 if (bpt == NULL) { |
375 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", | 354 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", |
376 CURRENT_FUNC, bp_id); | 355 CURRENT_FUNC, bp_id); |
377 } | 356 } |
378 return Api::NewHandle(T, bpt->bpt_location()->url()); | 357 return Api::NewHandle(T, bpt->bpt_location()->url()); |
379 } | 358 } |
380 | 359 |
381 | |
382 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id) { | 360 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id) { |
383 DARTSCOPE(Thread::Current()); | 361 DARTSCOPE(Thread::Current()); |
384 Isolate* I = T->isolate(); | 362 Isolate* I = T->isolate(); |
385 CHECK_DEBUGGER(I); | 363 CHECK_DEBUGGER(I); |
386 Debugger* debugger = I->debugger(); | 364 Debugger* debugger = I->debugger(); |
387 | 365 |
388 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); | 366 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); |
389 if (bpt == NULL) { | 367 if (bpt == NULL) { |
390 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", | 368 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", |
391 CURRENT_FUNC, bp_id); | 369 CURRENT_FUNC, bp_id); |
392 } | 370 } |
393 if (bpt->bpt_location()->IsResolved()) { | 371 if (bpt->bpt_location()->IsResolved()) { |
394 return Dart_NewInteger(bpt->bpt_location()->LineNumber()); | 372 return Dart_NewInteger(bpt->bpt_location()->LineNumber()); |
395 } else { | 373 } else { |
396 return Dart_NewInteger(bpt->bpt_location()->requested_line_number()); | 374 return Dart_NewInteger(bpt->bpt_location()->requested_line_number()); |
397 } | 375 } |
398 } | 376 } |
399 | 377 |
400 | |
401 DART_EXPORT Dart_Handle | 378 DART_EXPORT Dart_Handle |
402 Dart_SetBreakpointAtEntry(Dart_Handle library_in, | 379 Dart_SetBreakpointAtEntry(Dart_Handle library_in, |
403 Dart_Handle class_name_in, | 380 Dart_Handle class_name_in, |
404 Dart_Handle function_name_in) { | 381 Dart_Handle function_name_in) { |
405 DARTSCOPE(Thread::Current()); | 382 DARTSCOPE(Thread::Current()); |
406 Isolate* I = T->isolate(); | 383 Isolate* I = T->isolate(); |
407 CHECK_DEBUGGER(I); | 384 CHECK_DEBUGGER(I); |
408 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); | 385 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); |
409 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); | 386 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); |
410 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); | 387 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); |
(...skipping 17 matching lines...) Expand all Loading... |
428 | 405 |
429 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target, false); | 406 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target, false); |
430 if (bpt == NULL) { | 407 if (bpt == NULL) { |
431 const char* target_name = Debugger::QualifiedFunctionName(bp_target); | 408 const char* target_name = Debugger::QualifiedFunctionName(bp_target); |
432 return Api::NewError("%s: no breakpoint location found in '%s'", | 409 return Api::NewError("%s: no breakpoint location found in '%s'", |
433 CURRENT_FUNC, target_name); | 410 CURRENT_FUNC, target_name); |
434 } | 411 } |
435 return Dart_NewInteger(bpt->id()); | 412 return Dart_NewInteger(bpt->id()); |
436 } | 413 } |
437 | 414 |
438 | |
439 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry(Dart_Handle library_in, | 415 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry(Dart_Handle library_in, |
440 Dart_Handle class_name_in, | 416 Dart_Handle class_name_in, |
441 Dart_Handle function_name_in) { | 417 Dart_Handle function_name_in) { |
442 DARTSCOPE(Thread::Current()); | 418 DARTSCOPE(Thread::Current()); |
443 Isolate* I = T->isolate(); | 419 Isolate* I = T->isolate(); |
444 CHECK_DEBUGGER(I); | 420 CHECK_DEBUGGER(I); |
445 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); | 421 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); |
446 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); | 422 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); |
447 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); | 423 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); |
448 | 424 |
(...skipping 15 matching lines...) Expand all Loading... |
464 } | 440 } |
465 | 441 |
466 const Error& error = | 442 const Error& error = |
467 Error::Handle(Z, debugger->OneTimeBreakAtEntry(bp_target)); | 443 Error::Handle(Z, debugger->OneTimeBreakAtEntry(bp_target)); |
468 if (!error.IsNull()) { | 444 if (!error.IsNull()) { |
469 return Api::NewHandle(T, error.raw()); | 445 return Api::NewHandle(T, error.raw()); |
470 } | 446 } |
471 return Api::Success(); | 447 return Api::Success(); |
472 } | 448 } |
473 | 449 |
474 | |
475 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { | 450 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { |
476 DARTSCOPE(Thread::Current()); | 451 DARTSCOPE(Thread::Current()); |
477 Isolate* I = T->isolate(); | 452 Isolate* I = T->isolate(); |
478 CHECK_DEBUGGER(I); | 453 CHECK_DEBUGGER(I); |
479 I->debugger()->RemoveBreakpoint(bp_id); | 454 I->debugger()->RemoveBreakpoint(bp_id); |
480 return Api::Success(); | 455 return Api::Success(); |
481 } | 456 } |
482 | 457 |
483 | |
484 DART_EXPORT Dart_Handle Dart_SetStepOver() { | 458 DART_EXPORT Dart_Handle Dart_SetStepOver() { |
485 DARTSCOPE(Thread::Current()); | 459 DARTSCOPE(Thread::Current()); |
486 Isolate* I = T->isolate(); | 460 Isolate* I = T->isolate(); |
487 CHECK_DEBUGGER(I); | 461 CHECK_DEBUGGER(I); |
488 I->debugger()->SetResumeAction(Debugger::kStepOver); | 462 I->debugger()->SetResumeAction(Debugger::kStepOver); |
489 return Api::Success(); | 463 return Api::Success(); |
490 } | 464 } |
491 | 465 |
492 | |
493 DART_EXPORT Dart_Handle Dart_SetStepInto() { | 466 DART_EXPORT Dart_Handle Dart_SetStepInto() { |
494 DARTSCOPE(Thread::Current()); | 467 DARTSCOPE(Thread::Current()); |
495 Isolate* I = T->isolate(); | 468 Isolate* I = T->isolate(); |
496 CHECK_DEBUGGER(I); | 469 CHECK_DEBUGGER(I); |
497 I->debugger()->SetResumeAction(Debugger::kStepInto); | 470 I->debugger()->SetResumeAction(Debugger::kStepInto); |
498 return Api::Success(); | 471 return Api::Success(); |
499 } | 472 } |
500 | 473 |
501 | |
502 DART_EXPORT Dart_Handle Dart_SetStepOut() { | 474 DART_EXPORT Dart_Handle Dart_SetStepOut() { |
503 DARTSCOPE(Thread::Current()); | 475 DARTSCOPE(Thread::Current()); |
504 Isolate* I = T->isolate(); | 476 Isolate* I = T->isolate(); |
505 CHECK_DEBUGGER(I); | 477 CHECK_DEBUGGER(I); |
506 I->debugger()->SetResumeAction(Debugger::kStepOut); | 478 I->debugger()->SetResumeAction(Debugger::kStepOut); |
507 return Api::Success(); | 479 return Api::Success(); |
508 } | 480 } |
509 | 481 |
510 | |
511 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { | 482 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { |
512 DARTSCOPE(Thread::Current()); | 483 DARTSCOPE(Thread::Current()); |
513 Isolate* I = T->isolate(); | 484 Isolate* I = T->isolate(); |
514 CHECK_DEBUGGER(I); | 485 CHECK_DEBUGGER(I); |
515 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 486 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
516 return Api::NewHandle(T, I->debugger()->GetInstanceFields(obj)); | 487 return Api::NewHandle(T, I->debugger()->GetInstanceFields(obj)); |
517 } | 488 } |
518 | 489 |
519 | |
520 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle target) { | 490 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle target) { |
521 DARTSCOPE(Thread::Current()); | 491 DARTSCOPE(Thread::Current()); |
522 Isolate* I = T->isolate(); | 492 Isolate* I = T->isolate(); |
523 CHECK_DEBUGGER(I); | 493 CHECK_DEBUGGER(I); |
524 const Type& type_obj = Api::UnwrapTypeHandle(Z, target); | 494 const Type& type_obj = Api::UnwrapTypeHandle(Z, target); |
525 if (type_obj.IsNull()) { | 495 if (type_obj.IsNull()) { |
526 return Api::NewError("%s expects argument 'target' to be a type", | 496 return Api::NewError("%s expects argument 'target' to be a type", |
527 CURRENT_FUNC); | 497 CURRENT_FUNC); |
528 } | 498 } |
529 const Class& cls = Class::Handle(Z, type_obj.type_class()); | 499 const Class& cls = Class::Handle(Z, type_obj.type_class()); |
530 return Api::NewHandle(T, I->debugger()->GetStaticFields(cls)); | 500 return Api::NewHandle(T, I->debugger()->GetStaticFields(cls)); |
531 } | 501 } |
532 | 502 |
533 | |
534 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) { | 503 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) { |
535 DARTSCOPE(Thread::Current()); | 504 DARTSCOPE(Thread::Current()); |
536 Isolate* I = T->isolate(); | 505 Isolate* I = T->isolate(); |
537 CHECK_DEBUGGER(I); | 506 CHECK_DEBUGGER(I); |
538 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); | 507 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
539 if (lib.IsNull()) { | 508 if (lib.IsNull()) { |
540 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 509 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
541 library_id); | 510 library_id); |
542 } | 511 } |
543 return Api::NewHandle(T, I->debugger()->GetLibraryFields(lib)); | 512 return Api::NewHandle(T, I->debugger()->GetLibraryFields(lib)); |
544 } | 513 } |
545 | 514 |
546 | |
547 DART_EXPORT Dart_Handle Dart_GetGlobalVariables(intptr_t library_id) { | 515 DART_EXPORT Dart_Handle Dart_GetGlobalVariables(intptr_t library_id) { |
548 DARTSCOPE(Thread::Current()); | 516 DARTSCOPE(Thread::Current()); |
549 Isolate* I = T->isolate(); | 517 Isolate* I = T->isolate(); |
550 CHECK_DEBUGGER(I); | 518 CHECK_DEBUGGER(I); |
551 | 519 |
552 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); | 520 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
553 if (lib.IsNull()) { | 521 if (lib.IsNull()) { |
554 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 522 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
555 library_id); | 523 library_id); |
556 } | 524 } |
557 return Api::NewHandle(T, I->debugger()->GetGlobalFields(lib)); | 525 return Api::NewHandle(T, I->debugger()->GetGlobalFields(lib)); |
558 } | 526 } |
559 | 527 |
560 | |
561 DART_EXPORT Dart_Handle | 528 DART_EXPORT Dart_Handle |
562 Dart_ActivationFrameEvaluate(Dart_ActivationFrame activation_frame, | 529 Dart_ActivationFrameEvaluate(Dart_ActivationFrame activation_frame, |
563 Dart_Handle expr_in) { | 530 Dart_Handle expr_in) { |
564 DARTSCOPE(Thread::Current()); | 531 DARTSCOPE(Thread::Current()); |
565 CHECK_DEBUGGER(T->isolate()); | 532 CHECK_DEBUGGER(T->isolate()); |
566 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 533 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
567 UNWRAP_AND_CHECK_PARAM(String, expr, expr_in); | 534 UNWRAP_AND_CHECK_PARAM(String, expr, expr_in); |
568 const GrowableObjectArray& names = | 535 const GrowableObjectArray& names = |
569 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 536 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
570 const GrowableObjectArray& values = | 537 const GrowableObjectArray& values = |
571 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 538 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
572 return Api::NewHandle(T, frame->Evaluate(expr, names, values)); | 539 return Api::NewHandle(T, frame->Evaluate(expr, names, values)); |
573 } | 540 } |
574 | 541 |
575 | |
576 DART_EXPORT Dart_Handle Dart_EvaluateExpr(Dart_Handle target_in, | 542 DART_EXPORT Dart_Handle Dart_EvaluateExpr(Dart_Handle target_in, |
577 Dart_Handle expr_in) { | 543 Dart_Handle expr_in) { |
578 DARTSCOPE(Thread::Current()); | 544 DARTSCOPE(Thread::Current()); |
579 CHECK_DEBUGGER(T->isolate()); | 545 CHECK_DEBUGGER(T->isolate()); |
580 | 546 |
581 const Object& target = Object::Handle(Z, Api::UnwrapHandle(target_in)); | 547 const Object& target = Object::Handle(Z, Api::UnwrapHandle(target_in)); |
582 if (target.IsError()) return target_in; | 548 if (target.IsError()) return target_in; |
583 if (target.IsNull()) { | 549 if (target.IsNull()) { |
584 return Api::NewError("%s expects argument 'target' to be non-null", | 550 return Api::NewError("%s expects argument 'target' to be non-null", |
585 CURRENT_FUNC); | 551 CURRENT_FUNC); |
(...skipping 15 matching lines...) Expand all Loading... |
601 return Api::NewHandle( | 567 return Api::NewHandle( |
602 T, lib.Evaluate(expr, Array::empty_array(), Array::empty_array())); | 568 T, lib.Evaluate(expr, Array::empty_array(), Array::empty_array())); |
603 } else if (target.IsClass()) { | 569 } else if (target.IsClass()) { |
604 const Class& cls = Class::Cast(target); | 570 const Class& cls = Class::Cast(target); |
605 return Api::NewHandle( | 571 return Api::NewHandle( |
606 T, cls.Evaluate(expr, Array::empty_array(), Array::empty_array())); | 572 T, cls.Evaluate(expr, Array::empty_array(), Array::empty_array())); |
607 } | 573 } |
608 return Api::NewError("%s: unsupported target type", CURRENT_FUNC); | 574 return Api::NewError("%s: unsupported target type", CURRENT_FUNC); |
609 } | 575 } |
610 | 576 |
611 | |
612 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { | 577 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { |
613 DARTSCOPE(Thread::Current()); | 578 DARTSCOPE(Thread::Current()); |
614 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 579 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
615 return Api::NewHandle(T, obj.GetType(Heap::kNew)); | 580 return Api::NewHandle(T, obj.GetType(Heap::kNew)); |
616 } | 581 } |
617 | 582 |
618 | |
619 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, | 583 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, |
620 intptr_t* class_id) { | 584 intptr_t* class_id) { |
621 DARTSCOPE(Thread::Current()); | 585 DARTSCOPE(Thread::Current()); |
622 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 586 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
623 CHECK_NOT_NULL(class_id); | 587 CHECK_NOT_NULL(class_id); |
624 *class_id = obj.GetClassId(); | 588 *class_id = obj.GetClassId(); |
625 return Api::Success(); | 589 return Api::Success(); |
626 } | 590 } |
627 | 591 |
628 | |
629 DART_EXPORT Dart_Handle Dart_GetClassFromId(intptr_t class_id) { | 592 DART_EXPORT Dart_Handle Dart_GetClassFromId(intptr_t class_id) { |
630 DARTSCOPE(Thread::Current()); | 593 DARTSCOPE(Thread::Current()); |
631 Isolate* I = T->isolate(); | 594 Isolate* I = T->isolate(); |
632 if (!I->class_table()->IsValidIndex(class_id)) { | 595 if (!I->class_table()->IsValidIndex(class_id)) { |
633 return Api::NewError("%s: %" Pd " is not a valid class id", CURRENT_FUNC, | 596 return Api::NewError("%s: %" Pd " is not a valid class id", CURRENT_FUNC, |
634 class_id); | 597 class_id); |
635 } | 598 } |
636 return Api::NewHandle(T, I->class_table()->At(class_id)); | 599 return Api::NewHandle(T, I->class_table()->At(class_id)); |
637 } | 600 } |
638 | 601 |
639 | |
640 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) { | 602 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) { |
641 DARTSCOPE(Thread::Current()); | 603 DARTSCOPE(Thread::Current()); |
642 | 604 |
643 UNWRAP_AND_CHECK_PARAM(Type, type, type_in); | 605 UNWRAP_AND_CHECK_PARAM(Type, type, type_in); |
644 if (!type.IsFinalized()) { | 606 if (!type.IsFinalized()) { |
645 return Api::NewError("%s: type in 'type_in' is not a finalized type", | 607 return Api::NewError("%s: type in 'type_in' is not a finalized type", |
646 CURRENT_FUNC); | 608 CURRENT_FUNC); |
647 } | 609 } |
648 if (!type.IsInstantiated()) { | 610 if (!type.IsInstantiated()) { |
649 return Api::NewError("%s: type in 'type_in' is not an instantiated type", | 611 return Api::NewError("%s: type in 'type_in' is not an instantiated type", |
(...skipping 25 matching lines...) Expand all Loading... |
675 } | 637 } |
676 | 638 |
677 // Construct the super type object, canonicalize it and return. | 639 // Construct the super type object, canonicalize it and return. |
678 Type& instantiated_type = Type::Handle( | 640 Type& instantiated_type = Type::Handle( |
679 Type::New(super_cls, super_type_args_array, TokenPosition::kNoSource)); | 641 Type::New(super_cls, super_type_args_array, TokenPosition::kNoSource)); |
680 ASSERT(!instantiated_type.IsNull()); | 642 ASSERT(!instantiated_type.IsNull()); |
681 instantiated_type.SetIsFinalized(); | 643 instantiated_type.SetIsFinalized(); |
682 return Api::NewHandle(T, instantiated_type.Canonicalize()); | 644 return Api::NewHandle(T, instantiated_type.Canonicalize()); |
683 } | 645 } |
684 | 646 |
685 | |
686 DART_EXPORT Dart_Handle Dart_GetClosureInfo(Dart_Handle closure, | 647 DART_EXPORT Dart_Handle Dart_GetClosureInfo(Dart_Handle closure, |
687 Dart_Handle* name, | 648 Dart_Handle* name, |
688 Dart_Handle* signature, | 649 Dart_Handle* signature, |
689 Dart_CodeLocation* location) { | 650 Dart_CodeLocation* location) { |
690 DARTSCOPE(Thread::Current()); | 651 DARTSCOPE(Thread::Current()); |
691 UNWRAP_AND_CHECK_PARAM(Instance, instance, closure); | 652 UNWRAP_AND_CHECK_PARAM(Instance, instance, closure); |
692 CHECK_NOT_NULL(location); | 653 CHECK_NOT_NULL(location); |
693 | 654 |
694 if (!instance.IsClosure()) { | 655 if (!instance.IsClosure()) { |
695 return Api::NewError("%s: parameter 0 is not a closure", CURRENT_FUNC); | 656 return Api::NewError("%s: parameter 0 is not a closure", CURRENT_FUNC); |
(...skipping 21 matching lines...) Expand all Loading... |
717 location->token_pos = func.token_pos().Pos(); | 678 location->token_pos = func.token_pos().Pos(); |
718 } else { | 679 } else { |
719 location->script_url = Api::NewHandle(T, String::null()); | 680 location->script_url = Api::NewHandle(T, String::null()); |
720 location->library_id = -1; | 681 location->library_id = -1; |
721 location->token_pos = -1; | 682 location->token_pos = -1; |
722 } | 683 } |
723 } | 684 } |
724 return Api::True(); | 685 return Api::True(); |
725 } | 686 } |
726 | 687 |
727 | |
728 DART_EXPORT Dart_Handle Dart_GetClassInfo(intptr_t cls_id, | 688 DART_EXPORT Dart_Handle Dart_GetClassInfo(intptr_t cls_id, |
729 Dart_Handle* class_name, | 689 Dart_Handle* class_name, |
730 intptr_t* library_id, | 690 intptr_t* library_id, |
731 intptr_t* super_class_id, | 691 intptr_t* super_class_id, |
732 Dart_Handle* static_fields) { | 692 Dart_Handle* static_fields) { |
733 DARTSCOPE(Thread::Current()); | 693 DARTSCOPE(Thread::Current()); |
734 Isolate* I = T->isolate(); | 694 Isolate* I = T->isolate(); |
735 CHECK_DEBUGGER(I); | 695 CHECK_DEBUGGER(I); |
736 if (!I->class_table()->IsValidIndex(cls_id)) { | 696 if (!I->class_table()->IsValidIndex(cls_id)) { |
737 return Api::NewError("%s: %" Pd " is not a valid class id", CURRENT_FUNC, | 697 return Api::NewError("%s: %" Pd " is not a valid class id", CURRENT_FUNC, |
(...skipping 13 matching lines...) Expand all Loading... |
751 if (!super_cls.IsNull()) { | 711 if (!super_cls.IsNull()) { |
752 *super_class_id = super_cls.id(); | 712 *super_class_id = super_cls.id(); |
753 } | 713 } |
754 } | 714 } |
755 if (static_fields != NULL) { | 715 if (static_fields != NULL) { |
756 *static_fields = Api::NewHandle(T, I->debugger()->GetStaticFields(cls)); | 716 *static_fields = Api::NewHandle(T, I->debugger()->GetStaticFields(cls)); |
757 } | 717 } |
758 return Api::Success(); | 718 return Api::Success(); |
759 } | 719 } |
760 | 720 |
761 | |
762 DART_EXPORT Dart_Handle Dart_ScriptGetSource(intptr_t library_id, | 721 DART_EXPORT Dart_Handle Dart_ScriptGetSource(intptr_t library_id, |
763 Dart_Handle script_url_in) { | 722 Dart_Handle script_url_in) { |
764 DARTSCOPE(Thread::Current()); | 723 DARTSCOPE(Thread::Current()); |
765 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 724 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
766 if (lib.IsNull()) { | 725 if (lib.IsNull()) { |
767 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 726 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
768 library_id); | 727 library_id); |
769 } | 728 } |
770 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 729 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
771 const Script& script = Script::Handle(lib.LookupScript(script_url)); | 730 const Script& script = Script::Handle(lib.LookupScript(script_url)); |
772 if (script.IsNull()) { | 731 if (script.IsNull()) { |
773 return Api::NewError("%s: script '%s' not found in library '%s'", | 732 return Api::NewError("%s: script '%s' not found in library '%s'", |
774 CURRENT_FUNC, script_url.ToCString(), | 733 CURRENT_FUNC, script_url.ToCString(), |
775 String::Handle(lib.url()).ToCString()); | 734 String::Handle(lib.url()).ToCString()); |
776 } | 735 } |
777 return Api::NewHandle(T, script.Source()); | 736 return Api::NewHandle(T, script.Source()); |
778 } | 737 } |
779 | 738 |
780 | |
781 DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo(intptr_t library_id, | 739 DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo(intptr_t library_id, |
782 Dart_Handle script_url_in) { | 740 Dart_Handle script_url_in) { |
783 DARTSCOPE(Thread::Current()); | 741 DARTSCOPE(Thread::Current()); |
784 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 742 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
785 if (lib.IsNull()) { | 743 if (lib.IsNull()) { |
786 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 744 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
787 library_id); | 745 library_id); |
788 } | 746 } |
789 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 747 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
790 const Script& script = Script::Handle(lib.LookupScript(script_url)); | 748 const Script& script = Script::Handle(lib.LookupScript(script_url)); |
791 if (script.IsNull()) { | 749 if (script.IsNull()) { |
792 return Api::NewError("%s: script '%s' not found in library '%s'", | 750 return Api::NewError("%s: script '%s' not found in library '%s'", |
793 CURRENT_FUNC, script_url.ToCString(), | 751 CURRENT_FUNC, script_url.ToCString(), |
794 String::Handle(lib.url()).ToCString()); | 752 String::Handle(lib.url()).ToCString()); |
795 } | 753 } |
796 | 754 |
797 const GrowableObjectArray& info = | 755 const GrowableObjectArray& info = |
798 GrowableObjectArray::Handle(script.GenerateLineNumberArray()); | 756 GrowableObjectArray::Handle(script.GenerateLineNumberArray()); |
799 return Api::NewHandle(T, Array::MakeFixedLength(info)); | 757 return Api::NewHandle(T, Array::MakeFixedLength(info)); |
800 } | 758 } |
801 | 759 |
802 | |
803 DART_EXPORT Dart_Handle Dart_GenerateScriptSource(Dart_Handle library_url_in, | 760 DART_EXPORT Dart_Handle Dart_GenerateScriptSource(Dart_Handle library_url_in, |
804 Dart_Handle script_url_in) { | 761 Dart_Handle script_url_in) { |
805 DARTSCOPE(Thread::Current()); | 762 DARTSCOPE(Thread::Current()); |
806 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); | 763 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); |
807 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 764 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
808 | 765 |
809 const Library& library = | 766 const Library& library = |
810 Library::Handle(Z, Library::LookupLibrary(T, library_url)); | 767 Library::Handle(Z, Library::LookupLibrary(T, library_url)); |
811 if (library.IsNull()) { | 768 if (library.IsNull()) { |
812 return Api::NewError("%s: library '%s' not found", CURRENT_FUNC, | 769 return Api::NewError("%s: library '%s' not found", CURRENT_FUNC, |
813 library_url.ToCString()); | 770 library_url.ToCString()); |
814 } | 771 } |
815 | 772 |
816 const Script& script = Script::Handle(Z, library.LookupScript(script_url)); | 773 const Script& script = Script::Handle(Z, library.LookupScript(script_url)); |
817 if (script.IsNull()) { | 774 if (script.IsNull()) { |
818 return Api::NewError("%s: script '%s' not found in library '%s'", | 775 return Api::NewError("%s: script '%s' not found in library '%s'", |
819 CURRENT_FUNC, script_url.ToCString(), | 776 CURRENT_FUNC, script_url.ToCString(), |
820 library_url.ToCString()); | 777 library_url.ToCString()); |
821 } | 778 } |
822 | 779 |
823 return Api::NewHandle(T, script.GenerateSource()); | 780 return Api::NewHandle(T, script.GenerateSource()); |
824 } | 781 } |
825 | 782 |
826 | |
827 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) { | 783 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) { |
828 DARTSCOPE(Thread::Current()); | 784 DARTSCOPE(Thread::Current()); |
829 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); | 785 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); |
830 | 786 |
831 const Library& library = | 787 const Library& library = |
832 Library::Handle(Z, Library::LookupLibrary(T, library_url)); | 788 Library::Handle(Z, Library::LookupLibrary(T, library_url)); |
833 if (library.IsNull()) { | 789 if (library.IsNull()) { |
834 return Api::NewError("%s: library '%s' not found", CURRENT_FUNC, | 790 return Api::NewError("%s: library '%s' not found", CURRENT_FUNC, |
835 library_url.ToCString()); | 791 library_url.ToCString()); |
836 } | 792 } |
837 const Array& loaded_scripts = Array::Handle(Z, library.LoadedScripts()); | 793 const Array& loaded_scripts = Array::Handle(Z, library.LoadedScripts()); |
838 ASSERT(!loaded_scripts.IsNull()); | 794 ASSERT(!loaded_scripts.IsNull()); |
839 intptr_t num_scripts = loaded_scripts.Length(); | 795 intptr_t num_scripts = loaded_scripts.Length(); |
840 const Array& script_list = Array::Handle(Z, Array::New(num_scripts)); | 796 const Array& script_list = Array::Handle(Z, Array::New(num_scripts)); |
841 Script& script = Script::Handle(Z); | 797 Script& script = Script::Handle(Z); |
842 String& url = String::Handle(Z); | 798 String& url = String::Handle(Z); |
843 for (int i = 0; i < num_scripts; i++) { | 799 for (int i = 0; i < num_scripts; i++) { |
844 script ^= loaded_scripts.At(i); | 800 script ^= loaded_scripts.At(i); |
845 url = script.url(); | 801 url = script.url(); |
846 script_list.SetAt(i, url); | 802 script_list.SetAt(i, url); |
847 } | 803 } |
848 return Api::NewHandle(T, script_list.raw()); | 804 return Api::NewHandle(T, script_list.raw()); |
849 } | 805 } |
850 | 806 |
851 | |
852 DART_EXPORT Dart_Handle Dart_GetLibraryIds() { | 807 DART_EXPORT Dart_Handle Dart_GetLibraryIds() { |
853 DARTSCOPE(Thread::Current()); | 808 DARTSCOPE(Thread::Current()); |
854 Isolate* I = T->isolate(); | 809 Isolate* I = T->isolate(); |
855 | 810 |
856 const GrowableObjectArray& libs = | 811 const GrowableObjectArray& libs = |
857 GrowableObjectArray::Handle(Z, I->object_store()->libraries()); | 812 GrowableObjectArray::Handle(Z, I->object_store()->libraries()); |
858 int num_libs = libs.Length(); | 813 int num_libs = libs.Length(); |
859 | 814 |
860 // Create new list and populate with the url of loaded libraries. | 815 // Create new list and populate with the url of loaded libraries. |
861 Library& lib = Library::Handle(); | 816 Library& lib = Library::Handle(); |
862 const Array& library_id_list = Array::Handle(Z, Array::New(num_libs)); | 817 const Array& library_id_list = Array::Handle(Z, Array::New(num_libs)); |
863 for (int i = 0; i < num_libs; i++) { | 818 for (int i = 0; i < num_libs; i++) { |
864 lib ^= libs.At(i); | 819 lib ^= libs.At(i); |
865 ASSERT(!lib.IsNull()); | 820 ASSERT(!lib.IsNull()); |
866 ASSERT(Smi::IsValid(lib.index())); | 821 ASSERT(Smi::IsValid(lib.index())); |
867 library_id_list.SetAt(i, Smi::Handle(Smi::New(lib.index()))); | 822 library_id_list.SetAt(i, Smi::Handle(Smi::New(lib.index()))); |
868 } | 823 } |
869 return Api::NewHandle(T, library_id_list.raw()); | 824 return Api::NewHandle(T, library_id_list.raw()); |
870 } | 825 } |
871 | 826 |
872 | |
873 DART_EXPORT Dart_Handle Dart_GetLibraryFromId(intptr_t library_id) { | 827 DART_EXPORT Dart_Handle Dart_GetLibraryFromId(intptr_t library_id) { |
874 DARTSCOPE(Thread::Current()); | 828 DARTSCOPE(Thread::Current()); |
875 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); | 829 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
876 if (lib.IsNull()) { | 830 if (lib.IsNull()) { |
877 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 831 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
878 library_id); | 832 library_id); |
879 } | 833 } |
880 return Api::NewHandle(T, lib.raw()); | 834 return Api::NewHandle(T, lib.raw()); |
881 } | 835 } |
882 | 836 |
883 | |
884 DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library, | 837 DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library, |
885 intptr_t* library_id) { | 838 intptr_t* library_id) { |
886 DARTSCOPE(Thread::Current()); | 839 DARTSCOPE(Thread::Current()); |
887 const Library& lib = Api::UnwrapLibraryHandle(Z, library); | 840 const Library& lib = Api::UnwrapLibraryHandle(Z, library); |
888 if (lib.IsNull()) { | 841 if (lib.IsNull()) { |
889 RETURN_TYPE_ERROR(Z, library, Library); | 842 RETURN_TYPE_ERROR(Z, library, Library); |
890 } | 843 } |
891 if (library_id == NULL) { | 844 if (library_id == NULL) { |
892 RETURN_NULL_ERROR(library_id); | 845 RETURN_NULL_ERROR(library_id); |
893 } | 846 } |
894 *library_id = lib.index(); | 847 *library_id = lib.index(); |
895 return Api::Success(); | 848 return Api::Success(); |
896 } | 849 } |
897 | 850 |
898 | |
899 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { | 851 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { |
900 DARTSCOPE(Thread::Current()); | 852 DARTSCOPE(Thread::Current()); |
901 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 853 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
902 if (lib.IsNull()) { | 854 if (lib.IsNull()) { |
903 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 855 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
904 library_id); | 856 library_id); |
905 } | 857 } |
906 const GrowableObjectArray& import_list = | 858 const GrowableObjectArray& import_list = |
907 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 859 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
908 | 860 |
(...skipping 16 matching lines...) Expand all Loading... |
925 prefix_name = String::Concat(prefix_name, Symbols::Dot()); | 877 prefix_name = String::Concat(prefix_name, Symbols::Dot()); |
926 for (int32_t i = 0; i < prefix.num_imports(); i++) { | 878 for (int32_t i = 0; i < prefix.num_imports(); i++) { |
927 imported = prefix.GetLibrary(i); | 879 imported = prefix.GetLibrary(i); |
928 import_list.Add(prefix_name); | 880 import_list.Add(prefix_name); |
929 import_list.Add(Smi::Handle(Smi::New(imported.index()))); | 881 import_list.Add(Smi::Handle(Smi::New(imported.index()))); |
930 } | 882 } |
931 } | 883 } |
932 return Api::NewHandle(T, Array::MakeFixedLength(import_list)); | 884 return Api::NewHandle(T, Array::MakeFixedLength(import_list)); |
933 } | 885 } |
934 | 886 |
935 | |
936 DART_EXPORT Dart_Handle Dart_GetLibraryURL(intptr_t library_id) { | 887 DART_EXPORT Dart_Handle Dart_GetLibraryURL(intptr_t library_id) { |
937 DARTSCOPE(Thread::Current()); | 888 DARTSCOPE(Thread::Current()); |
938 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); | 889 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
939 if (lib.IsNull()) { | 890 if (lib.IsNull()) { |
940 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 891 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
941 library_id); | 892 library_id); |
942 } | 893 } |
943 return Api::NewHandle(T, lib.url()); | 894 return Api::NewHandle(T, lib.url()); |
944 } | 895 } |
945 | 896 |
946 | |
947 DART_EXPORT Dart_Handle Dart_GetLibraryDebuggable(intptr_t library_id, | 897 DART_EXPORT Dart_Handle Dart_GetLibraryDebuggable(intptr_t library_id, |
948 bool* is_debuggable) { | 898 bool* is_debuggable) { |
949 DARTSCOPE(Thread::Current()); | 899 DARTSCOPE(Thread::Current()); |
950 CHECK_NOT_NULL(is_debuggable); | 900 CHECK_NOT_NULL(is_debuggable); |
951 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 901 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
952 if (lib.IsNull()) { | 902 if (lib.IsNull()) { |
953 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 903 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
954 library_id); | 904 library_id); |
955 } | 905 } |
956 *is_debuggable = lib.IsDebuggable(); | 906 *is_debuggable = lib.IsDebuggable(); |
957 return Api::Success(); | 907 return Api::Success(); |
958 } | 908 } |
959 | 909 |
960 | |
961 DART_EXPORT Dart_Handle Dart_SetLibraryDebuggable(intptr_t library_id, | 910 DART_EXPORT Dart_Handle Dart_SetLibraryDebuggable(intptr_t library_id, |
962 bool is_debuggable) { | 911 bool is_debuggable) { |
963 DARTSCOPE(Thread::Current()); | 912 DARTSCOPE(Thread::Current()); |
964 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); | 913 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
965 if (lib.IsNull()) { | 914 if (lib.IsNull()) { |
966 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, | 915 return Api::NewError("%s: %" Pd " is not a valid library id", CURRENT_FUNC, |
967 library_id); | 916 library_id); |
968 } | 917 } |
969 lib.set_debuggable(is_debuggable); | 918 lib.set_debuggable(is_debuggable); |
970 return Api::Success(); | 919 return Api::Success(); |
971 } | 920 } |
972 | 921 |
973 | |
974 DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id) { | 922 DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id) { |
975 Isolate* isolate = PortMap::GetIsolate(isolate_id); | 923 Isolate* isolate = PortMap::GetIsolate(isolate_id); |
976 return Api::CastIsolate(isolate); | 924 return Api::CastIsolate(isolate); |
977 } | 925 } |
978 | 926 |
979 | |
980 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 927 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
981 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 928 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
982 if (isolate->debugger() == NULL) { | 929 if (isolate->debugger() == NULL) { |
983 return ILLEGAL_ISOLATE_ID; | 930 return ILLEGAL_ISOLATE_ID; |
984 } | 931 } |
985 return isolate->debugger()->GetIsolateId(); | 932 return isolate->debugger()->GetIsolateId(); |
986 } | 933 } |
987 | 934 |
988 #else | 935 #else |
989 | 936 |
990 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) { | 937 DART_EXPORT void Dart_SetPausedEventHandler(Dart_PausedEventHandler handler) { |
991 // NOOP. | 938 // NOOP. |
992 } | 939 } |
993 | 940 |
994 #endif // !PRODUCT | 941 #endif // !PRODUCT |
995 | 942 |
996 } // namespace dart | 943 } // namespace dart |
OLD | NEW |