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

Side by Side Diff: runtime/vm/debugger_api_impl.cc

Issue 9166016: Introduce the Error object class in the vm. It represents all of the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 11 months 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/dart_api_impl_test.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/debugger.h" 9 #include "vm/debugger.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
11 #include "vm/longjump.h" 11 #include "vm/longjump.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \ 15 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \
16 do { \ 16 do { \
17 const Object& tmp = Object::Handle(Api::UnwrapHandle(param)); \ 17 const Object& tmp = Object::Handle(Api::UnwrapHandle(param)); \
18 if (tmp.IsNull()) { \ 18 if (tmp.IsNull()) { \
19 return Api::Error("%s expects argument '%s' to be non-null.", \ 19 return Api::NewError("%s expects argument '%s' to be non-null.", \
20 CURRENT_FUNC, #param); \ 20 CURRENT_FUNC, #param); \
21 } else if (tmp.IsApiError()) { \ 21 } else if (tmp.IsApiError()) { \
22 return param; \ 22 return param; \
23 } else if (!tmp.Is##type()) { \ 23 } else if (!tmp.Is##type()) { \
24 return Api::Error("%s expects argument '%s' to be of type %s.", \ 24 return Api::NewError("%s expects argument '%s' to be of type %s.", \
25 CURRENT_FUNC, #param, #type); \ 25 CURRENT_FUNC, #param, #type); \
26 } \ 26 } \
27 var ^= tmp.raw(); \ 27 var ^= tmp.raw(); \
28 } while (0); 28 } while (0);
29 29
30 30
31 #define CHECK_AND_CAST(type, var, param) \ 31 #define CHECK_AND_CAST(type, var, param) \
32 if (param == NULL) { \ 32 if (param == NULL) { \
33 return Api::Error("%s expects argument '%s' to be non-null.", \ 33 return Api::NewError("%s expects argument '%s' to be non-null.", \
34 CURRENT_FUNC, #param); \ 34 CURRENT_FUNC, #param); \
35 } \ 35 } \
36 type* var = reinterpret_cast<type*>(param); 36 type* var = reinterpret_cast<type*>(param);
37 37
38 38
39 #define CHECK_NOT_NULL(param) \ 39 #define CHECK_NOT_NULL(param) \
40 if (param == NULL) { \ 40 if (param == NULL) { \
41 return Api::Error("%s expects argument '%s' to be non-null.", \ 41 return Api::NewError("%s expects argument '%s' to be non-null.", \
42 CURRENT_FUNC, #param); \ 42 CURRENT_FUNC, #param); \
43 } 43 }
44 44
45 45
46 DART_EXPORT Dart_Handle Dart_StackTraceLength( 46 DART_EXPORT Dart_Handle Dart_StackTraceLength(
47 Dart_StackTrace trace, 47 Dart_StackTrace trace,
48 intptr_t* length) { 48 intptr_t* length) {
49 Isolate* isolate = Isolate::Current(); 49 Isolate* isolate = Isolate::Current();
50 DARTSCOPE(isolate); 50 DARTSCOPE(isolate);
51 CHECK_NOT_NULL(length); 51 CHECK_NOT_NULL(length);
52 CHECK_AND_CAST(StackTrace, stack_trace, trace); 52 CHECK_AND_CAST(StackTrace, stack_trace, trace);
53 *length = stack_trace->Length(); 53 *length = stack_trace->Length();
54 return Api::True(); 54 return Api::True();
55 } 55 }
56 56
57 57
58 DART_EXPORT Dart_Handle Dart_GetActivationFrame( 58 DART_EXPORT Dart_Handle Dart_GetActivationFrame(
59 Dart_StackTrace trace, 59 Dart_StackTrace trace,
60 int frame_index, 60 int frame_index,
61 Dart_ActivationFrame* frame) { 61 Dart_ActivationFrame* frame) {
62 Isolate* isolate = Isolate::Current(); 62 Isolate* isolate = Isolate::Current();
63 DARTSCOPE(isolate); 63 DARTSCOPE(isolate);
64 CHECK_NOT_NULL(frame); 64 CHECK_NOT_NULL(frame);
65 CHECK_AND_CAST(StackTrace, stack_trace, trace); 65 CHECK_AND_CAST(StackTrace, stack_trace, trace);
66 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) { 66 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) {
67 return Api::Error("argument 'frame_index' is out of range for %s", 67 return Api::NewError("argument 'frame_index' is out of range for %s",
68 CURRENT_FUNC); 68 CURRENT_FUNC);
69 } 69 }
70 *frame = reinterpret_cast<Dart_ActivationFrame>( 70 *frame = reinterpret_cast<Dart_ActivationFrame>(
71 stack_trace->ActivationFrameAt(frame_index)); 71 stack_trace->ActivationFrameAt(frame_index));
72 return Api::True(); 72 return Api::True();
73 } 73 }
74 74
75 75
76 DART_EXPORT void Dart_SetBreakpointHandler( 76 DART_EXPORT void Dart_SetBreakpointHandler(
77 Dart_BreakpointHandler bp_handler) { 77 Dart_BreakpointHandler bp_handler) {
78 Isolate* isolate = Isolate::Current(); 78 Isolate* isolate = Isolate::Current();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 Library& library = Library::Handle(); 118 Library& library = Library::Handle();
119 String& class_name = String::Handle(); 119 String& class_name = String::Handle();
120 String& function_name = String::Handle(); 120 String& function_name = String::Handle();
121 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); 121 UNWRAP_AND_CHECK_PARAM(Library, library, library_in);
122 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); 122 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in);
123 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); 123 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in);
124 CHECK_NOT_NULL(breakpoint); 124 CHECK_NOT_NULL(breakpoint);
125 125
126 const char* msg = CheckIsolateState(isolate); 126 const char* msg = CheckIsolateState(isolate);
127 if (msg != NULL) { 127 if (msg != NULL) {
128 return Api::Error(msg); 128 return Api::NewError(msg);
129 } 129 }
130 130
131 // Resolve the breakpoint target function. 131 // Resolve the breakpoint target function.
132 Debugger* debugger = isolate->debugger(); 132 Debugger* debugger = isolate->debugger();
133 const Function& bp_target = Function::Handle( 133 const Function& bp_target = Function::Handle(
134 debugger->ResolveFunction(library, class_name, function_name)); 134 debugger->ResolveFunction(library, class_name, function_name));
135 if (bp_target.IsNull()) { 135 if (bp_target.IsNull()) {
136 const bool toplevel = class_name.Length() == 0; 136 const bool toplevel = class_name.Length() == 0;
137 return Api::Error("%s: could not find function '%s%s%s'", 137 return Api::NewError("%s: could not find function '%s%s%s'",
138 CURRENT_FUNC, 138 CURRENT_FUNC,
139 toplevel ? "" : class_name.ToCString(), 139 toplevel ? "" : class_name.ToCString(),
140 toplevel ? "" : ".", 140 toplevel ? "" : ".",
141 function_name.ToCString()); 141 function_name.ToCString());
142 } 142 }
143 143
144 LongJump* base = isolate->long_jump_base(); 144 LongJump* base = isolate->long_jump_base();
145 LongJump jump; 145 LongJump jump;
146 isolate->set_long_jump_base(&jump); 146 isolate->set_long_jump_base(&jump);
147 Dart_Handle result = Api::True(); 147 Dart_Handle result = Api::True();
148 *breakpoint = NULL; 148 *breakpoint = NULL;
149 if (setjmp(*jump.Set()) == 0) { 149 if (setjmp(*jump.Set()) == 0) {
150 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target); 150 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target);
151 if (bpt == NULL) { 151 if (bpt == NULL) {
152 const char* target_name = Debugger::QualifiedFunctionName(bp_target); 152 const char* target_name = Debugger::QualifiedFunctionName(bp_target);
153 result = Api::Error("%s: no breakpoint location found in '%s'", 153 result = Api::NewError("%s: no breakpoint location found in '%s'",
154 CURRENT_FUNC, target_name); 154 CURRENT_FUNC, target_name);
155 } else { 155 } else {
156 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); 156 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
157 } 157 }
158 } else { 158 } else {
159 SetupErrorResult(&result); 159 SetupErrorResult(&result);
160 } 160 }
161 isolate->set_long_jump_base(base); 161 isolate->set_long_jump_base(base);
162 return result; 162 return result;
163 } 163 }
164 164
165 165
166 } // namespace dart 166 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698