20void DefaultDcheckHandler(
const char* file,
int line,
const char* message);
22void (*g_print_stack_trace)() =
nullptr;
24void (*g_dcheck_function)(
const char*, int,
const char*) = DefaultDcheckHandler;
26void (*g_fatal_function)(
const char*, int,
const char*) =
nullptr;
28std::string PrettyPrintChar(
int ch) {
29 std::ostringstream oss;
31#define CHAR_PRINT_CASE(ch) \
48 if (std::isprint(ch)) {
49 oss <<
'\'' << ch <<
'\'';
51 oss << std::hex <<
"\\x" <<
static_cast<unsigned int>(ch);
57void DefaultDcheckHandler(
const char* file,
int line,
const char* message) {
59 V8_Fatal(file, line,
"Debug check failed: %s.", message);
62 V8_Fatal(
"Debug check failed: %s.", message);
69 g_print_stack_trace = print_stack_trace;
73 g_dcheck_function = dcheck_function ? dcheck_function : &DefaultDcheckHandler;
77 g_fatal_function = fatal_function;
89 OS::PrintError(
"\n\n#\n# Fatal %s out of memory: %s\n#", type_str, msg);
91 if (g_print_stack_trace) v8::base::g_print_stack_trace();
106#define DEFINE_PRINT_CHECK_OPERAND_CHAR(type) \
108 std::string PrintCheckOperand<type>(type ch) { \
109 return PrettyPrintChar(ch); \
112 std::string PrintCheckOperand<type*>(type * cstr) { \
113 return PrintCheckOperand<void*>(cstr); \
116 std::string PrintCheckOperand<const type*>(const type* cstr) { \
117 return PrintCheckOperand<const void*>(cstr); \
123#undef DEFINE_PRINT_CHECK_OPERAND_CHAR
126#define DEFINE_MAKE_CHECK_OP_STRING(type) \
127 template std::string* MakeCheckOpString<type, type>(type, type, \
129 template std::string PrintCheckOperand<type>(type);
137#undef DEFINE_MAKE_CHECK_OP_STRING
148class FailureMessage {
150 explicit FailureMessage(
const char* format, va_list arguments) {
151 memset(&message_, 0,
arraysize(message_));
152 v8::base::OS::VSNPrintF(&message_[0],
arraysize(message_), format,
156 static const uintptr_t kStartMarker = 0xdecade10;
157 static const uintptr_t kEndMarker = 0xdecade11;
158 static const int kMessageBufferSize = 512;
160 uintptr_t start_marker_ = kStartMarker;
161 char message_[kMessageBufferSize];
162 uintptr_t end_marker_ = kEndMarker;
168void V8_Fatal(
const char* file,
int line,
const char* format, ...) {
171 const char* file =
"";
175 va_start(arguments, format);
178 FailureMessage message(format, arguments);
181 if (v8::base::g_fatal_function !=
nullptr) {
182 v8::base::g_fatal_function(file, line, message.message_);
192 v8::base::OS::PrintError(
193 "\n\n#\n# Safely terminating process due to error in %s, line %d\n# ",
198 v8::base::OS::PrintError(
"The following harmless error was encountered: ");
200 v8::base::OS::PrintError(
"\n\n#\n# Fatal error in %s, line %d\n# ", file,
205 va_start(arguments, format);
206 v8::base::OS::VPrintError(format, arguments);
210 v8::base::OS::PrintError(
"\n#\n#\n#\n#FailureMessage Object: %p", &message);
212 if (v8::base::g_print_stack_trace) v8::base::g_print_stack_trace();
218void V8_Dcheck(
const char* file,
int line,
const char* message) {
221 v8::base::OS::PrintError(
222 "# Ignoring debug check failure in %s, line %d: %s\n", file, line,
227 v8::base::g_dcheck_function(file, line, message);
void V8_Fatal(const char *format,...)
#define CHAR_PRINT_CASE(ch)
void V8_Dcheck(const char *file, int line, const char *message)
#define DEFINE_PRINT_CHECK_OPERAND_CHAR(type)
#define DEFINE_MAKE_CHECK_OP_STRING(type)
void SetPrintStackTrace(void(*print_stack_trace)())
void FatalOOM(OOMType type, const char *msg)
V8_INLINE bool DcheckFailuresAreIgnored()
void SetDcheckFunction(void(*dcheck_function)(const char *, int, const char *))
V8_INLINE bool ControlledCrashesAreHarmless()
void SetFatalFunction(void(*fatal_function)(const char *, int, const char *))