| 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" |
| 8 |
| 7 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| 9 #include "vm/debugger.h" | 11 #include "vm/debugger.h" |
| 10 #include "vm/flags.h" | 12 #include "vm/flags.h" |
| 11 #include "vm/object.h" | 13 #include "vm/object.h" |
| 12 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 13 #include "vm/stack_frame.h" | 15 #include "vm/stack_frame.h" |
| 14 #include "vm/stub_code.h" | 16 #include "vm/stub_code.h" |
| 15 #include "vm/symbols.h" | 17 #include "vm/symbols.h" |
| 16 #include "vm/tags.h" | 18 #include "vm/tags.h" |
| 17 | 19 |
| 18 // Allow the use of ASan (AddressSanitizer). This is needed as ASan needs to be | |
| 19 // told about areas where the VM does the equivalent of a long-jump. | |
| 20 #if defined(__has_feature) | |
| 21 #if __has_feature(address_sanitizer) | |
| 22 extern "C" void __asan_unpoison_memory_region(void *, size_t); | |
| 23 #else // __has_feature(address_sanitizer) | |
| 24 void __asan_unpoison_memory_region(void* ignore1, size_t ignore2) {} | |
| 25 #endif // __has_feature(address_sanitizer) | |
| 26 #else // defined(__has_feature) | |
| 27 void __asan_unpoison_memory_region(void* ignore1, size_t ignore2) {} | |
| 28 #endif // defined(__has_feature) | |
| 29 | |
| 30 | |
| 31 namespace dart { | 20 namespace dart { |
| 32 | 21 |
| 33 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, | 22 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, |
| 34 "Prints a stack trace everytime a throw occurs."); | 23 "Prints a stack trace everytime a throw occurs."); |
| 35 DEFINE_FLAG(bool, verbose_stacktrace, false, | 24 DEFINE_FLAG(bool, verbose_stacktrace, false, |
| 36 "Stack traces will include methods marked invisible."); | 25 "Stack traces will include methods marked invisible."); |
| 37 | 26 |
| 38 | 27 |
| 39 const char* Exceptions::kCastErrorDstName = "type cast"; | 28 const char* Exceptions::kCastErrorDstName = "type cast"; |
| 40 | 29 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // Call a stub to set up the exception object in kExceptionObjectReg, | 292 // Call a stub to set up the exception object in kExceptionObjectReg, |
| 304 // to set up the stacktrace object in kStackTraceObjectReg, and to | 293 // to set up the stacktrace object in kStackTraceObjectReg, and to |
| 305 // continue execution at the given pc in the given frame. | 294 // continue execution at the given pc in the given frame. |
| 306 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*, | 295 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*, |
| 307 Isolate*); | 296 Isolate*); |
| 308 ExcpHandler func = reinterpret_cast<ExcpHandler>( | 297 ExcpHandler func = reinterpret_cast<ExcpHandler>( |
| 309 StubCode::JumpToExceptionHandlerEntryPoint()); | 298 StubCode::JumpToExceptionHandlerEntryPoint()); |
| 310 | 299 |
| 311 // Unpoison the stack before we tear it down in the generated stub code. | 300 // Unpoison the stack before we tear it down in the generated stub code. |
| 312 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; | 301 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; |
| 313 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp), | 302 ASAN_UNPOISON(reinterpret_cast<void*>(current_sp), |
| 314 stack_pointer - current_sp); | 303 stack_pointer - current_sp); |
| 315 | 304 |
| 316 func(program_counter, stack_pointer, frame_pointer, | 305 func(program_counter, stack_pointer, frame_pointer, |
| 317 raw_exception, raw_stacktrace, isolate); | 306 raw_exception, raw_stacktrace, isolate); |
| 318 #endif | 307 #endif |
| 319 UNREACHABLE(); | 308 UNREACHABLE(); |
| 320 } | 309 } |
| 321 | 310 |
| 322 | 311 |
| 323 static RawField* LookupStacktraceField(const Instance& instance) { | 312 static RawField* LookupStacktraceField(const Instance& instance) { |
| 324 if (instance.GetClassId() < kNumPredefinedCids) { | 313 if (instance.GetClassId() < kNumPredefinedCids) { |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 | 760 |
| 772 // Throw JavascriptCompatibilityError exception. | 761 // Throw JavascriptCompatibilityError exception. |
| 773 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { | 762 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { |
| 774 const Array& exc_args = Array::Handle(Array::New(1)); | 763 const Array& exc_args = Array::Handle(Array::New(1)); |
| 775 const String& msg_str = String::Handle(String::New(msg)); | 764 const String& msg_str = String::Handle(String::New(msg)); |
| 776 exc_args.SetAt(0, msg_str); | 765 exc_args.SetAt(0, msg_str); |
| 777 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); | 766 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); |
| 778 } | 767 } |
| 779 | 768 |
| 780 } // namespace dart | 769 } // namespace dart |
| OLD | NEW |