| 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 14 matching lines...) Expand all Loading... |
| 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 #include "top.h" | 33 #include "top.h" |
| 34 | 34 |
| 35 using namespace v8::internal; | |
| 36 | |
| 37 static int fatal_error_handler_nesting_depth = 0; | 35 static int fatal_error_handler_nesting_depth = 0; |
| 38 | 36 |
| 39 // Contains protection against recursive calls (faults while handling faults). | 37 // Contains protection against recursive calls (faults while handling faults). |
| 40 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { | 38 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { |
| 41 fatal_error_handler_nesting_depth++; | 39 fatal_error_handler_nesting_depth++; |
| 42 // First time we try to print an error message | 40 // First time we try to print an error message |
| 43 if (fatal_error_handler_nesting_depth < 2) { | 41 if (fatal_error_handler_nesting_depth < 2) { |
| 44 OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line); | 42 i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line); |
| 45 va_list arguments; | 43 va_list arguments; |
| 46 va_start(arguments, format); | 44 va_start(arguments, format); |
| 47 OS::VPrintError(format, arguments); | 45 i::OS::VPrintError(format, arguments); |
| 48 va_end(arguments); | 46 va_end(arguments); |
| 49 OS::PrintError("\n#\n\n"); | 47 i::OS::PrintError("\n#\n\n"); |
| 50 } | 48 } |
| 51 // First two times we may try to print a stack dump. | 49 // First two times we may try to print a stack dump. |
| 52 if (fatal_error_handler_nesting_depth < 3) { | 50 if (fatal_error_handler_nesting_depth < 3) { |
| 53 if (FLAG_stack_trace_on_abort) { | 51 if (i::FLAG_stack_trace_on_abort) { |
| 54 // Call this one twice on double fault | 52 // Call this one twice on double fault |
| 55 Top::PrintStack(); | 53 i::Top::PrintStack(); |
| 56 } | 54 } |
| 57 } | 55 } |
| 58 OS::Abort(); | 56 i::OS::Abort(); |
| 59 } | 57 } |
| 60 | 58 |
| 61 | 59 |
| 62 void CheckEqualsHelper(const char* file, | 60 void CheckEqualsHelper(const char* file, |
| 63 int line, | 61 int line, |
| 64 const char* expected_source, | 62 const char* expected_source, |
| 65 v8::Handle<v8::Value> expected, | 63 v8::Handle<v8::Value> expected, |
| 66 const char* value_source, | 64 const char* value_source, |
| 67 v8::Handle<v8::Value> value) { | 65 v8::Handle<v8::Value> value) { |
| 68 if (!expected->Equals(value)) { | 66 if (!expected->Equals(value)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 83 v8::Handle<v8::Value> value) { | 81 v8::Handle<v8::Value> value) { |
| 84 if (unexpected->Equals(value)) { | 82 if (unexpected->Equals(value)) { |
| 85 v8::String::Utf8Value value_str(value); | 83 v8::String::Utf8Value value_str(value); |
| 86 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s", | 84 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s", |
| 87 unexpected_source, value_source, *value_str); | 85 unexpected_source, value_source, *value_str); |
| 88 } | 86 } |
| 89 } | 87 } |
| 90 | 88 |
| 91 | 89 |
| 92 void API_Fatal(const char* location, const char* format, ...) { | 90 void API_Fatal(const char* location, const char* format, ...) { |
| 93 OS::PrintError("\n#\n# Fatal error in %s\n# ", location); | 91 i::OS::PrintError("\n#\n# Fatal error in %s\n# ", location); |
| 94 va_list arguments; | 92 va_list arguments; |
| 95 va_start(arguments, format); | 93 va_start(arguments, format); |
| 96 OS::VPrintError(format, arguments); | 94 i::OS::VPrintError(format, arguments); |
| 97 va_end(arguments); | 95 va_end(arguments); |
| 98 OS::PrintError("\n#\n\n"); | 96 i::OS::PrintError("\n#\n\n"); |
| 99 OS::Abort(); | 97 i::OS::Abort(); |
| 100 } | 98 } |
| OLD | NEW |