OLD | NEW |
---|---|
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 Loading... | |
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."); | |
siva
2013/11/15 23:03:28
We should probably just have
if (obj.IsError()) {
| |
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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 | 970 |
946 | 971 |
947 DART_EXPORT char* Dart_GetVmStatus(const char* request) { | 972 DART_EXPORT char* Dart_GetVmStatus(const char* request) { |
948 if (strncmp(request, "/isolate/", 9) == 0) { | 973 if (strncmp(request, "/isolate/", 9) == 0) { |
949 return Isolate::GetStatus(request); | 974 return Isolate::GetStatus(request); |
950 } | 975 } |
951 return NULL; | 976 return NULL; |
952 } | 977 } |
953 | 978 |
954 } // namespace dart | 979 } // namespace dart |
OLD | NEW |