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 13 matching lines...) Expand all Loading... |
24 #endif // __has_feature(address_sanitizer) | 24 #endif // __has_feature(address_sanitizer) |
25 #else // defined(__has_feature) | 25 #else // defined(__has_feature) |
26 void __asan_unpoison_memory_region(void* ignore1, size_t ignore2) {} | 26 void __asan_unpoison_memory_region(void* ignore1, size_t ignore2) {} |
27 #endif // defined(__has_feature) | 27 #endif // defined(__has_feature) |
28 | 28 |
29 | 29 |
30 namespace dart { | 30 namespace dart { |
31 | 31 |
32 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, | 32 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, |
33 "Prints a stack trace everytime a throw occurs."); | 33 "Prints a stack trace everytime a throw occurs."); |
34 DEFINE_FLAG(bool, heap_profile_out_of_memory, false, | |
35 "Writes a heap profile on unhandled out-of-memory exceptions."); | |
36 DEFINE_FLAG(bool, verbose_stacktrace, false, | 34 DEFINE_FLAG(bool, verbose_stacktrace, false, |
37 "Stack traces will include methods marked invisible."); | 35 "Stack traces will include methods marked invisible."); |
38 | 36 |
39 const char* Exceptions::kCastErrorDstName = "type cast"; | 37 const char* Exceptions::kCastErrorDstName = "type cast"; |
40 | 38 |
41 | 39 |
42 class StacktraceBuilder : public ValueObject { | 40 class StacktraceBuilder : public ValueObject { |
43 public: | 41 public: |
44 StacktraceBuilder() { } | 42 StacktraceBuilder() { } |
45 virtual ~StacktraceBuilder() { } | 43 virtual ~StacktraceBuilder() { } |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 OS::Print("%s\n", stacktrace.ToCString()); | 439 OS::Print("%s\n", stacktrace.ToCString()); |
442 } | 440 } |
443 if (handler_exists) { | 441 if (handler_exists) { |
444 // Found a dart handler for the exception, jump to it. | 442 // Found a dart handler for the exception, jump to it. |
445 JumpToExceptionHandler(handler_pc, | 443 JumpToExceptionHandler(handler_pc, |
446 handler_sp, | 444 handler_sp, |
447 handler_fp, | 445 handler_fp, |
448 exception, | 446 exception, |
449 stacktrace); | 447 stacktrace); |
450 } else { | 448 } else { |
451 if (FLAG_heap_profile_out_of_memory) { | |
452 if (exception.raw() == isolate->object_store()->out_of_memory()) { | |
453 isolate->heap()->ProfileToFile("out-of-memory"); | |
454 } | |
455 } | |
456 // No dart exception handler found in this invocation sequence, | 449 // No dart exception handler found in this invocation sequence, |
457 // so we create an unhandled exception object and return to the | 450 // so we create an unhandled exception object and return to the |
458 // invocation stub so that it returns this unhandled exception | 451 // invocation stub so that it returns this unhandled exception |
459 // object. The C++ code which invoked this dart sequence can check | 452 // object. The C++ code which invoked this dart sequence can check |
460 // and do the appropriate thing (rethrow the exception to the | 453 // and do the appropriate thing (rethrow the exception to the |
461 // dart invocation sequence above it, print diagnostics and terminate | 454 // dart invocation sequence above it, print diagnostics and terminate |
462 // the isolate etc.). | 455 // the isolate etc.). |
463 const UnhandledException& unhandled_exception = UnhandledException::Handle( | 456 const UnhandledException& unhandled_exception = UnhandledException::Handle( |
464 UnhandledException::New(exception, stacktrace)); | 457 UnhandledException::New(exception, stacktrace)); |
465 stacktrace = Stacktrace::null(); | 458 stacktrace = Stacktrace::null(); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 break; | 706 break; |
714 } | 707 } |
715 | 708 |
716 return DartLibraryCalls::InstanceCreate(library, | 709 return DartLibraryCalls::InstanceCreate(library, |
717 *class_name, | 710 *class_name, |
718 *constructor_name, | 711 *constructor_name, |
719 arguments); | 712 arguments); |
720 } | 713 } |
721 | 714 |
722 } // namespace dart | 715 } // namespace dart |
OLD | NEW |