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

Side by Side Diff: runtime/platform/assert.cc

Issue 2199453002: Attempt to print the stack using the profiler upon assertion failure. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | runtime/vm/profiler.cc » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #include "vm/os.h" 8 #include "vm/os.h"
9 #include "vm/profiler.h"
9 10
10 namespace dart { 11 namespace dart {
11 12
12 // Exit with a failure code when we miss an EXPECT check. 13 // Exit with a failure code when we miss an EXPECT check.
13 static void failed_exit(void) { 14 static void failed_exit(void) {
14 exit(255); 15 exit(255);
15 } 16 }
16 17
17 void DynamicAssertionHelper::Fail(const char* format, ...) { 18 void DynamicAssertionHelper::Fail(const char* format, ...) {
18 // Take only the last 1KB of the file name if it is longer. 19 // Take only the last 1KB of the file name if it is longer.
(...skipping 14 matching lines...) Expand all
33 format, 34 format,
34 arguments); 35 arguments);
35 va_end(arguments); 36 va_end(arguments);
36 37
37 // Print the buffer on stderr and/or syslog. 38 // Print the buffer on stderr and/or syslog.
38 OS::PrintErr("%s\n", buffer); 39 OS::PrintErr("%s\n", buffer);
39 40
40 // In case of failed assertions, abort right away. Otherwise, wait 41 // In case of failed assertions, abort right away. Otherwise, wait
41 // until the program is exiting before producing a non-zero exit 42 // until the program is exiting before producing a non-zero exit
42 // code through abort. 43 // code through abort.
43 // TODO(5411324): replace std::abort with OS::Abort so that we can handle
44 // restoring of signal handlers before aborting.
45 if (kind_ == ASSERT) { 44 if (kind_ == ASSERT) {
45 NOT_IN_PRODUCT(Profiler::DumpStackTrace(true /* native_stack_trace */));
46 OS::Abort(); 46 OS::Abort();
47 } 47 }
48 static bool failed = false; 48 static bool failed = false;
49 if (!failed) { 49 if (!failed) {
50 atexit(&failed_exit); 50 atexit(&failed_exit);
51 } 51 }
52 failed = true; 52 failed = true;
53 } 53 }
54 54
55 } // namespace dart 55 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698