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 "platform/globals.h" | 7 #include "platform/globals.h" |
8 #include "vm/os.h" | 8 #include "vm/os.h" |
9 #include "vm/profiler.h" | 9 #include "vm/profiler.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 // Print the file and line number into the buffer. | 21 // Print the file and line number into the buffer. |
22 char buffer[4 * KB]; | 22 char buffer[4 * KB]; |
23 MSAN_UNPOISON(buffer, sizeof(buffer)); | 23 MSAN_UNPOISON(buffer, sizeof(buffer)); |
24 intptr_t file_and_line_length = | 24 intptr_t file_and_line_length = |
25 snprintf(buffer, sizeof(buffer), "%s: %d: error: ", file, line_); | 25 snprintf(buffer, sizeof(buffer), "%s: %d: error: ", file, line_); |
26 | 26 |
27 // Print the error message into the buffer. | 27 // Print the error message into the buffer. |
28 va_list arguments; | 28 va_list arguments; |
29 va_start(arguments, format); | 29 va_start(arguments, format); |
30 vsnprintf(buffer + file_and_line_length, | 30 vsnprintf(buffer + file_and_line_length, |
31 sizeof(buffer) - file_and_line_length, | 31 sizeof(buffer) - file_and_line_length, format, arguments); |
32 format, | |
33 arguments); | |
34 va_end(arguments); | 32 va_end(arguments); |
35 | 33 |
36 // Print the buffer on stderr and/or syslog. | 34 // Print the buffer on stderr and/or syslog. |
37 OS::PrintErr("%s\n", buffer); | 35 OS::PrintErr("%s\n", buffer); |
38 | 36 |
39 // In case of failed assertions, abort right away. Otherwise, wait | 37 // In case of failed assertions, abort right away. Otherwise, wait |
40 // until the program is exiting before producing a non-zero exit | 38 // until the program is exiting before producing a non-zero exit |
41 // code through abort. | 39 // code through abort. |
42 if (kind_ == ASSERT) { | 40 if (kind_ == ASSERT) { |
43 NOT_IN_PRODUCT(Profiler::DumpStackTrace(true /* native_stack_trace */)); | 41 NOT_IN_PRODUCT(Profiler::DumpStackTrace(true /* native_stack_trace */)); |
44 OS::Abort(); | 42 OS::Abort(); |
45 } | 43 } |
46 failed_ = true; | 44 failed_ = true; |
47 } | 45 } |
48 | 46 |
49 } // namespace dart | 47 } // namespace dart |
OLD | NEW |