From 5522686e52cc832fb5cf376e95d3e213bb74ec00 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 13 Feb 2019 07:14:46 +0000 Subject: [PATCH] libphobos: Fallback on UnwindBacktrace if LibBacktrace not defined. In the gcc.backtrace module, either one of LibBacktrace or UnwindBacktrace will always be defined. Giving UnwindBacktrace a higher precedence over the libc backtrace as the default handler because the latter depends on a rt.backtrace module that is not compiled in. libphobos/ChangeLog: * libdruntime/core/runtime.d (defaultTraceHandler): Give UnwindBacktrace handler precedence over backtrace. From-SVN: r268836 --- libphobos/ChangeLog | 5 +++++ libphobos/libdruntime/core/runtime.d | 32 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index 2aa99a426f8..e43b8559d27 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,3 +1,8 @@ +2019-02-13 Iain Buclaw + + * libdruntime/core/runtime.d (defaultTraceHandler): Give + UnwindBacktrace handler precedence over backtrace. + 2019-02-10 Iain Buclaw * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Remove rt/util/hash.d 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; -- 2.30.2