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

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

Issue 9316071: Dart_PropagateError, take 2. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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/debugger.cc ('k') | runtime/vm/exceptions.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"
12 #include "vm/object_store.h" 11 #include "vm/object_store.h"
13 12
14 namespace dart { 13 namespace dart {
15 14
16 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \ 15 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \
17 do { \ 16 do { \
18 const Object& tmp = Object::Handle(Api::UnwrapHandle(param)); \ 17 const Object& tmp = Object::Handle(Api::UnwrapHandle(param)); \
19 if (tmp.IsNull()) { \ 18 if (tmp.IsNull()) { \
20 return Api::NewError("%s expects argument '%s' to be non-null.", \ 19 return Api::NewError("%s expects argument '%s' to be non-null.", \
21 CURRENT_FUNC, #param); \ 20 CURRENT_FUNC, #param); \
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (!line_number.IsSmi()) { 133 if (!line_number.IsSmi()) {
135 return Api::NewError("%s: line number out of range", CURRENT_FUNC); 134 return Api::NewError("%s: line number out of range", CURRENT_FUNC);
136 } 135 }
137 intptr_t line = line_number.AsInt64Value(); 136 intptr_t line = line_number.AsInt64Value();
138 137
139 const char* msg = CheckIsolateState(isolate); 138 const char* msg = CheckIsolateState(isolate);
140 if (msg != NULL) { 139 if (msg != NULL) {
141 return Api::NewError(msg); 140 return Api::NewError(msg);
142 } 141 }
143 142
144 LongJump* base = isolate->long_jump_base();
145 LongJump jump;
146 isolate->set_long_jump_base(&jump);
147 Dart_Handle result = Api::True(); 143 Dart_Handle result = Api::True();
148 *breakpoint = NULL; 144 *breakpoint = NULL;
149 Debugger* debugger = isolate->debugger(); 145 Debugger* debugger = isolate->debugger();
150 ASSERT(debugger != NULL); 146 ASSERT(debugger != NULL);
151 if (setjmp(*jump.Set()) == 0) { 147 Error& error = Error::Handle();
152 Breakpoint* bpt = debugger->SetBreakpointAtLine(script_url, line); 148 Breakpoint* bpt = debugger->SetBreakpointAtLine(script_url, line, &error);
153 if (bpt == NULL) { 149 if (bpt == NULL) {
150 if (!error.IsNull()) {
151 // If SetBreakpointAtLine provided an error message, use it.
152 result = Api::NewLocalHandle(error);
153 } else {
154 result = Api::NewError("%s: could not set breakpoint at line %d of '%s'", 154 result = Api::NewError("%s: could not set breakpoint at line %d of '%s'",
155 CURRENT_FUNC, line, script_url.ToCString()); 155 CURRENT_FUNC, line, script_url.ToCString());
156 } else {
157 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
158 } 156 }
159 } else { 157 } else {
160 SetupErrorResult(&result); 158 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
161 } 159 }
162 isolate->set_long_jump_base(base);
163 return result; 160 return result;
164 } 161 }
165 162
166 163
167 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( 164 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry(
168 Dart_Handle library_in, 165 Dart_Handle library_in,
169 Dart_Handle class_name_in, 166 Dart_Handle class_name_in,
170 Dart_Handle function_name_in, 167 Dart_Handle function_name_in,
171 Dart_Breakpoint* breakpoint) { 168 Dart_Breakpoint* breakpoint) {
172 Isolate* isolate = Isolate::Current(); 169 Isolate* isolate = Isolate::Current();
(...skipping 18 matching lines...) Expand all
191 debugger->ResolveFunction(library, class_name, function_name)); 188 debugger->ResolveFunction(library, class_name, function_name));
192 if (bp_target.IsNull()) { 189 if (bp_target.IsNull()) {
193 const bool toplevel = class_name.Length() == 0; 190 const bool toplevel = class_name.Length() == 0;
194 return Api::NewError("%s: could not find function '%s%s%s'", 191 return Api::NewError("%s: could not find function '%s%s%s'",
195 CURRENT_FUNC, 192 CURRENT_FUNC,
196 toplevel ? "" : class_name.ToCString(), 193 toplevel ? "" : class_name.ToCString(),
197 toplevel ? "" : ".", 194 toplevel ? "" : ".",
198 function_name.ToCString()); 195 function_name.ToCString());
199 } 196 }
200 197
201 LongJump* base = isolate->long_jump_base();
202 LongJump jump;
203 isolate->set_long_jump_base(&jump);
204 Dart_Handle result = Api::True(); 198 Dart_Handle result = Api::True();
205 *breakpoint = NULL; 199 *breakpoint = NULL;
206 if (setjmp(*jump.Set()) == 0) { 200
207 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target); 201 Error& error = Error::Handle();
208 if (bpt == NULL) { 202 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target, &error);
209 const char* target_name = Debugger::QualifiedFunctionName(bp_target); 203 if (!error.IsNull()) {
210 result = Api::NewError("%s: no breakpoint location found in '%s'", 204 return Api::NewLocalHandle(error);
205 }
206 if (bpt == NULL) {
207 const char* target_name = Debugger::QualifiedFunctionName(bp_target);
208 result = Api::NewError("%s: no breakpoint location found in '%s'",
211 CURRENT_FUNC, target_name); 209 CURRENT_FUNC, target_name);
212 } else {
213 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
214 }
215 } else { 210 } else {
216 SetupErrorResult(&result); 211 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
217 } 212 }
218 isolate->set_long_jump_base(base);
219 return result; 213 return result;
220 } 214 }
221 215
222 216
223 DART_EXPORT Dart_Handle Dart_DeleteBreakpoint( 217 DART_EXPORT Dart_Handle Dart_DeleteBreakpoint(
224 Dart_Breakpoint breakpoint_in) { 218 Dart_Breakpoint breakpoint_in) {
225 Isolate* isolate = Isolate::Current(); 219 Isolate* isolate = Isolate::Current();
226 DARTSCOPE(isolate); 220 DARTSCOPE(isolate);
227 221
228 CHECK_AND_CAST(Breakpoint, breakpoint, breakpoint_in); 222 CHECK_AND_CAST(Breakpoint, breakpoint, breakpoint_in);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 for (int i = 0; i < num_libs; i++) { 342 for (int i = 0; i < num_libs; i++) {
349 ASSERT(!lib.IsNull()); 343 ASSERT(!lib.IsNull());
350 lib_url = lib.url(); 344 lib_url = lib.url();
351 library_list.SetAt(i, lib_url); 345 library_list.SetAt(i, lib_url);
352 lib = lib.next_registered(); 346 lib = lib.next_registered();
353 } 347 }
354 return Api::NewLocalHandle(library_list); 348 return Api::NewLocalHandle(library_list);
355 } 349 }
356 350
357 } // namespace dart 351 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/exceptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698