Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: src/checks.cc

Issue 200343003: Expose DumpBacktrace for debugging purposes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/checks.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 20 matching lines...) Expand all
31 # include <cxxabi.h> 31 # include <cxxabi.h>
32 # include <execinfo.h> 32 # include <execinfo.h>
33 #elif V8_OS_QNX 33 #elif V8_OS_QNX
34 # include <backtrace.h> 34 # include <backtrace.h>
35 #endif // V8_LIBC_GLIBC || V8_OS_BSD 35 #endif // V8_LIBC_GLIBC || V8_OS_BSD
36 #include <stdio.h> 36 #include <stdio.h>
37 37
38 #include "platform.h" 38 #include "platform.h"
39 #include "v8.h" 39 #include "v8.h"
40 40
41 namespace v8 {
42 namespace internal {
43
44 intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; }
41 45
42 // Attempts to dump a backtrace (if supported). 46 // Attempts to dump a backtrace (if supported).
43 static V8_INLINE void DumpBacktrace() { 47 void DumpBacktrace() {
44 #if V8_LIBC_GLIBC || V8_OS_BSD 48 #if V8_LIBC_GLIBC || V8_OS_BSD
45 void* trace[100]; 49 void* trace[100];
46 int size = backtrace(trace, ARRAY_SIZE(trace)); 50 int size = backtrace(trace, ARRAY_SIZE(trace));
47 char** symbols = backtrace_symbols(trace, size); 51 char** symbols = backtrace_symbols(trace, size);
48 i::OS::PrintError("\n==== C stack trace ===============================\n\n"); 52 OS::PrintError("\n==== C stack trace ===============================\n\n");
49 if (size == 0) { 53 if (size == 0) {
50 i::OS::PrintError("(empty)\n"); 54 OS::PrintError("(empty)\n");
51 } else if (symbols == NULL) { 55 } else if (symbols == NULL) {
52 i::OS::PrintError("(no symbols)\n"); 56 OS::PrintError("(no symbols)\n");
53 } else { 57 } else {
54 for (int i = 1; i < size; ++i) { 58 for (int i = 1; i < size; ++i) {
55 i::OS::PrintError("%2d: ", i); 59 OS::PrintError("%2d: ", i);
56 char mangled[201]; 60 char mangled[201];
57 if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { // NOLINT 61 if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { // NOLINT
58 int status; 62 int status;
59 size_t length; 63 size_t length;
60 char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status); 64 char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status);
61 i::OS::PrintError("%s\n", demangled != NULL ? demangled : mangled); 65 OS::PrintError("%s\n", demangled != NULL ? demangled : mangled);
62 free(demangled); 66 free(demangled);
63 } else { 67 } else {
64 i::OS::PrintError("??\n"); 68 OS::PrintError("??\n");
65 } 69 }
66 } 70 }
67 } 71 }
68 free(symbols); 72 free(symbols);
69 #elif V8_OS_QNX 73 #elif V8_OS_QNX
70 char out[1024]; 74 char out[1024];
71 bt_accessor_t acc; 75 bt_accessor_t acc;
72 bt_memmap_t memmap; 76 bt_memmap_t memmap;
73 bt_init_accessor(&acc, BT_SELF); 77 bt_init_accessor(&acc, BT_SELF);
74 bt_load_memmap(&acc, &memmap); 78 bt_load_memmap(&acc, &memmap);
75 bt_sprn_memmap(&memmap, out, sizeof(out)); 79 bt_sprn_memmap(&memmap, out, sizeof(out));
76 i::OS::PrintError(out); 80 OS::PrintError(out);
77 bt_addr_t trace[100]; 81 bt_addr_t trace[100];
78 int size = bt_get_backtrace(&acc, trace, ARRAY_SIZE(trace)); 82 int size = bt_get_backtrace(&acc, trace, ARRAY_SIZE(trace));
79 i::OS::PrintError("\n==== C stack trace ===============================\n\n"); 83 OS::PrintError("\n==== C stack trace ===============================\n\n");
80 if (size == 0) { 84 if (size == 0) {
81 i::OS::PrintError("(empty)\n"); 85 OS::PrintError("(empty)\n");
82 } else { 86 } else {
83 bt_sprnf_addrs(&memmap, trace, size, const_cast<char*>("%a\n"), 87 bt_sprnf_addrs(&memmap, trace, size, const_cast<char*>("%a\n"),
84 out, sizeof(out), NULL); 88 out, sizeof(out), NULL);
85 i::OS::PrintError(out); 89 OS::PrintError(out);
86 } 90 }
87 bt_unload_memmap(&memmap); 91 bt_unload_memmap(&memmap);
88 bt_release_accessor(&acc); 92 bt_release_accessor(&acc);
89 #endif // V8_LIBC_GLIBC || V8_OS_BSD 93 #endif // V8_LIBC_GLIBC || V8_OS_BSD
90 } 94 }
91 95
96 } } // namespace v8::internal
97
92 98
93 // Contains protection against recursive calls (faults while handling faults). 99 // Contains protection against recursive calls (faults while handling faults).
94 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { 100 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) {
95 i::AllowHandleDereference allow_deref; 101 i::AllowHandleDereference allow_deref;
96 i::AllowDeferredHandleDereference allow_deferred_deref; 102 i::AllowDeferredHandleDereference allow_deferred_deref;
97 fflush(stdout); 103 fflush(stdout);
98 fflush(stderr); 104 fflush(stderr);
99 i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line); 105 i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line);
100 va_list arguments; 106 va_list arguments;
101 va_start(arguments, format); 107 va_start(arguments, format);
102 i::OS::VPrintError(format, arguments); 108 i::OS::VPrintError(format, arguments);
103 va_end(arguments); 109 va_end(arguments);
104 i::OS::PrintError("\n#\n"); 110 i::OS::PrintError("\n#\n");
105 DumpBacktrace(); 111 v8::internal::DumpBacktrace();
106 fflush(stderr); 112 fflush(stderr);
107 i::OS::Abort(); 113 i::OS::Abort();
108 } 114 }
109 115
110 116
111 void CheckEqualsHelper(const char* file, 117 void CheckEqualsHelper(const char* file,
112 int line, 118 int line,
113 const char* expected_source, 119 const char* expected_source,
114 v8::Handle<v8::Value> expected, 120 v8::Handle<v8::Value> expected,
115 const char* value_source, 121 const char* value_source,
(...skipping 13 matching lines...) Expand all
129 const char* unexpected_source, 135 const char* unexpected_source,
130 v8::Handle<v8::Value> unexpected, 136 v8::Handle<v8::Value> unexpected,
131 const char* value_source, 137 const char* value_source,
132 v8::Handle<v8::Value> value) { 138 v8::Handle<v8::Value> value) {
133 if (unexpected->Equals(value)) { 139 if (unexpected->Equals(value)) {
134 v8::String::Utf8Value value_str(value); 140 v8::String::Utf8Value value_str(value);
135 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s", 141 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s",
136 unexpected_source, value_source, *value_str); 142 unexpected_source, value_source, *value_str);
137 } 143 }
138 } 144 }
139
140
141 namespace v8 { namespace internal {
142
143 intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; }
144
145 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/checks.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698