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/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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 | 72 |
73 DART_EXPORT Dart_Handle Dart_StackTraceLength( | 73 DART_EXPORT Dart_Handle Dart_StackTraceLength( |
74 Dart_StackTrace trace, | 74 Dart_StackTrace trace, |
75 intptr_t* length) { | 75 intptr_t* length) { |
76 Isolate* isolate = Isolate::Current(); | 76 Isolate* isolate = Isolate::Current(); |
77 DARTSCOPE(isolate); | 77 DARTSCOPE(isolate); |
78 CHECK_NOT_NULL(length); | 78 CHECK_NOT_NULL(length); |
79 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); | 79 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); |
80 *length = stack_trace->Length(); | 80 *length = stack_trace->Length(); |
81 return Api::True(isolate); | 81 return Api::Success(); |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 DART_EXPORT Dart_Handle Dart_GetActivationFrame( | 85 DART_EXPORT Dart_Handle Dart_GetActivationFrame( |
86 Dart_StackTrace trace, | 86 Dart_StackTrace trace, |
87 int frame_index, | 87 int frame_index, |
88 Dart_ActivationFrame* frame) { | 88 Dart_ActivationFrame* frame) { |
89 Isolate* isolate = Isolate::Current(); | 89 Isolate* isolate = Isolate::Current(); |
90 DARTSCOPE(isolate); | 90 DARTSCOPE(isolate); |
91 CHECK_NOT_NULL(frame); | 91 CHECK_NOT_NULL(frame); |
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::Success(); |
100 } | 100 } |
101 | 101 |
102 static Dart_PausedEventHandler* paused_event_handler = NULL; | 102 static Dart_PausedEventHandler* paused_event_handler = NULL; |
103 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; | 103 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; |
104 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; | 104 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; |
105 static Dart_IsolateEventHandler* isolate_event_handler = NULL; | 105 static Dart_IsolateEventHandler* isolate_event_handler = NULL; |
106 | 106 |
107 static Dart_BreakpointHandler* legacy_bp_handler = NULL; | 107 static Dart_BreakpointHandler* legacy_bp_handler = NULL; |
108 | 108 |
109 | 109 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 isolate_event_handler = handler; | 197 isolate_event_handler = handler; |
198 Debugger::SetEventHandler(DebuggerEventHandler); | 198 Debugger::SetEventHandler(DebuggerEventHandler); |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 DART_EXPORT Dart_Handle Dart_SetExceptionPauseInfo( | 202 DART_EXPORT Dart_Handle Dart_SetExceptionPauseInfo( |
203 Dart_ExceptionPauseInfo pause_info) { | 203 Dart_ExceptionPauseInfo pause_info) { |
204 Isolate* isolate = Isolate::Current(); | 204 Isolate* isolate = Isolate::Current(); |
205 DARTSCOPE(isolate); | 205 DARTSCOPE(isolate); |
206 isolate->debugger()->SetExceptionPauseInfo(pause_info); | 206 isolate->debugger()->SetExceptionPauseInfo(pause_info); |
207 return Api::True(isolate); | 207 return Api::Success(); |
208 } | 208 } |
209 | 209 |
210 | 210 |
211 DART_EXPORT Dart_ExceptionPauseInfo Dart_GetExceptionPauseInfo() { | 211 DART_EXPORT Dart_ExceptionPauseInfo Dart_GetExceptionPauseInfo() { |
212 Isolate* isolate = Isolate::Current(); | 212 Isolate* isolate = Isolate::Current(); |
213 DARTSCOPE(isolate); | 213 DARTSCOPE(isolate); |
214 return isolate->debugger()->GetExceptionPauseInfo(); | 214 return isolate->debugger()->GetExceptionPauseInfo(); |
215 } | 215 } |
216 | 216 |
217 | 217 |
218 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace) { | 218 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace) { |
219 Isolate* isolate = Isolate::Current(); | 219 Isolate* isolate = Isolate::Current(); |
220 DARTSCOPE(isolate); | 220 DARTSCOPE(isolate); |
221 CHECK_NOT_NULL(trace); | 221 CHECK_NOT_NULL(trace); |
222 *trace = reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); | 222 *trace = reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); |
223 return Api::True(isolate); | 223 return Api::Success(); |
224 } | 224 } |
225 | 225 |
226 | 226 |
227 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( | 227 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( |
228 Dart_ActivationFrame activation_frame, | 228 Dart_ActivationFrame activation_frame, |
229 Dart_Handle* function_name, | 229 Dart_Handle* function_name, |
230 Dart_Handle* script_url, | 230 Dart_Handle* script_url, |
231 intptr_t* line_number, | 231 intptr_t* line_number, |
232 intptr_t* library_id) { | 232 intptr_t* library_id) { |
233 Isolate* isolate = Isolate::Current(); | 233 Isolate* isolate = Isolate::Current(); |
234 DARTSCOPE(isolate); | 234 DARTSCOPE(isolate); |
235 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 235 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
236 if (function_name != NULL) { | 236 if (function_name != NULL) { |
237 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); | 237 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); |
238 } | 238 } |
239 if (script_url != NULL) { | 239 if (script_url != NULL) { |
240 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); | 240 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); |
241 } | 241 } |
242 if (line_number != NULL) { | 242 if (line_number != NULL) { |
243 *line_number = frame->LineNumber(); | 243 *line_number = frame->LineNumber(); |
244 } | 244 } |
245 if (library_id != NULL) { | 245 if (library_id != NULL) { |
246 const Library& lib = Library::Handle(frame->Library()); | 246 const Library& lib = Library::Handle(frame->Library()); |
247 *library_id = lib.index(); | 247 *library_id = lib.index(); |
248 } | 248 } |
249 return Api::True(isolate); | 249 return Api::Success(); |
250 } | 250 } |
251 | 251 |
252 | 252 |
253 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation( | 253 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation( |
254 Dart_ActivationFrame activation_frame, | 254 Dart_ActivationFrame activation_frame, |
255 Dart_Handle* function_name, | 255 Dart_Handle* function_name, |
256 Dart_CodeLocation* location) { | 256 Dart_CodeLocation* location) { |
257 // TODO(hausner): Implement a way to recognize when there | 257 // TODO(hausner): Implement a way to recognize when there |
258 // is no source code for the code in the frame. | 258 // is no source code for the code in the frame. |
259 Isolate* isolate = Isolate::Current(); | 259 Isolate* isolate = Isolate::Current(); |
260 DARTSCOPE(isolate); | 260 DARTSCOPE(isolate); |
261 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 261 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
262 if (function_name != NULL) { | 262 if (function_name != NULL) { |
263 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); | 263 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); |
264 } | 264 } |
265 | 265 |
266 if (location != NULL) { | 266 if (location != NULL) { |
267 location->script_url = Api::NewHandle(isolate, frame->SourceUrl()); | 267 location->script_url = Api::NewHandle(isolate, frame->SourceUrl()); |
268 const Library& lib = Library::Handle(frame->Library()); | 268 const Library& lib = Library::Handle(frame->Library()); |
269 location->library_id = lib.index(); | 269 location->library_id = lib.index(); |
270 location->token_pos = frame->TokenPos(); | 270 location->token_pos = frame->TokenPos(); |
271 } | 271 } |
272 return Api::True(isolate); | 272 return Api::Success(); |
273 } | 273 } |
274 | 274 |
275 | 275 |
276 DART_EXPORT Dart_Handle Dart_GetLocalVariables( | 276 DART_EXPORT Dart_Handle Dart_GetLocalVariables( |
277 Dart_ActivationFrame activation_frame) { | 277 Dart_ActivationFrame activation_frame) { |
278 Isolate* isolate = Isolate::Current(); | 278 Isolate* isolate = Isolate::Current(); |
279 DARTSCOPE(isolate); | 279 DARTSCOPE(isolate); |
280 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 280 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
281 return Api::NewHandle(isolate, frame->GetLocalVariables()); | 281 return Api::NewHandle(isolate, frame->GetLocalVariables()); |
282 } | 282 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 if (bp_target.IsNull()) { | 390 if (bp_target.IsNull()) { |
391 const bool toplevel = class_name.Length() == 0; | 391 const bool toplevel = class_name.Length() == 0; |
392 return Api::NewError("%s: could not find function '%s%s%s'", | 392 return Api::NewError("%s: could not find function '%s%s%s'", |
393 CURRENT_FUNC, | 393 CURRENT_FUNC, |
394 toplevel ? "" : class_name.ToCString(), | 394 toplevel ? "" : class_name.ToCString(), |
395 toplevel ? "" : ".", | 395 toplevel ? "" : ".", |
396 function_name.ToCString()); | 396 function_name.ToCString()); |
397 } | 397 } |
398 | 398 |
399 debugger->OneTimeBreakAtEntry(bp_target); | 399 debugger->OneTimeBreakAtEntry(bp_target); |
400 return Api::True(isolate); | 400 return Api::Success(); |
401 } | 401 } |
402 | 402 |
403 | 403 |
404 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { | 404 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { |
405 Isolate* isolate = Isolate::Current(); | 405 Isolate* isolate = Isolate::Current(); |
406 DARTSCOPE(isolate); | 406 DARTSCOPE(isolate); |
407 Debugger* debugger = isolate->debugger(); | 407 Debugger* debugger = isolate->debugger(); |
408 ASSERT(debugger != NULL); | 408 ASSERT(debugger != NULL); |
409 | 409 |
410 isolate->debugger()->RemoveBreakpoint(bp_id); | 410 isolate->debugger()->RemoveBreakpoint(bp_id); |
411 return Api::True(isolate); | 411 return Api::Success(); |
412 } | 412 } |
413 | 413 |
414 | 414 |
415 DART_EXPORT Dart_Handle Dart_SetStepOver() { | 415 DART_EXPORT Dart_Handle Dart_SetStepOver() { |
416 Isolate* isolate = Isolate::Current(); | 416 Isolate* isolate = Isolate::Current(); |
417 DARTSCOPE(isolate); | 417 DARTSCOPE(isolate); |
418 isolate->debugger()->SetStepOver(); | 418 isolate->debugger()->SetStepOver(); |
419 return Api::True(isolate); | 419 return Api::Success(); |
420 } | 420 } |
421 | 421 |
422 | 422 |
423 DART_EXPORT Dart_Handle Dart_SetStepInto() { | 423 DART_EXPORT Dart_Handle Dart_SetStepInto() { |
424 Isolate* isolate = Isolate::Current(); | 424 Isolate* isolate = Isolate::Current(); |
425 DARTSCOPE(isolate); | 425 DARTSCOPE(isolate); |
426 isolate->debugger()->SetStepInto(); | 426 isolate->debugger()->SetStepInto(); |
427 return Api::True(isolate); | 427 return Api::Success(); |
428 } | 428 } |
429 | 429 |
430 | 430 |
431 DART_EXPORT Dart_Handle Dart_SetStepOut() { | 431 DART_EXPORT Dart_Handle Dart_SetStepOut() { |
432 Isolate* isolate = Isolate::Current(); | 432 Isolate* isolate = Isolate::Current(); |
433 DARTSCOPE(isolate); | 433 DARTSCOPE(isolate); |
434 isolate->debugger()->SetStepOut(); | 434 isolate->debugger()->SetStepOut(); |
435 return Api::True(isolate); | 435 return Api::Success(); |
436 } | 436 } |
437 | 437 |
438 | 438 |
439 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { | 439 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { |
440 Isolate* isolate = Isolate::Current(); | 440 Isolate* isolate = Isolate::Current(); |
441 DARTSCOPE(isolate); | 441 DARTSCOPE(isolate); |
442 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 442 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
443 return Api::NewHandle(isolate, isolate->debugger()->GetInstanceFields(obj)); | 443 return Api::NewHandle(isolate, isolate->debugger()->GetInstanceFields(obj)); |
444 } | 444 } |
445 | 445 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 } | 486 } |
487 | 487 |
488 | 488 |
489 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, | 489 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, |
490 intptr_t* class_id) { | 490 intptr_t* class_id) { |
491 Isolate* isolate = Isolate::Current(); | 491 Isolate* isolate = Isolate::Current(); |
492 DARTSCOPE(isolate); | 492 DARTSCOPE(isolate); |
493 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 493 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
494 CHECK_NOT_NULL(class_id); | 494 CHECK_NOT_NULL(class_id); |
495 *class_id = obj.GetClassId(); | 495 *class_id = obj.GetClassId(); |
496 return Api::True(isolate); | 496 return Api::Success(); |
497 } | 497 } |
498 | 498 |
499 | 499 |
500 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { | 500 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { |
501 Isolate* isolate = Isolate::Current(); | 501 Isolate* isolate = Isolate::Current(); |
502 DARTSCOPE(isolate); | 502 DARTSCOPE(isolate); |
503 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); | 503 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); |
504 return Api::NewHandle(isolate, cls.SuperClass()); | 504 return Api::NewHandle(isolate, cls.SuperClass()); |
505 } | 505 } |
506 | 506 |
(...skipping 22 matching lines...) Expand all Loading... |
529 *super_class_id = 0; | 529 *super_class_id = 0; |
530 Class& super_cls = Class::Handle(isolate, cls.SuperClass()); | 530 Class& super_cls = Class::Handle(isolate, cls.SuperClass()); |
531 if (!super_cls.IsNull()) { | 531 if (!super_cls.IsNull()) { |
532 *super_class_id = super_cls.id(); | 532 *super_class_id = super_cls.id(); |
533 } | 533 } |
534 } | 534 } |
535 if (static_fields != NULL) { | 535 if (static_fields != NULL) { |
536 *static_fields = | 536 *static_fields = |
537 Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); | 537 Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); |
538 } | 538 } |
539 return Api::True(isolate); | 539 return Api::Success(); |
540 } | 540 } |
541 | 541 |
542 | 542 |
543 DART_EXPORT Dart_Handle Dart_ScriptGetSource( | 543 DART_EXPORT Dart_Handle Dart_ScriptGetSource( |
544 intptr_t library_id, | 544 intptr_t library_id, |
545 Dart_Handle script_url_in) { | 545 Dart_Handle script_url_in) { |
546 Isolate* isolate = Isolate::Current(); | 546 Isolate* isolate = Isolate::Current(); |
547 DARTSCOPE(isolate); | 547 DARTSCOPE(isolate); |
548 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 548 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
549 if (lib.IsNull()) { | 549 if (lib.IsNull()) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 Isolate* isolate = Isolate::Current(); | 740 Isolate* isolate = Isolate::Current(); |
741 ASSERT(isolate != NULL); | 741 ASSERT(isolate != NULL); |
742 DARTSCOPE(isolate); | 742 DARTSCOPE(isolate); |
743 CHECK_NOT_NULL(is_debuggable); | 743 CHECK_NOT_NULL(is_debuggable); |
744 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 744 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
745 if (lib.IsNull()) { | 745 if (lib.IsNull()) { |
746 return Api::NewError("%s: %"Pd" is not a valid library id", | 746 return Api::NewError("%s: %"Pd" is not a valid library id", |
747 CURRENT_FUNC, library_id); | 747 CURRENT_FUNC, library_id); |
748 } | 748 } |
749 *is_debuggable = lib.IsDebuggable(); | 749 *is_debuggable = lib.IsDebuggable(); |
750 return Api::True(isolate); | 750 return Api::Success(); |
751 } | 751 } |
752 | 752 |
753 | 753 |
754 DART_EXPORT Dart_Handle Dart_SetLibraryDebuggable(intptr_t library_id, | 754 DART_EXPORT Dart_Handle Dart_SetLibraryDebuggable(intptr_t library_id, |
755 bool is_debuggable) { | 755 bool is_debuggable) { |
756 Isolate* isolate = Isolate::Current(); | 756 Isolate* isolate = Isolate::Current(); |
757 ASSERT(isolate != NULL); | 757 ASSERT(isolate != NULL); |
758 DARTSCOPE(isolate); | 758 DARTSCOPE(isolate); |
759 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 759 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
760 if (lib.IsNull()) { | 760 if (lib.IsNull()) { |
761 return Api::NewError("%s: %"Pd" is not a valid library id", | 761 return Api::NewError("%s: %"Pd" is not a valid library id", |
762 CURRENT_FUNC, library_id); | 762 CURRENT_FUNC, library_id); |
763 } | 763 } |
764 lib.set_debuggable(is_debuggable); | 764 lib.set_debuggable(is_debuggable); |
765 return Api::True(isolate); | 765 return Api::Success(); |
766 } | 766 } |
767 | 767 |
768 | 768 |
769 DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id) { | 769 DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id) { |
770 Isolate* isolate = PortMap::GetIsolate(isolate_id); | 770 Isolate* isolate = PortMap::GetIsolate(isolate_id); |
771 return Api::CastIsolate(isolate); | 771 return Api::CastIsolate(isolate); |
772 } | 772 } |
773 | 773 |
774 | 774 |
775 DART_EXPORT char* Dart_GetVmStatus(const char* request) { | 775 DART_EXPORT char* Dart_GetVmStatus(const char* request) { |
776 if (strncmp(request, "/isolate/", 9) == 0) { | 776 if (strncmp(request, "/isolate/", 9) == 0) { |
777 return Isolate::GetStatus(request); | 777 return Isolate::GetStatus(request); |
778 } | 778 } |
779 return NULL; | 779 return NULL; |
780 } | 780 } |
781 | 781 |
782 } // namespace dart | 782 } // namespace dart |
OLD | NEW |