diff mbox series

[libphobos] Committed fallback UnwindBacktrace if LibBacktrace unfound

Message ID CABOHX+fBx3tqm-jEDSN3_cCsYVY_H5VYeYkzYx==RmvJDFr9Tw@mail.gmail.com
State New
Headers show
Series [libphobos] Committed fallback UnwindBacktrace if LibBacktrace unfound | expand

Commit Message

Iain Buclaw Feb. 13, 2019, 7:15 a.m. UTC
Hi,

In the gcc.backtrace module, either one of LibBacktrace or
UnwindBacktrace will always be defined.  This patch gives
UnwindBacktrace a higher precedence over the libc backtrace as the
default backtrace handler as the latter depends on a rt.backtrace
module that is not compiled in.

Only useful if building --without-libbacktrace or libbacktrace is
unsupported for whatever reason.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r268836.
diff mbox series

Patch

diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d
index a78363cf477..0ead04752e4 100644
--- a/libphobos/libdruntime/core/runtime.d
+++ b/libphobos/libdruntime/core/runtime.d
@@ -619,6 +619,22 @@  Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
         }
         return new LibBacktrace(FIRSTFRAME);
     }
+    else static if ( __traits( compiles, new UnwindBacktrace(0) ) )
+    {
+        version (Posix)
+        {
+            static enum FIRSTFRAME = 5;
+        }
+        else version (Win64)
+        {
+            static enum FIRSTFRAME = 4;
+        }
+        else
+        {
+            static enum FIRSTFRAME = 0;
+        }
+        return new UnwindBacktrace(FIRSTFRAME);
+    }
     else static if ( __traits( compiles, backtrace ) )
     {
         import core.demangle;
@@ -885,22 +901,6 @@  Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
         auto s = new StackTrace(FIRSTFRAME, cast(CONTEXT*)ptr);
         return s;
     }
-    else static if ( __traits( compiles, new UnwindBacktrace(0) ) )
-    {
-        version (Posix)
-        {
-            static enum FIRSTFRAME = 5;
-        }
-        else version (Win64)
-        {
-            static enum FIRSTFRAME = 4;
-        }
-        else
-        {
-            static enum FIRSTFRAME = 0;
-        }
-        return new UnwindBacktrace(FIRSTFRAME);
-    }
     else
     {
         return null;