Chromium Code Reviews| 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 | 23 DEFINE_FLAG(bool, verbose_stacktrace, false, |
| 24 "Includes also core-lib's private methods"); | |
|
siva
2013/01/19 01:12:13
Should this be limited to just the core lib or all
| |
| 24 | 25 |
| 25 const char* Exceptions::kCastErrorDstName = "type cast"; | 26 const char* Exceptions::kCastErrorDstName = "type cast"; |
| 26 | 27 |
| 28 static bool ShouldShowFunction(const Function& func) { | |
| 29 if (FLAG_verbose_stacktrace) return true; | |
| 30 const Class& owner = Class::Handle(func.Owner()); | |
| 31 if (owner.library() != Library::CoreLibrary()) return true; | |
| 32 // Check if function is private, hide it if so. | |
| 33 const String& name = String::Handle(func.name()); | |
| 34 for (intptr_t i = 0; i < name.Length(); i++) { | |
| 35 if (name.CharAt(i) == Scanner::kPrivateKeySeparator) { | |
| 36 return false; | |
| 37 } | |
| 38 } | |
|
siva
2013/01/19 01:12:13
We should probably pull this code into a helper me
| |
| 39 return true; | |
| 40 } | |
| 41 | |
| 27 | 42 |
| 28 // Iterate through the stack frames and try to find a frame with an | 43 // 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 | 44 // exception handler. Once found, set the pc, sp and fp so that execution |
| 30 // can continue in that frame. | 45 // can continue in that frame. |
| 31 static bool FindExceptionHandler(uword* handler_pc, | 46 static bool FindExceptionHandler(uword* handler_pc, |
| 32 uword* handler_sp, | 47 uword* handler_sp, |
| 33 uword* handler_fp, | 48 uword* handler_fp, |
| 34 const GrowableObjectArray& func_list, | 49 const GrowableObjectArray& func_list, |
| 35 const GrowableObjectArray& code_list, | 50 const GrowableObjectArray& code_list, |
| 36 const GrowableObjectArray& pc_offset_list) { | 51 const GrowableObjectArray& pc_offset_list) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 49 InlinedFunctionsInDartFrameIterator optimized_frames(frame); | 64 InlinedFunctionsInDartFrameIterator optimized_frames(frame); |
| 50 while (true) { | 65 while (true) { |
| 51 uword pc = 0; | 66 uword pc = 0; |
| 52 func = optimized_frames.GetNextFunction(&pc); | 67 func = optimized_frames.GetNextFunction(&pc); |
| 53 if (func.IsNull()) { | 68 if (func.IsNull()) { |
| 54 break; | 69 break; |
| 55 } | 70 } |
| 56 ASSERT(pc != 0); | 71 ASSERT(pc != 0); |
| 57 code = func.unoptimized_code(); | 72 code = func.unoptimized_code(); |
| 58 offset = Smi::New(pc - code.EntryPoint()); | 73 offset = Smi::New(pc - code.EntryPoint()); |
| 74 if (ShouldShowFunction(func)) { | |
| 75 func_list.Add(func); | |
| 76 code_list.Add(code); | |
| 77 pc_offset_list.Add(offset); | |
| 78 } | |
| 79 } | |
| 80 } else { | |
| 81 offset = Smi::New(frame->pc() - code.EntryPoint()); | |
| 82 func = code.function(); | |
| 83 if (ShouldShowFunction(func)) { | |
| 59 func_list.Add(func); | 84 func_list.Add(func); |
| 60 code_list.Add(code); | 85 code_list.Add(code); |
| 61 pc_offset_list.Add(offset); | 86 pc_offset_list.Add(offset); |
| 62 } | 87 } |
| 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 } | 88 } |
| 70 if (frame->FindExceptionHandler(handler_pc)) { | 89 if (frame->FindExceptionHandler(handler_pc)) { |
| 71 *handler_sp = frame->sp(); | 90 *handler_sp = frame->sp(); |
| 72 *handler_fp = frame->fp(); | 91 *handler_fp = frame->fp(); |
| 73 return true; | 92 return true; |
| 74 } | 93 } |
| 75 } | 94 } |
| 76 frame = frames.NextFrame(); | 95 frame = frames.NextFrame(); |
| 77 ASSERT(frame != NULL); | 96 ASSERT(frame != NULL); |
| 78 } | 97 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 case kIsolateUnhandledException: | 483 case kIsolateUnhandledException: |
| 465 library = Library::IsolateLibrary(); | 484 library = Library::IsolateLibrary(); |
| 466 class_name = &Symbols::IsolateUnhandledException(); | 485 class_name = &Symbols::IsolateUnhandledException(); |
| 467 break; | 486 break; |
| 468 } | 487 } |
| 469 | 488 |
| 470 return DartLibraryCalls::ExceptionCreate(library, *class_name, arguments); | 489 return DartLibraryCalls::ExceptionCreate(library, *class_name, arguments); |
| 471 } | 490 } |
| 472 | 491 |
| 473 } // namespace dart | 492 } // namespace dart |
| OLD | NEW |