Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(751)

Unified Diff: runtime/vm/dart_dapi_impl.cc

Issue 8826007: First bits of external debugger API (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« runtime/bin/bin.gypi ('K') | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698