OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <stdarg.h> | 28 #include <stdarg.h> |
29 | 29 |
30 #include "v8.h" | 30 #include "v8.h" |
31 | 31 |
32 #include "platform.h" | 32 #include "platform.h" |
33 | 33 |
34 // TODO(isolates): is it necessary to lift this? | |
35 static int fatal_error_handler_nesting_depth = 0; | |
36 | |
37 // Contains protection against recursive calls (faults while handling faults). | 34 // Contains protection against recursive calls (faults while handling faults). |
38 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { | 35 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { |
39 i::AllowHandleDereference allow_deref; | 36 i::AllowHandleDereference allow_deref; |
40 i::AllowDeferredHandleDereference allow_deferred_deref; | 37 i::AllowDeferredHandleDereference allow_deferred_deref; |
41 fflush(stdout); | 38 fflush(stdout); |
42 fflush(stderr); | 39 fflush(stderr); |
43 fatal_error_handler_nesting_depth++; | 40 i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line); |
44 // First time we try to print an error message | 41 va_list arguments; |
45 if (fatal_error_handler_nesting_depth < 2) { | 42 va_start(arguments, format); |
46 i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line); | 43 i::OS::VPrintError(format, arguments); |
47 va_list arguments; | 44 va_end(arguments); |
48 va_start(arguments, format); | 45 i::OS::PrintError("\n#\n"); |
49 i::OS::VPrintError(format, arguments); | 46 i::OS::DumpBacktrace(); |
50 va_end(arguments); | |
51 i::OS::PrintError("\n#\n"); | |
52 i::OS::DumpBacktrace(); | |
53 } | |
54 // First two times we may try to print a stack dump. | |
55 if (fatal_error_handler_nesting_depth < 3) { | |
56 if (i::FLAG_stack_trace_on_abort) { | |
57 // Call this one twice on double fault | |
58 i::Isolate::Current()->PrintStack(stderr); | |
59 } | |
60 } | |
61 i::OS::Abort(); | 47 i::OS::Abort(); |
62 } | 48 } |
63 | 49 |
64 | 50 |
65 void CheckEqualsHelper(const char* file, | 51 void CheckEqualsHelper(const char* file, |
66 int line, | 52 int line, |
67 const char* expected_source, | 53 const char* expected_source, |
68 v8::Handle<v8::Value> expected, | 54 v8::Handle<v8::Value> expected, |
69 const char* value_source, | 55 const char* value_source, |
70 v8::Handle<v8::Value> value) { | 56 v8::Handle<v8::Value> value) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 90 |
105 | 91 |
106 namespace v8 { namespace internal { | 92 namespace v8 { namespace internal { |
107 | 93 |
108 bool EnableSlowAsserts() { return FLAG_enable_slow_asserts; } | 94 bool EnableSlowAsserts() { return FLAG_enable_slow_asserts; } |
109 | 95 |
110 intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; } | 96 intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; } |
111 | 97 |
112 } } // namespace v8::internal | 98 } } // namespace v8::internal |
113 | 99 |
OLD | NEW |