OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 #include "include/dart_dapi.h" |
| 6 |
| 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/debugger.h" |
| 10 #include "vm/isolate.h" |
| 11 #include "vm/longjump.h" |
| 12 |
| 13 |
| 14 namespace dart { |
| 15 |
| 16 |
| 17 DART_EXPORT void Dart_InitDebugger() { |
| 18 Isolate* isolate = Isolate::Current(); |
| 19 DARTSCOPE(isolate); |
| 20 isolate->debugger()->Initialize(isolate); |
| 21 } |
| 22 |
| 23 |
| 24 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( |
| 25 Dart_Handle library_in, |
| 26 Dart_Handle class_name_in, |
| 27 Dart_Handle function_name_in, |
| 28 Dart_Breakpoint* breakpoint) { |
| 29 Isolate* isolate = Isolate::Current(); |
| 30 DARTSCOPE(isolate); |
| 31 if (breakpoint != NULL) { |
| 32 *breakpoint = NULL; |
| 33 } |
| 34 const char* msg = CheckIsolateState(isolate); |
| 35 if (msg != NULL) { |
| 36 return Api::Error(msg); |
| 37 } |
| 38 |
| 39 const Library& library = |
| 40 Library::CheckedHandle(Api::UnwrapHandle(library_in)); |
| 41 if (library.IsNull()) { |
| 42 return Api::Error("No library specified"); |
| 43 } |
| 44 const String& class_name = |
| 45 String::CheckedHandle(Api::UnwrapHandle(class_name_in)); |
| 46 const String& function_name = |
| 47 String::CheckedHandle(Api::UnwrapHandle(function_name_in)); |
| 48 |
| 49 // Resolve the breakpoint target function. |
| 50 const Function& bp_target = Function::Handle( |
| 51 isolate->debugger()->ResolveFunction( |
| 52 library, class_name, function_name)); |
| 53 if (bp_target.IsNull()) { |
| 54 return Api::Error("Breakpoint target function does not exist"); |
| 55 } |
| 56 |
| 57 LongJump* base = isolate->long_jump_base(); |
| 58 LongJump jump; |
| 59 isolate->set_long_jump_base(&jump); |
| 60 Dart_Handle result = Api::True(); |
| 61 if (setjmp(*jump.Set()) == 0) { |
| 62 Breakpoint* bpt = isolate->debugger()->SetBreakpointAtEntry(bp_target); |
| 63 if (breakpoint != NULL) { |
| 64 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); |
| 65 } |
| 66 } else { |
| 67 SetupErrorResult(&result); |
| 68 } |
| 69 isolate->set_long_jump_base(base); |
| 70 return result; |
| 71 } |
| 72 |
| 73 |
| 74 } // namespace dart |
OLD | NEW |