OLD | NEW |
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 "vm/exceptions.h" | 5 #include "vm/exceptions.h" |
6 | 6 |
7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 // dart invocation sequence above it, print diagnostics and terminate | 358 // dart invocation sequence above it, print diagnostics and terminate |
359 // the isolate etc.). | 359 // the isolate etc.). |
360 const UnhandledException& unhandled_exception = UnhandledException::Handle( | 360 const UnhandledException& unhandled_exception = UnhandledException::Handle( |
361 UnhandledException::New(exception, stacktrace)); | 361 UnhandledException::New(exception, stacktrace)); |
362 JumpToErrorHandler(handler_pc, handler_sp, handler_fp, unhandled_exception); | 362 JumpToErrorHandler(handler_pc, handler_sp, handler_fp, unhandled_exception); |
363 } | 363 } |
364 UNREACHABLE(); | 364 UNREACHABLE(); |
365 } | 365 } |
366 | 366 |
367 | 367 |
| 368 const char* Exceptions::CreateStackTrace() { |
| 369 Isolate* isolate = Isolate::Current(); |
| 370 Stacktrace& stacktrace = Stacktrace::Handle(isolate); |
| 371 stacktrace ^= isolate->object_store()->preallocated_stack_trace(); |
| 372 RegularStacktraceBuilder frame_builder; |
| 373 uword handler_pc = 0; |
| 374 uword handler_sp = 0; |
| 375 uword handler_fp = 0; |
| 376 FindExceptionHandler(&handler_pc, |
| 377 &handler_sp, |
| 378 &handler_fp, |
| 379 &frame_builder); |
| 380 const Array& func_array = |
| 381 Array::Handle(isolate, Array::MakeArray(frame_builder.func_list())); |
| 382 const Array& code_array = |
| 383 Array::Handle(isolate, Array::MakeArray(frame_builder.code_list())); |
| 384 const Array& pc_offset_array = |
| 385 Array::Handle(isolate, |
| 386 Array::MakeArray(frame_builder.pc_offset_list())); |
| 387 stacktrace = Stacktrace::New(func_array, code_array, pc_offset_array); |
| 388 return stacktrace.ToCString(); |
| 389 } |
| 390 |
| 391 |
368 // Static helpers for allocating, initializing, and throwing an error instance. | 392 // Static helpers for allocating, initializing, and throwing an error instance. |
369 | 393 |
370 // Return the script of the Dart function that called the native entry or the | 394 // Return the script of the Dart function that called the native entry or the |
371 // runtime entry. The frame iterator points to the callee. | 395 // runtime entry. The frame iterator points to the callee. |
372 RawScript* Exceptions::GetCallerScript(DartFrameIterator* iterator) { | 396 RawScript* Exceptions::GetCallerScript(DartFrameIterator* iterator) { |
373 StackFrame* caller_frame = iterator->NextFrame(); | 397 StackFrame* caller_frame = iterator->NextFrame(); |
374 ASSERT(caller_frame != NULL && caller_frame->IsDartFrame()); | 398 ASSERT(caller_frame != NULL && caller_frame->IsDartFrame()); |
375 const Function& caller = Function::Handle(caller_frame->LookupDartFunction()); | 399 const Function& caller = Function::Handle(caller_frame->LookupDartFunction()); |
376 ASSERT(!caller.IsNull()); | 400 ASSERT(!caller.IsNull()); |
377 return caller.script(); | 401 return caller.script(); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 break; | 621 break; |
598 } | 622 } |
599 | 623 |
600 return DartLibraryCalls::ExceptionCreate(library, | 624 return DartLibraryCalls::ExceptionCreate(library, |
601 *class_name, | 625 *class_name, |
602 *constructor_name, | 626 *constructor_name, |
603 arguments); | 627 arguments); |
604 } | 628 } |
605 | 629 |
606 } // namespace dart | 630 } // namespace dart |
OLD | NEW |