説明を見る。00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <stdarg.h>
00029
00030 #include "v8.h"
00031
00032 #include "platform.h"
00033 #include "top.h"
00034
00035 using namespace v8::internal;
00036
00037 static int fatal_error_handler_nesting_depth = 0;
00038
00039
00040 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) {
00041 fatal_error_handler_nesting_depth++;
00042
00043 if (fatal_error_handler_nesting_depth < 2) {
00044 OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line);
00045 va_list arguments;
00046 va_start(arguments, format);
00047 OS::VPrintError(format, arguments);
00048 va_end(arguments);
00049 OS::PrintError("\n#\n\n");
00050 }
00051
00052 if (fatal_error_handler_nesting_depth < 3) {
00053 if (FLAG_stack_trace_on_abort) {
00054
00055 Top::PrintStack();
00056 }
00057 }
00058 OS::Abort();
00059 }
00060
00061
00062 void CheckEqualsHelper(const char* file,
00063 int line,
00064 const char* expected_source,
00065 v8::Handle<v8::Value> expected,
00066 const char* value_source,
00067 v8::Handle<v8::Value> value) {
00068 if (!expected->Equals(value)) {
00069 v8::String::Utf8Value value_str(value);
00070 v8::String::Utf8Value expected_str(expected);
00071 V8_Fatal(file, line,
00072 "CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s",
00073 expected_source, value_source, *expected_str, *value_str);
00074 }
00075 }
00076
00077
00078 void CheckNonEqualsHelper(const char* file,
00079 int line,
00080 const char* unexpected_source,
00081 v8::Handle<v8::Value> unexpected,
00082 const char* value_source,
00083 v8::Handle<v8::Value> value) {
00084 if (unexpected->Equals(value)) {
00085 v8::String::Utf8Value value_str(value);
00086 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s",
00087 unexpected_source, value_source, *value_str);
00088 }
00089 }
00090
00091
00092 void API_Fatal(const char* location, const char* format, ...) {
00093 OS::PrintError("\n#\n# Fatal error in %s\n# ", location);
00094 va_list arguments;
00095 va_start(arguments, format);
00096 OS::VPrintError(format, arguments);
00097 va_end(arguments);
00098 OS::PrintError("\n#\n\n");
00099 OS::Abort();
00100 }