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

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

Issue 51793002: Add an API function to get a debugger stack trace from an error handle. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 Isolate* isolate = Isolate::Current(); 214 Isolate* isolate = Isolate::Current();
215 DARTSCOPE(isolate); 215 DARTSCOPE(isolate);
216 return isolate->debugger()->GetExceptionPauseInfo(); 216 return isolate->debugger()->GetExceptionPauseInfo();
217 } 217 }
218 218
219 219
220 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace) { 220 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace) {
221 Isolate* isolate = Isolate::Current(); 221 Isolate* isolate = Isolate::Current();
222 DARTSCOPE(isolate); 222 DARTSCOPE(isolate);
223 CHECK_NOT_NULL(trace); 223 CHECK_NOT_NULL(trace);
224 *trace = reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); 224 *trace = reinterpret_cast<Dart_StackTrace>(
225 isolate->debugger()->CurrentStackTrace());
225 return Api::Success(); 226 return Api::Success();
226 } 227 }
227 228
228 229
230 DART_EXPORT Dart_Handle Dart_GetStackTraceFromError(Dart_Handle handle,
231 Dart_StackTrace* trace) {
232 Isolate* isolate = Isolate::Current();
233 DARTSCOPE(isolate);
234 CHECK_NOT_NULL(trace);
235 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
236 if (obj.IsUnhandledException()) {
237 const UnhandledException& error = UnhandledException::Cast(obj);
238 Stacktrace& dart_stacktrace = Stacktrace::Handle(isolate);
239 dart_stacktrace ^= error.stacktrace();
240 if (dart_stacktrace.IsNull()) {
241 *trace = NULL;
242 } else {
243 *trace = reinterpret_cast<Dart_StackTrace>(
244 isolate->debugger()->StackTraceFrom(dart_stacktrace));
245 }
246 return Api::Success();
247 } else if (obj.IsError()) {
248 return Api::NewError("This error is not an unhandled exception error.");
249 } else {
250 return Api::NewError("Can only get stacktraces from error handles.");
251 }
252 }
253
254
229 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( 255 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo(
230 Dart_ActivationFrame activation_frame, 256 Dart_ActivationFrame activation_frame,
231 Dart_Handle* function_name, 257 Dart_Handle* function_name,
232 Dart_Handle* script_url, 258 Dart_Handle* script_url,
233 intptr_t* line_number, 259 intptr_t* line_number,
234 intptr_t* library_id) { 260 intptr_t* column_number) {
235 Isolate* isolate = Isolate::Current(); 261 Isolate* isolate = Isolate::Current();
236 DARTSCOPE(isolate); 262 DARTSCOPE(isolate);
237 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); 263 CHECK_AND_CAST(ActivationFrame, frame, activation_frame);
238 if (function_name != NULL) { 264 if (function_name != NULL) {
239 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); 265 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName());
240 } 266 }
241 if (script_url != NULL) { 267 if (script_url != NULL) {
242 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); 268 *script_url = Api::NewHandle(isolate, frame->SourceUrl());
243 } 269 }
244 if (line_number != NULL) { 270 if (line_number != NULL) {
245 *line_number = frame->LineNumber(); 271 *line_number = frame->LineNumber();
246 } 272 }
247 if (library_id != NULL) { 273 if (column_number != NULL) {
248 const Library& lib = Library::Handle(frame->Library()); 274 *column_number = frame->ColumnNumber();
249 *library_id = lib.index();
250 } 275 }
251 return Api::Success(); 276 return Api::Success();
252 } 277 }
253 278
254 279
255 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation( 280 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation(
256 Dart_ActivationFrame activation_frame, 281 Dart_ActivationFrame activation_frame,
257 Dart_Handle* function_name, 282 Dart_Handle* function_name,
258 Dart_Handle* function, 283 Dart_Handle* function,
259 Dart_CodeLocation* location) { 284 Dart_CodeLocation* location) {
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 927
903 928
904 DART_EXPORT char* Dart_GetVmStatus(const char* request) { 929 DART_EXPORT char* Dart_GetVmStatus(const char* request) {
905 if (strncmp(request, "/isolate/", 9) == 0) { 930 if (strncmp(request, "/isolate/", 9) == 0) {
906 return Isolate::GetStatus(request); 931 return Isolate::GetStatus(request);
907 } 932 }
908 return NULL; 933 return NULL;
909 } 934 }
910 935
911 } // namespace dart 936 } // namespace dart
OLDNEW
« runtime/vm/debugger.h ('K') | « runtime/vm/debugger.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698