From 5f0e42343f3d5bf60d0f51a5302ab211299514e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antons=20Je=C4=BCkins?= Date: Thu, 19 Sep 2024 23:44:09 +0200 Subject: [PATCH] Add libdwfl based implementation This commit adds an implementation based on libdwfl from elfutils. Implements #176 --- CMakeLists.txt | 8 ++ build.jam | 3 + build/Jamfile.v2 | 19 +++ build/has_dwfl.cpp | 10 ++ doc/stacktrace.qbk | 1 + .../boost/stacktrace/detail/frame_unwind.ipp | 2 + .../boost/stacktrace/detail/libdwfl_impls.hpp | 116 ++++++++++++++++++ src/dwfl.cpp | 14 +++ test/CMakeLists.txt | 4 + test/Jamfile.v2 | 30 +++++ test/test.cpp | 4 +- 11 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 build/has_dwfl.cpp create mode 100644 include/boost/stacktrace/detail/libdwfl_impls.hpp create mode 100644 src/dwfl.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c5bf84..ee55baf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ function(stacktrace_check var source incs libs defs) endfunction() stacktrace_check(BOOST_STACKTRACE_HAS_BACKTRACE has_backtrace.cpp "" "backtrace" "") +stacktrace_check(BOOST_STACKTRACE_HAS_DWFL has_dwfl.cpp "" "dw" "") set(_default_addr2line ON) if(WIN32 AND NOT CMAKE_CXX_PLATFORM_ID MATCHES "Cygwin") @@ -78,6 +79,7 @@ endif() option(BOOST_STACKTRACE_ENABLE_NOOP "Boost.Stacktrace: build boost_stacktrace_noop" ON) option(BOOST_STACKTRACE_ENABLE_BACKTRACE "Boost.Stacktrace: build boost_stacktrace_backtrace" ${BOOST_STACKTRACE_HAS_BACKTRACE}) +option(BOOST_STACKTRACE_ENABLE_DWFL "Boost.Stacktrace: build boost_stacktrace_dwfl" ${BOOST_STACKTRACE_HAS_DWFL}) option(BOOST_STACKTRACE_ENABLE_ADDR2LINE "Boost.Stacktrace: build boost_stacktrace_addr2line" ${_default_addr2line}) option(BOOST_STACKTRACE_ENABLE_BASIC "Boost.Stacktrace: build boost_stacktrace_basic" ON) option(BOOST_STACKTRACE_ENABLE_WINDBG "Boost.Stacktrace: build boost_stacktrace_windbg" ${BOOST_STACKTRACE_HAS_WINDBG}) @@ -90,6 +92,7 @@ unset(_default_from_exception) message(STATUS "Boost.Stacktrace: " "noop ${BOOST_STACKTRACE_ENABLE_NOOP}, " "backtrace ${BOOST_STACKTRACE_ENABLE_BACKTRACE}, " + "dwfl ${BOOST_STACKTRACE_ENABLE_DWFL}, " "addr2line ${BOOST_STACKTRACE_ENABLE_ADDR2LINE}, " "basic ${BOOST_STACKTRACE_ENABLE_BASIC}, " "windbg ${BOOST_STACKTRACE_ENABLE_WINDBG}, " @@ -99,6 +102,7 @@ message(STATUS "Boost.Stacktrace: " stacktrace_add_library(noop ${BOOST_STACKTRACE_ENABLE_NOOP} "" "") stacktrace_add_library(backtrace ${BOOST_STACKTRACE_ENABLE_BACKTRACE} "backtrace;${CMAKE_DL_LIBS}" "") +stacktrace_add_library(dwfl ${BOOST_STACKTRACE_ENABLE_DWFL} "dw;${CMAKE_DL_LIBS}" "") stacktrace_add_library(addr2line ${BOOST_STACKTRACE_ENABLE_ADDR2LINE} "${CMAKE_DL_LIBS}" "") stacktrace_add_library(basic ${BOOST_STACKTRACE_ENABLE_BASIC} "${CMAKE_DL_LIBS}" "") stacktrace_add_library(windbg ${BOOST_STACKTRACE_ENABLE_WINDBG} "dbgeng;ole32" "_GNU_SOURCE=1") @@ -119,6 +123,10 @@ elseif(BOOST_STACKTRACE_ENABLE_BACKTRACE) target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_backtrace) +elseif(BOOST_STACKTRACE_ENABLE_DWFL) + + target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_dwfl) + elseif(BOOST_STACKTRACE_ENABLE_ADDR2LINE) target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_addr2line) diff --git a/build.jam b/build.jam index 8ea7a38..93bdaeb 100644 --- a/build.jam +++ b/build.jam @@ -22,6 +22,7 @@ project /boost/stacktrace explicit [ alias boost_stacktrace_addr2line : build//boost_stacktrace_addr2line ] [ alias boost_stacktrace_backtrace : build//boost_stacktrace_backtrace ] + [ alias boost_stacktrace_dwfl : build//boost_stacktrace_dwfl ] [ alias boost_stacktrace_basic : build//boost_stacktrace_basic ] [ alias boost_stacktrace_from_exception : build//boost_stacktrace_from_exception ] [ alias boost_stacktrace_noop : build//boost_stacktrace_noop ] @@ -31,6 +32,7 @@ explicit [ alias all : boost_stacktrace_addr2line boost_stacktrace_backtrace + boost_stacktrace_dwfl boost_stacktrace_basic boost_stacktrace_from_exception boost_stacktrace_noop @@ -44,6 +46,7 @@ call-if : boost-library stacktrace : install boost_stacktrace_addr2line boost_stacktrace_backtrace + boost_stacktrace_dwfl boost_stacktrace_basic boost_stacktrace_from_exception boost_stacktrace_noop diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index ce57c34..8f75d9a 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -28,6 +28,7 @@ lib dl ; lib gcc_s ; lib Dbgeng ; lib ole32 ; +lib dw ; local LIBBACKTRACE_PATH = [ modules.peek : LIBBACKTRACE_PATH ] ; lib backtrace @@ -54,6 +55,9 @@ rule mp-run-simple ( sources + : args * : input-files * : requirements * : targe mp-run-simple has_backtrace.cpp : : : backtrace : libbacktrace ; explicit libbacktrace ; +mp-run-simple has_dwfl.cpp : : : dw : libdw ; +explicit libdw ; + mp-run-simple has_addr2line.cpp : : : : addr2line ; explicit addr2line ; @@ -90,6 +94,21 @@ lib boost_stacktrace_backtrace BOOST_STACKTRACE_NO_LIB=1 ; +lib boost_stacktrace_dwfl + : # sources + ../src/dwfl.cpp + : # requirements + all + linux:dl + dw + shared:BOOST_STACKTRACE_DYN_LINK=1 + [ check-target-builds libdw : : no ] + : # default build + : # usage-requirements + #shared:BOOST_STACKTRACE_DYN_LINK=1 + BOOST_STACKTRACE_NO_LIB=1 + ; + lib boost_stacktrace_addr2line : # sources ../src/addr2line.cpp diff --git a/build/has_dwfl.cpp b/build/has_dwfl.cpp new file mode 100644 index 0000000..6d86e8d --- /dev/null +++ b/build/has_dwfl.cpp @@ -0,0 +1,10 @@ +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +int main() { + Dwfl_Callbacks callbacks{nullptr, nullptr, nullptr, nullptr}; + Dwfl* dwfl_ = dwfl_begin(&callbacks); +} diff --git a/doc/stacktrace.qbk b/doc/stacktrace.qbk index 65914f0..18d6cb3 100644 --- a/doc/stacktrace.qbk +++ b/doc/stacktrace.qbk @@ -321,6 +321,7 @@ In header only mode library could be tuned by macro. If one of the link macro fr [[*BOOST_STACKTRACE_USE_BACKTRACE*] [*boost_stacktrace_backtrace*] [Requires linking with *libdl* on POSIX and *libbacktrace* libraries[footnote Some *libbacktrace* packages SEGFAULT if there's a concurrent work with the same `backtrace_state` instance. To avoid that issue the Boost.Stacktrace library uses `thread_local` states, unfortunately this may consume a lot of memory if you often create and destroy execution threads in your application. Define *BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC* to force single instance, but make sure that [@https://github.com/boostorg/stacktrace/blob/develop/test/thread_safety_checking.cpp thread_safety_checking.cpp] works well in your setup. ]. *libbacktrace* is probably already installed in your system[footnote If you are using Clang with libstdc++ you could get into troubles of including ``, because on some platforms Clang does not search for headers in the GCC's include paths and any attempt to add GCC's include path leads to linker errors. To explicitly specify a path to the `` header you could define the *BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE* to a full path to the header. For example on Ubuntu Xenial use the command line option *-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=* while building with Clang. ], or built into your compiler. Otherwise (if you are a *MinGW*/*MinGW-w64* user for example) it can be downloaded [@https://github.com/ianlancetaylor/libbacktrace from here] or [@https://github.com/gcc-mirror/gcc/tree/master/libbacktrace from here]. ] [Any compiler on POSIX, or MinGW, or MinGW-w64] [yes] [yes]] + [[*BOOST_STACKTRACE_USE_DWFL*] [*boost_stacktrace_dwfl*] [Use *libdwfl* from *elfutils*.] [POSIX] [yes] [yes]] [[*BOOST_STACKTRACE_USE_ADDR2LINE*] [*boost_stacktrace_addr2line*] [Use *addr2line* program to retrieve stacktrace. Requires linking with *libdl* library and `::fork` system call. Macro *BOOST_STACKTRACE_ADDR2LINE_LOCATION* must be defined to the absolute path to the addr2line executable if it is not located in /usr/bin/addr2line. ] [Any compiler on POSIX] [yes] [yes]] [[*BOOST_STACKTRACE_USE_NOOP*] [*boost_stacktrace_noop*] [Use this if you wish to disable backtracing. `stacktrace::size()` with that macro always returns 0. ] [All] [no] [no]] ] diff --git a/include/boost/stacktrace/detail/frame_unwind.ipp b/include/boost/stacktrace/detail/frame_unwind.ipp index a985515..7de1cf7 100644 --- a/include/boost/stacktrace/detail/frame_unwind.ipp +++ b/include/boost/stacktrace/detail/frame_unwind.ipp @@ -23,6 +23,8 @@ #ifdef BOOST_STACKTRACE_USE_BACKTRACE # include +#elif defined(BOOST_STACKTRACE_USE_DWFL) +# include #elif defined(BOOST_STACKTRACE_USE_ADDR2LINE) # include #else diff --git a/include/boost/stacktrace/detail/libdwfl_impls.hpp b/include/boost/stacktrace/detail/libdwfl_impls.hpp new file mode 100644 index 0000000..a31b9a1 --- /dev/null +++ b/include/boost/stacktrace/detail/libdwfl_impls.hpp @@ -0,0 +1,116 @@ +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_STACKTRACE_DETAIL_LIBDWFL_IMPLS_HPP +#define BOOST_STACKTRACE_DETAIL_LIBDWFL_IMPLS_HPP + +#include + +#include +#include + +namespace boost { namespace stacktrace { namespace detail { + +class dwfl_handle { +public: + dwfl_handle() noexcept + : dwfl_(dwfl_begin(&callbacks_)) + { + if (dwfl_) { + dwfl_linux_proc_report(dwfl_, getpid()); + dwfl_report_end(dwfl_, nullptr, nullptr); + } + } + + ~dwfl_handle() { + if (dwfl_) { + dwfl_end(dwfl_); + } + } + + const char* function(Dwarf_Addr addr) const noexcept { + if (!dwfl_ || !addr) { + return nullptr; + } + + Dwfl_Module* dwfl_module = dwfl_addrmodule (dwfl_, addr); + return dwfl_module ? dwfl_module_addrname(dwfl_module, addr) : nullptr; + } + + std::pair source(Dwarf_Addr addr) const noexcept { + if (!dwfl_ || !addr) { + return {nullptr, 0}; + } + + Dwfl_Line* dwfl_line = dwfl_getsrc(dwfl_, addr); + if (!dwfl_line) { + return {nullptr, 0}; + } + + int line{0}; + const char* filename = dwfl_lineinfo(dwfl_line, nullptr, &line, nullptr, nullptr, nullptr); + return {filename, static_cast(line)}; + } + +private: + Dwfl_Callbacks callbacks_{ + .find_elf = dwfl_linux_proc_find_elf, + .find_debuginfo = dwfl_build_id_find_debuginfo, + .section_address = dwfl_offline_section_address, + .debuginfo_path = nullptr, + }; + Dwfl* dwfl_; +}; + +struct to_string_using_dwfl { + std::string res; + dwfl_handle dwfl; + + void prepare_function_name(const void* addr) noexcept { + const char* function = dwfl.function(reinterpret_cast(addr)); + if (function) { + res = function; + } + } + + bool prepare_source_location(const void* addr) noexcept { + auto [filename, line] = dwfl.source(reinterpret_cast(addr)); + if (!filename) { + return false; + } + + res += " at "; + res += filename; + res += ':'; + res += boost::stacktrace::detail::to_dec_array(line).data(); + + return true; + } +}; + +template class to_string_impl_base; +typedef to_string_impl_base to_string_impl; + +inline std::string name_impl(const void* addr) { + dwfl_handle dwfl; + const char* function = dwfl.function(reinterpret_cast(addr)); + return function ? std::string{function} : std::string{}; +} + +} // namespace detail + +std::string frame::source_file() const { + detail::dwfl_handle dwfl; + auto [filename, _] = dwfl.source(reinterpret_cast(addr_)); + return filename ? std::string{filename} : std::string{}; +} + +std::size_t frame::source_line() const { + detail::dwfl_handle dwfl; + return dwfl.source(reinterpret_cast(addr_)).second; +} + +}} // namespace boost::stacktrace + +#endif // BOOST_STACKTRACE_DETAIL_LIBDWFL_IMPLS_HPP diff --git a/src/dwfl.cpp b/src/dwfl.cpp new file mode 100644 index 0000000..d88745b --- /dev/null +++ b/src/dwfl.cpp @@ -0,0 +1,14 @@ +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS +#define BOOST_STACKTRACE_USE_DWFL +#define BOOST_STACKTRACE_LINK + +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif + +#include +#include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index afe56f7..0fc0751 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,3 +12,7 @@ boost_test(TYPE run SOURCES test.cpp test_impl.cpp LINK_LIBRARIES Boost::stacktr boost_test(TYPE run SOURCES test_noop.cpp test_impl.cpp LINK_LIBRARIES Boost::stacktrace_noop Boost::core) boost_test(TYPE run SOURCES test_trivial.cpp LINK_LIBRARIES Boost::stacktrace Boost::core) + +if(BOOST_STACKTRACE_ENABLE_DWFL) + boost_test(TYPE run NAME test_dwfl SOURCES test.cpp test_impl.cpp COMPILE_DEFINITIONS BOOST_STACKTRACE_USE_DWFL LINK_LIBRARIES Boost::stacktrace_dwfl Boost::core) +endif() diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 72c3aa2..caf7118 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -14,6 +14,7 @@ lib gcc_s ; lib rt ; lib Dbgeng ; lib ole32 ; +lib dw ; local LIBBACKTRACE_PATH = [ modules.peek : LIBBACKTRACE_PATH ] ; lib backtrace @@ -44,6 +45,7 @@ local FORCE_SYMBOL_EXPORT = freebsd:"-rdynamic" BOOST_STACKTRACE_TEST_EXPORTS_TABLE_USAGE ; local BT_DEPS = linux:dl backtrace [ check-target-builds ../build//libbacktrace : : no ] ; +local DWFL_DEPS = linux:dl dw [ check-target-builds ../build//libdw : : no ] ; local AD2L_DEPS = linux:dl [ check-target-builds ../build//addr2line : : no ] BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL # Some old versions of addr2line may not produce readable names for a modern compilers ; @@ -53,6 +55,7 @@ local NOOP_DEPS = ; local BASIC_DEPS = linux:dl [ check-target-builds ../build//WinDbg : no ] ; local LINKSHARED_BT = shared BOOST_STACKTRACE_DYN_LINK /boost/stacktrace//boost_stacktrace_backtrace $(BT_DEPS) ; +local LINKSHARED_DWFL = shared BOOST_STACKTRACE_DYN_LINK /boost/stacktrace//boost_stacktrace_dwfl $(DWFL_DEPS) ; local LINKSHARED_AD2L = shared BOOST_STACKTRACE_DYN_LINK /boost/stacktrace//boost_stacktrace_addr2line $(AD2L_DEPS) ; local LINKSHARED_WIND = shared BOOST_STACKTRACE_DYN_LINK /boost/stacktrace//boost_stacktrace_windbg $(WIND_DEPS) ; local LINKSHARED_WIND_CACHED = shared BOOST_STACKTRACE_DYN_LINK /boost/stacktrace//boost_stacktrace_windbg_cached $(WICA_DEPS) ; @@ -61,6 +64,7 @@ local LINKSHARED_BASIC = shared BOOST_STACKTRACE_DYN_LINK < # Libs with debug symbols lib test_impl_lib_backtrace : test_impl.cpp : on $(LINKSHARED_BT) ; +lib test_impl_lib_dwfl : test_impl.cpp : on $(LINKSHARED_DWFL) ; lib test_impl_lib_addr2line : test_impl.cpp : on $(LINKSHARED_AD2L) ; lib test_impl_lib_windbg : test_impl.cpp : on $(LINKSHARED_WIND) ; lib test_impl_lib_windbg_cached : test_impl.cpp : on $(LINKSHARED_WIND_CACHED) ; @@ -72,6 +76,7 @@ lib test_impl_lib_basic : test_impl_nohide-obj : on $(LINKSHARED # Libs without debug symbols lib test_impl_lib_backtrace_no_dbg : test_impl.cpp : off $(LINKSHARED_BT) ; +lib test_impl_lib_dwfl_no_dbg : test_impl.cpp : off $(LINKSHARED_DWFL) ; lib test_impl_lib_addr2line_no_dbg : test_impl.cpp : off $(LINKSHARED_AD2L) ; lib test_impl_lib_windbg_no_dbg : test_impl.cpp : off $(LINKSHARED_WIND) ; lib test_impl_lib_windbg_cached_no_dbg : test_impl.cpp : off $(LINKSHARED_WIND_CACHED) ; @@ -87,6 +92,7 @@ test-suite stacktrace_tests # Header only tests with debug symbols [ run test.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : backtrace_ho ] [ run test.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_BACKTRACE BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC $(BT_DEPS) : backtrace_ho_static ] + [ run test.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_DWFL $(DWFL_DEPS) : dwfl_ho ] [ run test.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_ADDR2LINE $(AD2L_DEPS) : addr2line_ho ] [ run test_noop.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : noop_ho ] [ run test.cpp test_impl.cpp : : : on $(WIND_DEPS) : windbg_ho ] @@ -96,6 +102,7 @@ test-suite stacktrace_tests # Header only trivial [ run test_trivial.cpp : : : on BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : trivial_backtrace_ho ] + [ run test_trivial.cpp : : : on BOOST_STACKTRACE_USE_DWFL $(DWFL_DEPS) : trivial_dwfl_ho ] [ run test_trivial.cpp : : : on BOOST_STACKTRACE_USE_ADDR2LINE $(AD2L_DEPS) : trivial_addr2line_ho ] [ run test_trivial.cpp : : : on BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : trivial_noop_ho ] [ run test_trivial.cpp : : : on $(WIND_DEPS) : trivial_windbg_ho ] @@ -105,6 +112,7 @@ test-suite stacktrace_tests # Test with shared linked implementations with debug symbols [ run test.cpp : : : on .//test_impl_lib_backtrace $(LINKSHARED_BT) : backtrace_lib ] + [ run test.cpp : : : on .//test_impl_lib_dwfl $(LINKSHARED_DWFL) : dwfl_lib ] [ run test.cpp : : : on .//test_impl_lib_addr2line $(LINKSHARED_AD2L) : addr2line_lib ] [ run test.cpp : : : on .//test_impl_lib_windbg $(LINKSHARED_WIND) : windbg_lib ] [ run test.cpp : : : on .//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED) : windbg_cached_lib ] @@ -113,6 +121,7 @@ test-suite stacktrace_tests # Trivial test with shared linked implementations with debug symbols [ run test_trivial.cpp : : : on .//test_impl_lib_backtrace $(LINKSHARED_BT) : trivial_backtrace_lib ] + [ run test_trivial.cpp : : : on .//test_impl_lib_dwfl $(LINKSHARED_DWFL) : trivial_dwfl_lib ] [ run test_trivial.cpp : : : on .//test_impl_lib_addr2line $(LINKSHARED_AD2L) : trivial_addr2line_lib ] [ run test_trivial.cpp : : : on .//test_impl_lib_windbg $(LINKSHARED_WIND) : trivial_windbg_lib ] [ run test_trivial.cpp : : : on .//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED) : trivial_windbg_cached_lib ] @@ -128,6 +137,9 @@ test-suite stacktrace_tests BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC /boost/optional//boost_optional : backtrace_lib_threaded_static ] + [ run thread_safety_checking.cpp + : : : on .//test_impl_lib_dwfl $(LINKSHARED_DWFL) + : dwfl_lib_threaded ] [ run thread_safety_checking.cpp : : : on .//test_impl_lib_windbg $(LINKSHARED_WIND) /boost/optional//boost_optional @@ -145,6 +157,7 @@ test-suite stacktrace_tests # Header only tests without debug symbols [ run test.cpp test_impl.cpp : : : off BOOST_STACKTRACE_USE_BACKTRACE $(FORCE_SYMBOL_EXPORT) $(BT_DEPS) : backtrace_ho_no_dbg ] + [ run test.cpp test_impl.cpp : : : off BOOST_STACKTRACE_USE_DWFL $(FORCE_SYMBOL_EXPORT) $(DWFL_DEPS) : dwfl_ho_no_dbg ] [ run test_noop.cpp test_impl.cpp : : : off BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : noop_ho_no_dbg ] [ run test.cpp test_impl.cpp : : : off BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(WIND_DEPS) : windbg_ho_no_dbg ] [ run test.cpp test_impl.cpp : : : off BOOST_STACKTRACE_USE_WINDBG_CACHED BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(WICA_DEPS) : windbg_cached_ho_no_dbg ] @@ -156,6 +169,7 @@ test-suite stacktrace_tests # Test with shared linked implementations without debug symbols [ run test.cpp : : : off .//test_impl_lib_backtrace_no_dbg $(LINKSHARED_BT) $(FORCE_SYMBOL_EXPORT) : backtrace_lib_no_dbg ] + [ run test.cpp : : : off .//test_impl_lib_dwfl_no_dbg $(LINKSHARED_DWFL) $(FORCE_SYMBOL_EXPORT) : dwfl_lib_no_dbg ] [ run test.cpp : : : off .//test_impl_lib_addr2line_no_dbg $(LINKSHARED_AD2L) : addr2line_lib_no_dbg ] [ run test.cpp : : : off .//test_impl_lib_windbg_no_dbg $(LINKSHARED_WIND) BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL : windbg_lib_no_dbg ] [ run test.cpp : : : off .//test_impl_lib_windbg_cached_no_dbg $(LINKSHARED_WIND_CACHED) BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL : windbg_cached_lib_no_dbg ] @@ -169,6 +183,12 @@ test-suite stacktrace_tests /boost/optional//boost_optional $(LINKSHARED_BT) : backtrace_lib_no_dbg_threaded ] + [ run thread_safety_checking.cpp + : : : off + .//test_impl_lib_dwfl_no_dbg + /boost/optional//boost_optional + $(LINKSHARED_DWFL) + : dwfl_lib_no_dbg_threaded ] [ run thread_safety_checking.cpp : : : off .//test_impl_lib_windbg_no_dbg @@ -194,6 +214,8 @@ test-suite stacktrace_tests [ run test_from_exception_none.cpp : : : $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) on : from_exception_none_basic_ho ] [ run test_from_exception_none.cpp : : : $(LINKSHARED_BT) on : from_exception_none_bt ] [ run test_from_exception_none.cpp : : : BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) on : from_exception_none_bt_ho ] + [ run test_from_exception_none.cpp : : : $(LINKSHARED_DWFL) on : from_exception_none_dwfl ] + [ run test_from_exception_none.cpp : : : BOOST_STACKTRACE_USE_DWFL $(DWFL_DEPS) on : from_exception_none_dwfl_ho ] [ run test_from_exception_none.cpp : : : $(LINKSHARED_WIND) on : from_exception_none_windbg ] [ run test_from_exception_none.cpp : : : BOOST_STACKTRACE_USE_WINDBG $(WIND_DEPS) on : from_exception_none_windbg_ho ] [ run test_from_exception_none.cpp : : : $(LINKSHARED_WIND_CACHED) on : from_exception_none_windbg_cached ] @@ -205,6 +227,8 @@ test-suite stacktrace_tests [ run test_from_exception_none.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) on : from_exception_disabled_basic_ho ] [ run test_from_exception_none.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_BT) on : from_exception_disabled_bt ] [ run test_from_exception_none.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : from_exception_disabled_bt_ho ] + [ run test_from_exception_none.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_DWFL) on : from_exception_disabled_dwfl ] + [ run test_from_exception_none.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception BOOST_STACKTRACE_USE_DWFL $(DWFL_DEPS) : from_exception_disabled_dwfl_ho ] [ run test_from_exception_none.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_WIND) on : from_exception_disabled_windbg ] [ run test_from_exception_none.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception BOOST_STACKTRACE_USE_WINDBG $(WIND_DEPS) on : from_exception_disabled_windbg_ho ] [ run test_from_exception_none.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_WIND_CACHED) on : from_exception_disabled_windbg_cached ] @@ -212,11 +236,13 @@ test-suite stacktrace_tests [ link test_from_exception.cpp : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_BASIC) on : from_exception_basic ] [ run test_from_exception.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_BT) on : from_exception_bt ] + [ run test_from_exception.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_DWFL) on : from_exception_dwfl ] [ run test_from_exception.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_WIND) on : from_exception_windbg ] [ run test_from_exception.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception $(LINKSHARED_WIND_CACHED) on : from_exception_windbg_cached ] [ link test_from_exception.cpp : /boost/stacktrace//boost_stacktrace_from_exception $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) on : from_exception_basic_ho ] [ run test_from_exception.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) on : from_exception_bt_ho ] + [ run test_from_exception.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception BOOST_STACKTRACE_USE_DWFL $(DWFL_DEPS) on : from_exception_dwfl_ho ] [ run test_from_exception.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception BOOST_STACKTRACE_USE_WINDBG $(WIND_DEPS) on : from_exception_windbg_ho ] [ run test_from_exception.cpp : : : /boost/stacktrace//boost_stacktrace_from_exception BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) on : from_exception_windbg_cached_ho ] ; @@ -237,6 +263,7 @@ for local p in [ glob ../example/*.cpp ] } stacktrace_tests += [ run $(p) : : : on $(LINKSHARED_BT) $(additional_dependency) : backtrace_$(p2[1]:B) ] ; + stacktrace_tests += [ run $(p) : : : on $(LINKSHARED_DWFL) $(additional_dependency) : dwfl_$(p[1]:B) ] ; stacktrace_tests += [ run $(p) : : : on $(LINKSHARED_AD2L) $(additional_dependency) : addr2line_$(p[1]:B) ] ; stacktrace_tests += [ run $(p) : : : on $(LINKSHARED_WIND) $(additional_dependency) : windbg_$(p[1]:B) ] ; stacktrace_tests += [ run $(p) : : : on $(LINKSHARED_WIND_CACHED) $(additional_dependency) : windbg_cached_$(p[1]:B) ] ; @@ -247,6 +274,7 @@ for local p in [ glob ../example/*.cpp ] ##### Tests with disabled debug symbols ##### stacktrace_tests += [ run $(p) : : : off $(LINKSHARED_BT) $(additional_dependency) : backtrace_$(p[1]:B)_no_dbg ] ; + stacktrace_tests += [ run $(p) : : : off $(LINKSHARED_DWFL) $(additional_dependency) : dwfl_$(p[1]:B)_no_dbg ] ; stacktrace_tests += [ run $(p) : : : off $(LINKSHARED_AD2L) $(additional_dependency) : addr2line_$(p[1]:B)_no_dbg ] ; stacktrace_tests += [ run $(p) : : : off $(LINKSHARED_WIND) $(additional_dependency) : windbg_$(p[1]:B)_no_dbg ] ; stacktrace_tests += [ run $(p) : : : off $(LINKSHARED_WIND_CACHED) $(additional_dependency) : windbg_cached_$(p[1]:B)_no_dbg ] ; @@ -259,6 +287,7 @@ for local p in [ glob ../example/*.cpp ] test-suite stacktrace_torture : [ run torture.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : torture_backtrace_ho ] + [ run torture.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_DWFL $(DWFL_DEPS) : torture_dwfl_ho ] #[ run torture.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_ADDR2LINE $(AD2L_DEPS) : torture_addr2line_ho ] [ run torture.cpp test_impl.cpp : : : on $(WIND_DEPS) : torture_windbg_ho ] [ run torture.cpp test_impl.cpp : : : on BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) : torture_windbg_cached_ho ] @@ -266,6 +295,7 @@ test-suite stacktrace_torture [ run torture.cpp test_impl.cpp : : : on BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(BASIC_DEPS) : torture_basic_ho_empty ] [ run torture.cpp test_impl.cpp : : : on .//test_impl_lib_backtrace $(LINKSHARED_BT) : torture_backtrace_lib ] + [ run torture.cpp test_impl.cpp : : : on .//test_impl_lib_dwfl $(LINKSHARED_DWFL) : torture_dwfl_lib ] #[ run torture.cpp test_impl.cpp : : : on .//test_impl_lib_addr2line $(LINKSHARED_AD2L) : torture_addr2line_lib ] [ run torture.cpp test_impl.cpp : : : on .//test_impl_lib_windbg $(LINKSHARED_WIND) : torture_windbg_lib ] [ run torture.cpp test_impl.cpp : : : on .//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED) : torture_windbg_cached_lib ] diff --git a/test/test.cpp b/test/test.cpp index e9cb5bd..c59a5e9 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -22,8 +22,8 @@ using boost::stacktrace::stacktrace; using boost::stacktrace::frame; -#if (defined(BOOST_GCC) && defined(BOOST_WINDOWS) && !defined(BOOST_STACKTRACE_USE_BACKTRACE) && !defined(BOOST_STACKTRACE_USE_ADDR2LINE)) \ - || defined(BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL) +#if (defined(BOOST_GCC) && defined(BOOST_WINDOWS) && !defined(BOOST_STACKTRACE_USE_BACKTRACE) && !defined(BOOST_STACKTRACE_USE_ADDR2LINE) \ + && !defined(BOOST_STACKTRACE_USE_DWFL)) || defined(BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL) # define BOOST_STACKTRACE_TEST_SHOULD_OUTPUT_READABLE_NAMES 0 #else