| Index: runtime/vm/dart_dapi_impl.cc
|
| ===================================================================
|
| --- runtime/vm/dart_dapi_impl.cc (revision 0)
|
| +++ runtime/vm/dart_dapi_impl.cc (revision 0)
|
| @@ -0,0 +1,74 @@
|
| +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +#include "include/dart_dapi.h"
|
| +
|
| +#include "vm/dart_api_impl.h"
|
| +#include "vm/dart_api_state.h"
|
| +#include "vm/debugger.h"
|
| +#include "vm/isolate.h"
|
| +#include "vm/longjump.h"
|
| +
|
| +
|
| +namespace dart {
|
| +
|
| +
|
| +DART_EXPORT void Dart_InitDebugger() {
|
| + Isolate* isolate = Isolate::Current();
|
| + DARTSCOPE(isolate);
|
| + isolate->debugger()->Initialize(isolate);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry(
|
| + Dart_Handle library_in,
|
| + Dart_Handle class_name_in,
|
| + Dart_Handle function_name_in,
|
| + Dart_Breakpoint* breakpoint) {
|
| + Isolate* isolate = Isolate::Current();
|
| + DARTSCOPE(isolate);
|
| + if (breakpoint != NULL) {
|
| + *breakpoint = NULL;
|
| + }
|
| + const char* msg = CheckIsolateState(isolate);
|
| + if (msg != NULL) {
|
| + return Api::Error(msg);
|
| + }
|
| +
|
| + const Library& library =
|
| + Library::CheckedHandle(Api::UnwrapHandle(library_in));
|
| + if (library.IsNull()) {
|
| + return Api::Error("No library specified");
|
| + }
|
| + const String& class_name =
|
| + String::CheckedHandle(Api::UnwrapHandle(class_name_in));
|
| + const String& function_name =
|
| + String::CheckedHandle(Api::UnwrapHandle(function_name_in));
|
| +
|
| + // Resolve the breakpoint target function.
|
| + const Function& bp_target = Function::Handle(
|
| + isolate->debugger()->ResolveFunction(
|
| + library, class_name, function_name));
|
| + if (bp_target.IsNull()) {
|
| + return Api::Error("Breakpoint target function does not exist");
|
| + }
|
| +
|
| + LongJump* base = isolate->long_jump_base();
|
| + LongJump jump;
|
| + isolate->set_long_jump_base(&jump);
|
| + Dart_Handle result = Api::True();
|
| + if (setjmp(*jump.Set()) == 0) {
|
| + Breakpoint* bpt = isolate->debugger()->SetBreakpointAtEntry(bp_target);
|
| + if (breakpoint != NULL) {
|
| + *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
|
| + }
|
| + } else {
|
| + SetupErrorResult(&result);
|
| + }
|
| + isolate->set_long_jump_base(base);
|
| + return result;
|
| +}
|
| +
|
| +
|
| +} // namespace dart
|
|
|