Revision f230a1cf deps/v8/src/checks.cc
deps/v8/src/checks.cc | ||
---|---|---|
25 | 25 |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 | 26 |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
|
28 |
#include <stdarg.h>
|
|
28 |
#include "checks.h"
|
|
29 | 29 |
|
30 |
#include "v8.h" |
|
30 |
#if V8_LIBC_GLIBC || V8_OS_BSD |
|
31 |
# include <cxxabi.h> |
|
32 |
# include <execinfo.h> |
|
33 |
#endif // V8_LIBC_GLIBC || V8_OS_BSD |
|
34 |
#include <stdio.h> |
|
31 | 35 |
|
32 | 36 |
#include "platform.h" |
37 |
#include "v8.h" |
|
38 |
|
|
39 |
|
|
40 |
// Attempts to dump a backtrace (if supported). |
|
41 |
static V8_INLINE void DumpBacktrace() { |
|
42 |
#if V8_LIBC_GLIBC || V8_OS_BSD |
|
43 |
void* trace[100]; |
|
44 |
int size = backtrace(trace, ARRAY_SIZE(trace)); |
|
45 |
char** symbols = backtrace_symbols(trace, size); |
|
46 |
i::OS::PrintError("\n==== C stack trace ===============================\n\n"); |
|
47 |
if (size == 0) { |
|
48 |
i::OS::PrintError("(empty)\n"); |
|
49 |
} else if (symbols == NULL) { |
|
50 |
i::OS::PrintError("(no symbols)\n"); |
|
51 |
} else { |
|
52 |
for (int i = 1; i < size; ++i) { |
|
53 |
i::OS::PrintError("%2d: ", i); |
|
54 |
char mangled[201]; |
|
55 |
if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { // NOLINT |
|
56 |
int status; |
|
57 |
size_t length; |
|
58 |
char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status); |
|
59 |
i::OS::PrintError("%s\n", demangled != NULL ? demangled : mangled); |
|
60 |
free(demangled); |
|
61 |
} else { |
|
62 |
i::OS::PrintError("??\n"); |
|
63 |
} |
|
64 |
} |
|
65 |
} |
|
66 |
free(symbols); |
|
67 |
#endif // V8_LIBC_GLIBC || V8_OS_BSD |
|
68 |
} |
|
69 |
|
|
33 | 70 |
|
34 | 71 |
// Contains protection against recursive calls (faults while handling faults). |
35 | 72 |
extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { |
... | ... | |
43 | 80 |
i::OS::VPrintError(format, arguments); |
44 | 81 |
va_end(arguments); |
45 | 82 |
i::OS::PrintError("\n#\n"); |
46 |
i::OS::DumpBacktrace(); |
|
83 |
DumpBacktrace(); |
|
84 |
fflush(stderr); |
|
47 | 85 |
i::OS::Abort(); |
48 | 86 |
} |
49 | 87 |
|
... | ... | |
91 | 129 |
|
92 | 130 |
namespace v8 { namespace internal { |
93 | 131 |
|
94 |
bool EnableSlowAsserts() { return FLAG_enable_slow_asserts; } |
|
95 |
|
|
96 | 132 |
intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; } |
97 | 133 |
|
98 | 134 |
} } // namespace v8::internal |
Also available in: Unified diff