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()->UncachedStackTrace()); | |
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/12 16:00:43
Why are you not getting the stack trace correspond
rmacnak
2013/11/12 22:32:40
This matches the behavior of Dart_ErrorGetStacktra
| |
249 } else { | |
250 return Api::NewError("Can only get stacktraces from error handles."); | |
251 } | |
252 } | |
253 | |
254 | |
255 | |
229 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( | 256 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( |
230 Dart_ActivationFrame activation_frame, | 257 Dart_ActivationFrame activation_frame, |
231 Dart_Handle* function_name, | 258 Dart_Handle* function_name, |
232 Dart_Handle* script_url, | 259 Dart_Handle* script_url, |
233 intptr_t* line_number, | 260 intptr_t* line_number, |
234 intptr_t* library_id) { | 261 intptr_t* library_id) { |
235 Isolate* isolate = Isolate::Current(); | 262 Isolate* isolate = Isolate::Current(); |
236 DARTSCOPE(isolate); | 263 DARTSCOPE(isolate); |
237 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 264 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
238 if (function_name != NULL) { | 265 if (function_name != NULL) { |
239 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); | 266 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); |
240 } | 267 } |
241 if (script_url != NULL) { | 268 if (script_url != NULL) { |
242 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); | 269 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); |
243 } | 270 } |
244 if (line_number != NULL) { | 271 if (line_number != NULL) { |
245 *line_number = frame->LineNumber(); | 272 *line_number = frame->LineNumber(); |
246 } | 273 } |
247 if (library_id != NULL) { | 274 if (library_id != NULL) { |
248 const Library& lib = Library::Handle(frame->Library()); | 275 const Library& lib = Library::Handle(frame->Library()); |
249 *library_id = lib.index(); | 276 *library_id = lib.index(); |
250 } | 277 } |
251 return Api::Success(); | 278 return Api::Success(); |
252 } | 279 } |
253 | 280 |
281 DART_EXPORT Dart_Handle Dart_ActivationFrameInfoWithColumn( | |
282 Dart_ActivationFrame activation_frame, | |
283 Dart_Handle* function_name, | |
284 Dart_Handle* script_url, | |
285 intptr_t* line_number, | |
286 intptr_t* column_number) { | |
287 Isolate* isolate = Isolate::Current(); | |
288 DARTSCOPE(isolate); | |
289 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | |
290 if (function_name != NULL) { | |
291 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); | |
292 } | |
293 if (script_url != NULL) { | |
294 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); | |
295 } | |
296 if (line_number != NULL) { | |
297 *line_number = frame->LineNumber(); | |
298 } | |
299 if (column_number != NULL) { | |
300 *column_number = frame->ColumnNumber(); | |
301 } | |
302 return Api::Success(); | |
303 } | |
304 | |
254 | 305 |
255 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation( | 306 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation( |
256 Dart_ActivationFrame activation_frame, | 307 Dart_ActivationFrame activation_frame, |
257 Dart_Handle* function_name, | 308 Dart_Handle* function_name, |
258 Dart_Handle* function, | 309 Dart_Handle* function, |
259 Dart_CodeLocation* location) { | 310 Dart_CodeLocation* location) { |
260 // TODO(hausner): Implement a way to recognize when there | 311 // TODO(hausner): Implement a way to recognize when there |
261 // is no source code for the code in the frame. | 312 // is no source code for the code in the frame. |
262 Isolate* isolate = Isolate::Current(); | 313 Isolate* isolate = Isolate::Current(); |
263 DARTSCOPE(isolate); | 314 DARTSCOPE(isolate); |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
902 | 953 |
903 | 954 |
904 DART_EXPORT char* Dart_GetVmStatus(const char* request) { | 955 DART_EXPORT char* Dart_GetVmStatus(const char* request) { |
905 if (strncmp(request, "/isolate/", 9) == 0) { | 956 if (strncmp(request, "/isolate/", 9) == 0) { |
906 return Isolate::GetStatus(request); | 957 return Isolate::GetStatus(request); |
907 } | 958 } |
908 return NULL; | 959 return NULL; |
909 } | 960 } |
910 | 961 |
911 } // namespace dart | 962 } // namespace dart |
OLD | NEW |