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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 return Api::Success(); | 101 return Api::Success(); |
102 } | 102 } |
103 | 103 |
104 static Dart_PausedEventHandler* paused_event_handler = NULL; | 104 static Dart_PausedEventHandler* paused_event_handler = NULL; |
105 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; | 105 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; |
106 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; | 106 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; |
107 static Dart_IsolateEventHandler* isolate_event_handler = NULL; | 107 static Dart_IsolateEventHandler* isolate_event_handler = NULL; |
108 | 108 |
109 | 109 |
110 static void DebuggerEventHandler(DebuggerEvent* event) { | 110 static void DebuggerEventHandler(DebuggerEvent* event) { |
111 Isolate* isolate = Isolate::Current(); | 111 Thread* thread = Thread::Current(); |
| 112 Isolate* isolate = thread->isolate(); |
112 ASSERT(isolate != NULL); | 113 ASSERT(isolate != NULL); |
113 Dart_EnterScope(); | 114 Dart_EnterScope(); |
114 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); | 115 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); |
115 if (event->type() == DebuggerEvent::kBreakpointReached) { | 116 if (event->type() == DebuggerEvent::kBreakpointReached) { |
116 if (paused_event_handler != NULL) { | 117 if (paused_event_handler != NULL) { |
117 Dart_CodeLocation location; | 118 Dart_CodeLocation location; |
118 ActivationFrame* top_frame = event->top_frame(); | 119 ActivationFrame* top_frame = event->top_frame(); |
119 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl()); | 120 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl()); |
120 const Library& lib = Library::Handle(top_frame->Library()); | 121 const Library& lib = Library::Handle(top_frame->Library()); |
121 location.library_id = lib.index(); | 122 location.library_id = lib.index(); |
122 location.token_pos = top_frame->TokenPos(); | 123 location.token_pos = top_frame->TokenPos(); |
123 intptr_t bp_id = 0; | 124 intptr_t bp_id = 0; |
124 if (event->breakpoint() != NULL) { | 125 if (event->breakpoint() != NULL) { |
125 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); | 126 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); |
126 bp_id = event->breakpoint()->id(); | 127 bp_id = event->breakpoint()->id(); |
127 } | 128 } |
128 (*paused_event_handler)(isolate_id, bp_id, location); | 129 (*paused_event_handler)(isolate_id, bp_id, location); |
129 } | 130 } |
130 } else if (event->type() == DebuggerEvent::kBreakpointResolved) { | 131 } else if (event->type() == DebuggerEvent::kBreakpointResolved) { |
131 if (bp_resolved_handler != NULL) { | 132 if (bp_resolved_handler != NULL) { |
132 Breakpoint* bpt = event->breakpoint(); | 133 Breakpoint* bpt = event->breakpoint(); |
133 ASSERT(bpt != NULL); | 134 ASSERT(bpt != NULL); |
134 Dart_CodeLocation location; | 135 Dart_CodeLocation location; |
135 Library& library = Library::Handle(isolate); | 136 Zone* zone = thread->zone(); |
136 Script& script = Script::Handle(isolate); | 137 Library& library = Library::Handle(zone); |
| 138 Script& script = Script::Handle(zone); |
137 intptr_t token_pos; | 139 intptr_t token_pos; |
138 bpt->bpt_location()->GetCodeLocation(&library, &script, &token_pos); | 140 bpt->bpt_location()->GetCodeLocation(&library, &script, &token_pos); |
139 location.script_url = Api::NewHandle(isolate, script.url()); | 141 location.script_url = Api::NewHandle(isolate, script.url()); |
140 location.library_id = library.index(); | 142 location.library_id = library.index(); |
141 location.token_pos = token_pos; | 143 location.token_pos = token_pos; |
142 (*bp_resolved_handler)(isolate_id, bpt->id(), location); | 144 (*bp_resolved_handler)(isolate_id, bpt->id(), location); |
143 } | 145 } |
144 } else if (event->type() == DebuggerEvent::kExceptionThrown) { | 146 } else if (event->type() == DebuggerEvent::kExceptionThrown) { |
145 if (exc_thrown_handler != NULL) { | 147 if (exc_thrown_handler != NULL) { |
146 Dart_Handle exception = | 148 Dart_Handle exception = |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 478 |
477 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { | 479 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { |
478 DARTSCOPE(Thread::Current()); | 480 DARTSCOPE(Thread::Current()); |
479 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 481 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
480 return Api::NewHandle(I, I->debugger()->GetInstanceFields(obj)); | 482 return Api::NewHandle(I, I->debugger()->GetInstanceFields(obj)); |
481 } | 483 } |
482 | 484 |
483 | 485 |
484 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle target) { | 486 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle target) { |
485 DARTSCOPE(Thread::Current()); | 487 DARTSCOPE(Thread::Current()); |
486 const Type& type_obj = Api::UnwrapTypeHandle(I, target); | 488 const Type& type_obj = Api::UnwrapTypeHandle(Z, target); |
487 if (type_obj.IsNull()) { | 489 if (type_obj.IsNull()) { |
488 return Api::NewError("%s expects argument 'target' to be a type", | 490 return Api::NewError("%s expects argument 'target' to be a type", |
489 CURRENT_FUNC); | 491 CURRENT_FUNC); |
490 } | 492 } |
491 const Class& cls = Class::Handle(Z, type_obj.type_class()); | 493 const Class& cls = Class::Handle(Z, type_obj.type_class()); |
492 return Api::NewHandle(I, I->debugger()->GetStaticFields(cls)); | 494 return Api::NewHandle(I, I->debugger()->GetStaticFields(cls)); |
493 } | 495 } |
494 | 496 |
495 | 497 |
496 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) { | 498 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 return Api::NewError("%s: %" Pd " is not a valid library id", | 833 return Api::NewError("%s: %" Pd " is not a valid library id", |
832 CURRENT_FUNC, library_id); | 834 CURRENT_FUNC, library_id); |
833 } | 835 } |
834 return Api::NewHandle(I, lib.raw()); | 836 return Api::NewHandle(I, lib.raw()); |
835 } | 837 } |
836 | 838 |
837 | 839 |
838 DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library, | 840 DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library, |
839 intptr_t* library_id) { | 841 intptr_t* library_id) { |
840 DARTSCOPE(Thread::Current()); | 842 DARTSCOPE(Thread::Current()); |
841 const Library& lib = Api::UnwrapLibraryHandle(I, library); | 843 const Library& lib = Api::UnwrapLibraryHandle(Z, library); |
842 if (lib.IsNull()) { | 844 if (lib.IsNull()) { |
843 RETURN_TYPE_ERROR(I, library, Library); | 845 RETURN_TYPE_ERROR(Z, library, Library); |
844 } | 846 } |
845 if (library_id == NULL) { | 847 if (library_id == NULL) { |
846 RETURN_NULL_ERROR(library_id); | 848 RETURN_NULL_ERROR(library_id); |
847 } | 849 } |
848 *library_id = lib.index(); | 850 *library_id = lib.index(); |
849 return Api::Success(); | 851 return Api::Success(); |
850 } | 852 } |
851 | 853 |
852 | 854 |
853 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { | 855 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 return Api::CastIsolate(isolate); | 932 return Api::CastIsolate(isolate); |
931 } | 933 } |
932 | 934 |
933 | 935 |
934 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 936 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
935 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 937 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
936 return isolate->debugger()->GetIsolateId(); | 938 return isolate->debugger()->GetIsolateId(); |
937 } | 939 } |
938 | 940 |
939 } // namespace dart | 941 } // namespace dart |
OLD | NEW |