Line data Source code
1 : // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/base/logging.h"
6 :
7 : #include <cstdarg>
8 : #include <cstdio>
9 : #include <cstdlib>
10 :
11 : #include "src/base/debug/stack_trace.h"
12 : #include "src/base/platform/platform.h"
13 :
14 : namespace v8 {
15 : namespace base {
16 :
17 : namespace {
18 :
19 : void (*g_print_stack_trace)() = nullptr;
20 :
21 : } // namespace
22 :
23 118205 : void SetPrintStackTrace(void (*print_stack_trace)()) {
24 118205 : g_print_stack_trace = print_stack_trace;
25 118205 : }
26 :
27 : // Explicit instantiations for commonly used comparisons.
28 : #define DEFINE_MAKE_CHECK_OP_STRING(type) \
29 : template std::string* MakeCheckOpString<type, type>(type, type, char const*);
30 : DEFINE_MAKE_CHECK_OP_STRING(int)
31 : DEFINE_MAKE_CHECK_OP_STRING(long) // NOLINT(runtime/int)
32 : DEFINE_MAKE_CHECK_OP_STRING(long long) // NOLINT(runtime/int)
33 : DEFINE_MAKE_CHECK_OP_STRING(unsigned int)
34 : DEFINE_MAKE_CHECK_OP_STRING(unsigned long) // NOLINT(runtime/int)
35 : DEFINE_MAKE_CHECK_OP_STRING(unsigned long long) // NOLINT(runtime/int)
36 : DEFINE_MAKE_CHECK_OP_STRING(char const*)
37 : DEFINE_MAKE_CHECK_OP_STRING(void const*)
38 : #undef DEFINE_MAKE_CHECK_OP_STRING
39 :
40 :
41 : // Explicit instantiations for floating point checks.
42 : #define DEFINE_CHECK_OP_IMPL(NAME) \
43 : template std::string* Check##NAME##Impl<float, float>(float lhs, float rhs, \
44 : char const* msg); \
45 : template std::string* Check##NAME##Impl<double, double>( \
46 : double lhs, double rhs, char const* msg);
47 : DEFINE_CHECK_OP_IMPL(EQ)
48 : DEFINE_CHECK_OP_IMPL(NE)
49 : DEFINE_CHECK_OP_IMPL(LE)
50 : DEFINE_CHECK_OP_IMPL(LT)
51 : DEFINE_CHECK_OP_IMPL(GE)
52 : DEFINE_CHECK_OP_IMPL(GT)
53 : #undef DEFINE_CHECK_OP_IMPL
54 :
55 : } // namespace base
56 : } // namespace v8
57 :
58 :
59 : // Contains protection against recursive calls (faults while handling faults).
60 0 : extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) {
61 0 : fflush(stdout);
62 0 : fflush(stderr);
63 : v8::base::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file,
64 0 : line);
65 : va_list arguments;
66 0 : va_start(arguments, format);
67 0 : v8::base::OS::VPrintError(format, arguments);
68 0 : va_end(arguments);
69 0 : v8::base::OS::PrintError("\n#\n");
70 :
71 0 : if (v8::base::g_print_stack_trace) v8::base::g_print_stack_trace();
72 :
73 0 : fflush(stderr);
74 0 : v8::base::OS::Abort();
75 : }
|