• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstdio>
8 #include <cstdlib>
9 
10 #include "src/base/debug/stack_trace.h"
11 #include "src/base/platform/platform.h"
12 
13 namespace v8 {
14 namespace base {
15 
16 // Explicit instantiations for commonly used comparisons.
17 #define DEFINE_MAKE_CHECK_OP_STRING(type) \
18   template std::string* MakeCheckOpString<type, type>(type, type, char const*);
19 DEFINE_MAKE_CHECK_OP_STRING(int)
20 DEFINE_MAKE_CHECK_OP_STRING(long)       // NOLINT(runtime/int)
21 DEFINE_MAKE_CHECK_OP_STRING(long long)  // NOLINT(runtime/int)
22 DEFINE_MAKE_CHECK_OP_STRING(unsigned int)
23 DEFINE_MAKE_CHECK_OP_STRING(unsigned long)       // NOLINT(runtime/int)
24 DEFINE_MAKE_CHECK_OP_STRING(unsigned long long)  // NOLINT(runtime/int)
25 DEFINE_MAKE_CHECK_OP_STRING(char const*)
26 DEFINE_MAKE_CHECK_OP_STRING(void const*)
27 #undef DEFINE_MAKE_CHECK_OP_STRING
28 
29 
30 // Explicit instantiations for floating point checks.
31 #define DEFINE_CHECK_OP_IMPL(NAME)                                            \
32   template std::string* Check##NAME##Impl<float, float>(float lhs, float rhs, \
33                                                         char const* msg);     \
34   template std::string* Check##NAME##Impl<double, double>(                    \
35       double lhs, double rhs, char const* msg);
36 DEFINE_CHECK_OP_IMPL(EQ)
37 DEFINE_CHECK_OP_IMPL(NE)
38 DEFINE_CHECK_OP_IMPL(LE)
39 DEFINE_CHECK_OP_IMPL(LT)
40 DEFINE_CHECK_OP_IMPL(GE)
41 DEFINE_CHECK_OP_IMPL(GT)
42 #undef DEFINE_CHECK_OP_IMPL
43 
44 }  // namespace base
45 }  // namespace v8
46 
47 
48 // Contains protection against recursive calls (faults while handling faults).
49 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) {
50   fflush(stdout);
51   fflush(stderr);
52   v8::base::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file,
53                            line);
54   va_list arguments;
55   va_start(arguments, format);
56   v8::base::OS::VPrintError(format, arguments);
57   va_end(arguments);
58   v8::base::OS::PrintError("\n#\n");
59 
60   v8::base::debug::StackTrace trace;
61   trace.Print();
62 
63   fflush(stderr);
64   // Avoid dumping stack trace on abort signal.
65   v8::base::debug::DisableSignalStackDump();
66   v8::base::OS::Abort();
67 }
68