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 "platform/address_sanitizer.h" | 7 #include "platform/address_sanitizer.h" |
8 | 8 |
| 9 #include "lib/stacktrace.h" |
| 10 |
9 #include "vm/dart_api_impl.h" | 11 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
11 #include "vm/debugger.h" | 13 #include "vm/debugger.h" |
12 #include "vm/flags.h" | 14 #include "vm/flags.h" |
13 #include "vm/log.h" | 15 #include "vm/log.h" |
14 #include "vm/longjump.h" | 16 #include "vm/longjump.h" |
15 #include "vm/object.h" | 17 #include "vm/object.h" |
16 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
17 #include "vm/stack_frame.h" | 19 #include "vm/stack_frame.h" |
18 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
19 #include "vm/symbols.h" | 21 #include "vm/symbols.h" |
20 #include "vm/tags.h" | 22 #include "vm/tags.h" |
21 | 23 |
| 24 |
22 namespace dart { | 25 namespace dart { |
23 | 26 |
24 DECLARE_FLAG(bool, trace_deoptimization); | 27 DECLARE_FLAG(bool, trace_deoptimization); |
25 DEFINE_FLAG(bool, | 28 DEFINE_FLAG(bool, |
26 print_stacktrace_at_throw, | 29 print_stacktrace_at_throw, |
27 false, | 30 false, |
28 "Prints a stack trace everytime a throw occurs."); | 31 "Prints a stack trace everytime a throw occurs."); |
29 | 32 |
30 | 33 |
31 class StackTraceBuilder : public ValueObject { | 34 class StackTraceBuilder : public ValueObject { |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 type = test_class.super_type(); | 365 type = test_class.super_type(); |
363 if (type.IsNull()) return Field::null(); | 366 if (type.IsNull()) return Field::null(); |
364 test_class = type.type_class(); | 367 test_class = type.type_class(); |
365 } | 368 } |
366 UNREACHABLE(); | 369 UNREACHABLE(); |
367 return Field::null(); | 370 return Field::null(); |
368 } | 371 } |
369 | 372 |
370 | 373 |
371 RawStackTrace* Exceptions::CurrentStackTrace() { | 374 RawStackTrace* Exceptions::CurrentStackTrace() { |
372 Zone* zone = Thread::Current()->zone(); | 375 return GetStackTraceForException(); |
373 RegularStackTraceBuilder frame_builder(zone); | |
374 BuildStackTrace(&frame_builder); | |
375 | |
376 // Create arrays for code and pc_offset tuples of each frame. | |
377 const Array& full_code_array = | |
378 Array::Handle(zone, Array::MakeArray(frame_builder.code_list())); | |
379 const Array& full_pc_offset_array = | |
380 Array::Handle(zone, Array::MakeArray(frame_builder.pc_offset_list())); | |
381 const StackTrace& full_stacktrace = StackTrace::Handle( | |
382 StackTrace::New(full_code_array, full_pc_offset_array)); | |
383 return full_stacktrace.raw(); | |
384 } | 376 } |
385 | 377 |
386 | 378 |
387 static void ThrowExceptionHelper(Thread* thread, | 379 static void ThrowExceptionHelper(Thread* thread, |
388 const Instance& incoming_exception, | 380 const Instance& incoming_exception, |
389 const Instance& existing_stacktrace, | 381 const Instance& existing_stacktrace, |
390 const bool is_rethrow) { | 382 const bool is_rethrow) { |
391 Zone* zone = thread->zone(); | 383 Zone* zone = thread->zone(); |
392 Isolate* isolate = thread->isolate(); | 384 Isolate* isolate = thread->isolate(); |
393 bool use_preallocated_stacktrace = false; | 385 bool use_preallocated_stacktrace = false; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 class_name = &Symbols::_CompileTimeError(); | 805 class_name = &Symbols::_CompileTimeError(); |
814 break; | 806 break; |
815 } | 807 } |
816 | 808 |
817 return DartLibraryCalls::InstanceCreate(library, *class_name, | 809 return DartLibraryCalls::InstanceCreate(library, *class_name, |
818 *constructor_name, arguments); | 810 *constructor_name, arguments); |
819 } | 811 } |
820 | 812 |
821 | 813 |
822 } // namespace dart | 814 } // namespace dart |
OLD | NEW |