Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: runtime/vm/exceptions.cc

Issue 1691443002: Make --abort_on_assertion_errors more selective. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 7 #include "platform/address_sanitizer.h"
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
11 #include "vm/debugger.h" 11 #include "vm/debugger.h"
12 #include "vm/flags.h" 12 #include "vm/flags.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/stack_frame.h" 15 #include "vm/stack_frame.h"
16 #include "vm/stub_code.h" 16 #include "vm/stub_code.h"
17 #include "vm/symbols.h" 17 #include "vm/symbols.h"
18 #include "vm/tags.h" 18 #include "vm/tags.h"
19 19
20 namespace dart { 20 namespace dart {
21 21
22 // TODO(vegorov): Remove --abort_on_assertion_errors flag and associated
23 // infrastructure (dartbug.com/25753)
22 DEFINE_FLAG(bool, abort_on_assertion_errors, false, 24 DEFINE_FLAG(bool, abort_on_assertion_errors, false,
23 "Abort on assertion and typecheck failures"); 25 "Abort on assertion and typecheck failures");
24 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, 26 DEFINE_FLAG(bool, print_stacktrace_at_throw, false,
25 "Prints a stack trace everytime a throw occurs."); 27 "Prints a stack trace everytime a throw occurs.");
26 28
27 29
28 const char* Exceptions::kCastErrorDstName = "type cast"; 30 const char* Exceptions::kCastErrorDstName = "type cast";
29 31
30 32
31 class StacktraceBuilder : public ValueObject { 33 class StacktraceBuilder : public ValueObject {
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 682
681 // Throw JavascriptCompatibilityError exception. 683 // Throw JavascriptCompatibilityError exception.
682 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { 684 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) {
683 const Array& exc_args = Array::Handle(Array::New(1)); 685 const Array& exc_args = Array::Handle(Array::New(1));
684 const String& msg_str = String::Handle(String::New(msg)); 686 const String& msg_str = String::Handle(String::New(msg));
685 exc_args.SetAt(0, msg_str); 687 exc_args.SetAt(0, msg_str);
686 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); 688 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args);
687 } 689 }
688 690
689 691
692 static bool IsLikelyInternalDart2JSCrash(const Stacktrace& stacktrace) {
693 Function& function = Function::Handle();
694 String& name = String::Handle();
695 for (intptr_t i = 0, len = stacktrace.Length(); i < len; i++) {
696 function = stacktrace.FunctionAtFrame(i);
697 name = function.QualifiedPrettyName();
698 if (name.Equals("_CompilerDiagnosticReporter.withCurrentElement")) {
699 return true;
700 }
701 }
702 return false;
703 }
704
705
690 void Exceptions::PrintStackTraceAndAbort(const char* reason) { 706 void Exceptions::PrintStackTraceAndAbort(const char* reason) {
691 const Instance& stacktrace = Instance::Handle(CurrentStacktrace()); 707 const Stacktrace& stacktrace = Stacktrace::Handle(CurrentStacktrace());
708 if (!IsLikelyInternalDart2JSCrash(stacktrace)) {
709 return;
710 }
692 711
693 OS::PrintErr("\n\n\nAborting due to %s. Stacktrace:\n%s\n", 712 OS::PrintErr("\n\n\nAborting due to %s. Stacktrace:\n%s\n",
694 reason, 713 reason,
695 stacktrace.ToCString()); 714 stacktrace.ToCString());
696 OS::Abort(); 715 OS::Abort();
697 } 716 }
698 717
699 } // namespace dart 718 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698