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" |
11 #include "vm/object.h" | 11 #include "vm/object.h" |
12 #include "vm/object_store.h" | 12 #include "vm/object_store.h" |
13 #include "vm/stack_frame.h" | 13 #include "vm/stack_frame.h" |
14 #include "vm/stub_code.h" | 14 #include "vm/stub_code.h" |
15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
16 | 16 |
17 namespace dart { | 17 namespace dart { |
18 | 18 |
19 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, | 19 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, |
20 "Prints a stack trace everytime a throw occurs."); | 20 "Prints a stack trace everytime a throw occurs."); |
21 DEFINE_FLAG(bool, heap_profile_out_of_memory, false, | 21 DEFINE_FLAG(bool, heap_profile_out_of_memory, false, |
22 "Writes a heap profile on unhandled out-of-memory exceptions."); | 22 "Writes a heap profile on unhandled out-of-memory exceptions."); |
| 23 DEFINE_FLAG(bool, verbose_stacktrace, false, |
| 24 "Stack traces will include methods marked invisible."); |
| 25 |
| 26 const char* Exceptions::kCastErrorDstName = "type cast"; |
23 | 27 |
24 | 28 |
25 const char* Exceptions::kCastErrorDstName = "type cast"; | 29 static bool ShouldShowFunction(const Function& function) { |
| 30 if (FLAG_verbose_stacktrace) { |
| 31 return true; |
| 32 } |
| 33 return function.is_visible(); |
| 34 } |
26 | 35 |
27 | 36 |
28 // Iterate through the stack frames and try to find a frame with an | 37 // Iterate through the stack frames and try to find a frame with an |
29 // exception handler. Once found, set the pc, sp and fp so that execution | 38 // exception handler. Once found, set the pc, sp and fp so that execution |
30 // can continue in that frame. | 39 // can continue in that frame. |
31 static bool FindExceptionHandler(uword* handler_pc, | 40 static bool FindExceptionHandler(uword* handler_pc, |
32 uword* handler_sp, | 41 uword* handler_sp, |
33 uword* handler_fp, | 42 uword* handler_fp, |
34 const GrowableObjectArray& func_list, | 43 const GrowableObjectArray& func_list, |
35 const GrowableObjectArray& code_list, | 44 const GrowableObjectArray& code_list, |
(...skipping 13 matching lines...) Expand all Loading... |
49 InlinedFunctionsInDartFrameIterator optimized_frames(frame); | 58 InlinedFunctionsInDartFrameIterator optimized_frames(frame); |
50 while (true) { | 59 while (true) { |
51 uword pc = 0; | 60 uword pc = 0; |
52 func = optimized_frames.GetNextFunction(&pc); | 61 func = optimized_frames.GetNextFunction(&pc); |
53 if (func.IsNull()) { | 62 if (func.IsNull()) { |
54 break; | 63 break; |
55 } | 64 } |
56 ASSERT(pc != 0); | 65 ASSERT(pc != 0); |
57 code = func.unoptimized_code(); | 66 code = func.unoptimized_code(); |
58 offset = Smi::New(pc - code.EntryPoint()); | 67 offset = Smi::New(pc - code.EntryPoint()); |
| 68 if (ShouldShowFunction(func)) { |
| 69 func_list.Add(func); |
| 70 code_list.Add(code); |
| 71 pc_offset_list.Add(offset); |
| 72 } |
| 73 } |
| 74 } else { |
| 75 offset = Smi::New(frame->pc() - code.EntryPoint()); |
| 76 func = code.function(); |
| 77 if (ShouldShowFunction(func)) { |
59 func_list.Add(func); | 78 func_list.Add(func); |
60 code_list.Add(code); | 79 code_list.Add(code); |
61 pc_offset_list.Add(offset); | 80 pc_offset_list.Add(offset); |
62 } | 81 } |
63 } else { | |
64 offset = Smi::New(frame->pc() - code.EntryPoint()); | |
65 func = code.function(); | |
66 func_list.Add(func); | |
67 code_list.Add(code); | |
68 pc_offset_list.Add(offset); | |
69 } | 82 } |
70 if (frame->FindExceptionHandler(handler_pc)) { | 83 if (frame->FindExceptionHandler(handler_pc)) { |
71 *handler_sp = frame->sp(); | 84 *handler_sp = frame->sp(); |
72 *handler_fp = frame->fp(); | 85 *handler_fp = frame->fp(); |
73 return true; | 86 return true; |
74 } | 87 } |
75 } | 88 } |
76 frame = frames.NextFrame(); | 89 frame = frames.NextFrame(); |
77 ASSERT(frame != NULL); | 90 ASSERT(frame != NULL); |
78 } | 91 } |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 case kIsolateUnhandledException: | 477 case kIsolateUnhandledException: |
465 library = Library::IsolateLibrary(); | 478 library = Library::IsolateLibrary(); |
466 class_name = &Symbols::IsolateUnhandledException(); | 479 class_name = &Symbols::IsolateUnhandledException(); |
467 break; | 480 break; |
468 } | 481 } |
469 | 482 |
470 return DartLibraryCalls::ExceptionCreate(library, *class_name, arguments); | 483 return DartLibraryCalls::ExceptionCreate(library, *class_name, arguments); |
471 } | 484 } |
472 | 485 |
473 } // namespace dart | 486 } // namespace dart |
OLD | NEW |