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

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
« no previous file with comments | « runtime/vm/debugger.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) 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 {
248 return Api::NewError("Can only get stacktraces from error handles or "
249 "instances of Error.");
250 }
251 }
252
253
229 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( 254 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo(
230 Dart_ActivationFrame activation_frame, 255 Dart_ActivationFrame activation_frame,
231 Dart_Handle* function_name, 256 Dart_Handle* function_name,
232 Dart_Handle* script_url, 257 Dart_Handle* script_url,
233 intptr_t* line_number, 258 intptr_t* line_number,
234 intptr_t* library_id) { 259 intptr_t* column_number) {
235 Isolate* isolate = Isolate::Current(); 260 Isolate* isolate = Isolate::Current();
236 DARTSCOPE(isolate); 261 DARTSCOPE(isolate);
237 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); 262 CHECK_AND_CAST(ActivationFrame, frame, activation_frame);
238 if (function_name != NULL) { 263 if (function_name != NULL) {
239 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); 264 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName());
240 } 265 }
241 if (script_url != NULL) { 266 if (script_url != NULL) {
242 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); 267 *script_url = Api::NewHandle(isolate, frame->SourceUrl());
243 } 268 }
244 if (line_number != NULL) { 269 if (line_number != NULL) {
245 *line_number = frame->LineNumber(); 270 *line_number = frame->LineNumber();
246 } 271 }
247 if (library_id != NULL) { 272 if (column_number != NULL) {
248 const Library& lib = Library::Handle(frame->Library()); 273 *column_number = frame->ColumnNumber();
249 *library_id = lib.index();
250 } 274 }
251 return Api::Success(); 275 return Api::Success();
252 } 276 }
253 277
254 278
255 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation( 279 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation(
256 Dart_ActivationFrame activation_frame, 280 Dart_ActivationFrame activation_frame,
257 Dart_Handle* function_name, 281 Dart_Handle* function_name,
258 Dart_Handle* function, 282 Dart_Handle* function,
259 Dart_CodeLocation* location) { 283 Dart_CodeLocation* location) {
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 969
946 970
947 DART_EXPORT char* Dart_GetVmStatus(const char* request) { 971 DART_EXPORT char* Dart_GetVmStatus(const char* request) {
948 if (strncmp(request, "/isolate/", 9) == 0) { 972 if (strncmp(request, "/isolate/", 9) == 0) {
949 return Isolate::GetStatus(request); 973 return Isolate::GetStatus(request);
950 } 974 }
951 return NULL; 975 return NULL;
952 } 976 }
953 977
954 } // namespace dart 978 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698