OLD | NEW |
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 <cstdlib> | |
8 #include <sstream> | 7 #include <sstream> |
9 #include <string> | 8 #include <string> |
10 | 9 |
11 #include "platform/globals.h" | 10 #include "platform/globals.h" |
12 | 11 |
13 namespace dart { | 12 namespace dart { |
14 | 13 |
15 // Exit with a failure code when we miss an EXPECT check. | 14 // Exit with a failure code when we miss an EXPECT check. |
16 static void failed_exit(void) { | 15 static void failed_exit(void) { |
17 exit(255); | 16 exit(255); |
(...skipping 13 matching lines...) Expand all Loading... |
31 // Get the message from the string stream and dump it on stderr. | 30 // Get the message from the string stream and dump it on stderr. |
32 std::string message = stream.str(); | 31 std::string message = stream.str(); |
33 fprintf(stderr, "%s", message.c_str()); | 32 fprintf(stderr, "%s", message.c_str()); |
34 | 33 |
35 // In case of failed assertions, abort right away. Otherwise, wait | 34 // In case of failed assertions, abort right away. Otherwise, wait |
36 // until the program is exiting before producing a non-zero exit | 35 // until the program is exiting before producing a non-zero exit |
37 // code through abort. | 36 // code through abort. |
38 // TODO(5411324): replace std::abort with OS::Abort so that we can handle | 37 // TODO(5411324): replace std::abort with OS::Abort so that we can handle |
39 // restoring of signal handlers before aborting. | 38 // restoring of signal handlers before aborting. |
40 if (kind_ == ASSERT) { | 39 if (kind_ == ASSERT) { |
41 std::abort(); | 40 abort(); |
42 } | 41 } |
43 static bool failed = false; | 42 static bool failed = false; |
44 if (!failed) { | 43 if (!failed) { |
45 std::atexit(&failed_exit); | 44 atexit(&failed_exit); |
46 } | 45 } |
47 failed = true; | 46 failed = true; |
48 } | 47 } |
49 | 48 |
50 } // namespace dart | 49 } // namespace dart |
OLD | NEW |