| Index: runtime/vm/exceptions.cc
|
| diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc
|
| index 99563bb3d07387c1a577b4e3a47cc668214222ad..3ef19c9b1605ab82cfbe856f98836181415c4d19 100644
|
| --- a/runtime/vm/exceptions.cc
|
| +++ b/runtime/vm/exceptions.cc
|
| @@ -19,6 +19,8 @@
|
|
|
| namespace dart {
|
|
|
| +DEFINE_FLAG(bool, abort_on_assertion_errors, false,
|
| + "Abort on assertion and typecheck failures");
|
| DEFINE_FLAG(bool, print_stacktrace_at_throw, false,
|
| "Prints a stack trace everytime a throw occurs.");
|
|
|
| @@ -457,7 +459,7 @@ void Exceptions::CreateAndThrowTypeError(intptr_t location,
|
|
|
| // Type errors in the core library may be difficult to diagnose.
|
| // Print type error information before throwing the error when debugging.
|
| - if (FLAG_print_stacktrace_at_throw) {
|
| + if (FLAG_print_stacktrace_at_throw || FLAG_abort_on_assertion_errors) {
|
| if (!error_msg.IsNull()) {
|
| OS::Print("%s\n", error_msg.ToCString());
|
| }
|
| @@ -472,6 +474,11 @@ void Exceptions::CreateAndThrowTypeError(intptr_t location,
|
| OS::Print("type error.\n");
|
| }
|
| }
|
| +
|
| + if (FLAG_abort_on_assertion_errors) {
|
| + PrintStackTraceAndAbort("a type error");
|
| + }
|
| +
|
| // Throw TypeError or CastError instance.
|
| Exceptions::ThrowByType(exception_type, args);
|
| UNREACHABLE();
|
| @@ -677,4 +684,14 @@ void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) {
|
| Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args);
|
| }
|
|
|
| +
|
| +void Exceptions::PrintStackTraceAndAbort(const char* reason) {
|
| + const Instance& stacktrace = Instance::Handle(CurrentStacktrace());
|
| +
|
| + OS::PrintErr("\n\n\nAborting due to %s. Stacktrace:\n%s\n",
|
| + reason,
|
| + stacktrace.ToCString());
|
| + OS::Abort();
|
| +}
|
| +
|
| } // namespace dart
|
|
|