Title: [111366] trunk/Source/_javascript_Core
Revision
111366
Author
[email protected]
Date
2012-03-19 23:48:17 -0700 (Mon, 19 Mar 2012)

Log Message

Split WTFReportBacktrace into WTFReportBacktrace and WTFPrintBacktrace
https://bugs.webkit.org/show_bug.cgi?id=80983

Reviewed by Darin Adler.

This allows printing a backtrace acquired by an earlier WTFGetBacktrace
call which is useful for local debugging.

* wtf/Assertions.cpp:
* wtf/Assertions.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (111365 => 111366)


--- trunk/Source/_javascript_Core/ChangeLog	2012-03-20 06:43:17 UTC (rev 111365)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-03-20 06:48:17 UTC (rev 111366)
@@ -1,3 +1,16 @@
+2012-03-19  Jochen Eisinger  <[email protected]>
+
+        Split WTFReportBacktrace into WTFReportBacktrace and WTFPrintBacktrace
+        https://bugs.webkit.org/show_bug.cgi?id=80983
+
+        Reviewed by Darin Adler.
+
+        This allows printing a backtrace acquired by an earlier WTFGetBacktrace
+        call which is useful for local debugging.
+
+        * wtf/Assertions.cpp:
+        * wtf/Assertions.h:
+
 2012-03-19  Benjamin Poulain  <[email protected]>
 
         Do not copy the script source in the SourceProvider, just reference the existing string

Modified: trunk/Source/_javascript_Core/wtf/Assertions.cpp (111365 => 111366)


--- trunk/Source/_javascript_Core/wtf/Assertions.cpp	2012-03-20 06:43:17 UTC (rev 111365)
+++ trunk/Source/_javascript_Core/wtf/Assertions.cpp	2012-03-20 06:48:17 UTC (rev 111366)
@@ -279,6 +279,17 @@
 #endif
 }
 
+void WTFReportBacktrace()
+{
+    static const int framesToShow = 31;
+    static const int framesToSkip = 2;
+    void* samples[framesToShow + framesToSkip];
+    int frames = framesToShow + framesToSkip;
+
+    WTFGetBacktrace(samples, &frames);
+    WTFPrintBacktrace(samples + framesToSkip, frames - framesToSkip);
+}
+
 #if OS(DARWIN) || OS(LINUX)
 #  if PLATFORM(QT) || PLATFORM(GTK)
 #    if defined(__GLIBC__) && !defined(__UCLIBC__)
@@ -289,38 +300,31 @@
 #  endif
 #endif
 
-void WTFReportBacktrace()
+void WTFPrintBacktrace(void** stack, int size)
 {
-    static const int framesToShow = 31;
-    static const int framesToSkip = 2;
-    void* samples[framesToShow + framesToSkip];
-    int frames = framesToShow + framesToSkip;
-
-    WTFGetBacktrace(samples, &frames);
-
 #if USE(BACKTRACE_SYMBOLS)
-    char** symbols = backtrace_symbols(samples, frames);
+    char** symbols = backtrace_symbols(stack, size);
     if (!symbols)
         return;
 #endif
 
-    for (int i = framesToSkip; i < frames; ++i) {
+    for (int i = 0; i < size; ++i) {
         const char* mangledName = 0;
         char* cxaDemangled = 0;
 #if USE(BACKTRACE_SYMBOLS)
         mangledName = symbols[i];
 #elif USE(DLADDR)
         Dl_info info;
-        if (dladdr(samples[i], &info) && info.dli_sname)
+        if (dladdr(stack[i], &info) && info.dli_sname)
             mangledName = info.dli_sname;
         if (mangledName)
             cxaDemangled = abi::__cxa_demangle(mangledName, 0, 0, 0);
 #endif
-        const int frameNumber = i - framesToSkip + 1;
+        const int frameNumber = i + 1;
         if (mangledName || cxaDemangled)
-            printf_stderr_common("%-3d %p %s\n", frameNumber, samples[i], cxaDemangled ? cxaDemangled : mangledName);
+            printf_stderr_common("%-3d %p %s\n", frameNumber, stack[i], cxaDemangled ? cxaDemangled : mangledName);
         else
-            printf_stderr_common("%-3d %p\n", frameNumber, samples[i]);
+            printf_stderr_common("%-3d %p\n", frameNumber, stack[i]);
         free(cxaDemangled);
     }
 

Modified: trunk/Source/_javascript_Core/wtf/Assertions.h (111365 => 111366)


--- trunk/Source/_javascript_Core/wtf/Assertions.h	2012-03-20 06:43:17 UTC (rev 111365)
+++ trunk/Source/_javascript_Core/wtf/Assertions.h	2012-03-20 06:48:17 UTC (rev 111366)
@@ -146,6 +146,7 @@
 
 WTF_EXPORT_PRIVATE void WTFGetBacktrace(void** stack, int* size);
 WTF_EXPORT_PRIVATE void WTFReportBacktrace();
+WTF_EXPORT_PRIVATE void WTFPrintBacktrace(void** stack, int size);
 
 typedef void (*WTFCrashHookFunction)();
 WTF_EXPORT_PRIVATE void WTFSetCrashHook(WTFCrashHookFunction);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to