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

Side by Side Diff: runtime/vm/debugger_api_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_debugger_api.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 namespace dart {
14
15 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \
16 do { \
17 const Object& tmp = Object::Handle(Api::UnwrapHandle(param)); \
18 if (tmp.IsNull()) { \
19 return Api::Error("%s expects argument '%s' to be non-null.", \
20 CURRENT_FUNC, #param); \
21 } else if (tmp.IsApiError()) { \
22 return param; \
23 } else if (!tmp.Is##type()) { \
24 return Api::Error("%s expects argument '%s' to be of type %s.", \
25 CURRENT_FUNC, #param, #type); \
26 } \
27 var ^= tmp.raw(); \
28 } while (0);
29
30
31 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry(
32 Dart_Handle library_in,
33 Dart_Handle class_name_in,
34 Dart_Handle function_name_in,
35 Dart_Breakpoint* breakpoint) {
36 Isolate* isolate = Isolate::Current();
37 DARTSCOPE(isolate);
38
39 Library& library = Library::Handle();
40 String& class_name = String::Handle();
41 String& function_name = String::Handle();
42 UNWRAP_AND_CHECK_PARAM(Library, library, library_in);
43 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in);
44 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in);
45
46 const char* msg = CheckIsolateState(isolate);
47 if (msg != NULL) {
48 return Api::Error(msg);
49 }
50
51 if (breakpoint != NULL) {
52 *breakpoint = NULL;
53 }
54
55 // Resolve the breakpoint target function.
56 Debugger* debugger = isolate->debugger();
57 const Function& bp_target = Function::Handle(
58 debugger->ResolveFunction(library, class_name, function_name));
59 if (bp_target.IsNull()) {
60 return Api::Error("Breakpoint target function does not exist");
61 }
62
63 LongJump* base = isolate->long_jump_base();
64 LongJump jump;
65 isolate->set_long_jump_base(&jump);
66 Dart_Handle result = Api::True();
67 if (setjmp(*jump.Set()) == 0) {
68 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target);
69 if (breakpoint != NULL) {
70 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
71 }
72 } else {
73 SetupErrorResult(&result);
74 }
75 isolate->set_long_jump_base(base);
76 return result;
77 }
78
79
80 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698