Modified: trunk/Source/_javascript_Core/ChangeLog (96594 => 96595)
--- trunk/Source/_javascript_Core/ChangeLog 2011-10-04 15:13:45 UTC (rev 96594)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-10-04 15:39:46 UTC (rev 96595)
@@ -1,3 +1,18 @@
+2011-10-04 Gavin Peters <gav...@chromium.org>
+
+ add more stack dumping methods
+ https://bugs.webkit.org/show_bug.cgi?id=69018
+
+ In addition to WTFReportBacktrace, this adds the cross-platform WTFGetBacktrace, which lets
+ WebKit programmatically retrieve the current stack. This is useful if you need to add more
+ reporting to field crash report uploads, if you're tracking down an irreproducable bug,
+ for instance.
+
+ Reviewed by Darin Adler.
+
+ * wtf/Assertions.cpp:
+ * wtf/Assertions.h:
+
2011-10-03 Filip Pizlo <fpi...@apple.com>
DFG should inline Array.push and Array.pop
Modified: trunk/Source/_javascript_Core/wtf/Assertions.cpp (96594 => 96595)
--- trunk/Source/_javascript_Core/wtf/Assertions.cpp 2011-10-04 15:13:45 UTC (rev 96594)
+++ trunk/Source/_javascript_Core/wtf/Assertions.cpp 2011-10-04 15:39:46 UTC (rev 96595)
@@ -49,7 +49,7 @@
#include <windows.h>
#endif
-#if PLATFORM(MAC)
+#if OS(DARWIN) || OS(LINUX)
#include <cxxabi.h>
#include <dlfcn.h>
#include <execinfo.h>
@@ -166,32 +166,56 @@
printCallSite(file, line, function);
}
+void WTFGetBacktrace(void** stack, int* size)
+{
+#if OS(DARWIN) || OS(LINUX)
+ *size = backtrace(stack, *size);
+#elif OS(WINDOWS)
+ // The CaptureStackBackTrace function is available in XP, but it is not defined
+ // in the Windows Server 2003 R2 Platform SDK. So, we'll grab the function
+ // through GetProcAddress.
+ typedef WORD (NTAPI* RtlCaptureStackBackTraceFunc)(DWORD, DWORD, PVOID*, PDWORD);
+ HMODULE kernel32 = ::GetModuleHandleW(L"Kernel32.dll");
+ if (!kernel32) {
+ *size = 0;
+ return;
+ }
+ RtlCaptureStackBackTraceFunc captureStackBackTraceFunc = reinterpret_cast<RtlCaptureStackBackTraceFunc>(
+ ::GetProcAddress(kernel32, "RtlCaptureStackBackTrace"));
+ if (captureStackBackTraceFunc)
+ *size = captureStackBackTraceFunc(1, *size, stack, 0);
+ else
+ *size = 0;
+#else
+ *size = 0;
+#endif
+}
+
void WTFReportBacktrace()
{
-#if PLATFORM(MAC)
static const int maxFrames = 32;
void* samples[maxFrames];
- int frames = backtrace(samples, maxFrames);
+ int frames = maxFrames;
+ WTFGetBacktrace(samples, &frames);
+
for (int i = 1; i < frames; ++i) {
- void* pointer = samples[i];
+ const char* mangledName = 0;
+ char* cxaDemangled = 0;
- // Try to get a symbol name from the dynamic linker.
+#if !PLATFORM(QT) && (OS(DARWIN) || OS(LINUX))
Dl_info info;
- if (dladdr(pointer, &info) && info.dli_sname) {
- const char* mangledName = info.dli_sname;
-
- // Assume c++ & try to demangle the name.
- char* demangledName = abi::__cxa_demangle(mangledName, 0, 0, 0);
- if (demangledName) {
- fprintf(stderr, "%-3d %s\n", i, demangledName);
- free(demangledName);
- } else
- fprintf(stderr, "%-3d %s\n", i, mangledName);
- } else
- fprintf(stderr, "%-3d %p\n", i, pointer);
+ if (dladdr(samples[i], &info) && info.dli_sname)
+ mangledName = info.dli_sname;
+ if (mangledName)
+ cxaDemangled = abi::__cxa_demangle(mangledName, 0, 0, 0);
+#endif
+ if (mangledName || cxaDemangled)
+ fprintf(stderr, "%-3d %p %s\n", i, samples[i], cxaDemangled ? cxaDemangled : mangledName);
+ else
+ fprintf(stderr, "%-3d %p\n", i, samples[i]);
+ free(cxaDemangled);
}
-#endif
}
void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...)
Modified: trunk/Source/_javascript_Core/wtf/Assertions.h (96594 => 96595)
--- trunk/Source/_javascript_Core/wtf/Assertions.h 2011-10-04 15:13:45 UTC (rev 96594)
+++ trunk/Source/_javascript_Core/wtf/Assertions.h 2011-10-04 15:39:46 UTC (rev 96595)
@@ -144,12 +144,14 @@
WTF_EXPORT_PRIVATE void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion);
WTF_EXPORT_PRIVATE void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
WTF_EXPORT_PRIVATE void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion);
-WTF_EXPORT_PRIVATE void WTFReportBacktrace();
WTF_EXPORT_PRIVATE void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
WTF_EXPORT_PRIVATE void WTFReportError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
WTF_EXPORT_PRIVATE void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
WTF_EXPORT_PRIVATE void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
+WTF_EXPORT_PRIVATE void WTFGetBacktrace(void** stack, int* size);
+WTF_EXPORT_PRIVATE void WTFReportBacktrace();
+
#ifdef __cplusplus
}
#endif