feat stacktrace: independent dump library (#227)

This pull request introduces `boost_stacktrace_dump` library that is independent from backtrace implementations.
The purpose is to make `boost_stacktrace_from_exception` also independent from specific backtrace implementation to further introduce C++20 modules support.

As well, all stacktrace tests added to CMake CI. Header only library test also was added to CMake test.
This commit is contained in:
Fedor Osetrov
2026-04-28 15:00:43 +03:00
committed by GitHub
parent d1e329d56b
commit 8dd3018808
25 changed files with 199 additions and 104 deletions
+53 -39
View File
@@ -1,4 +1,5 @@
# Copyright 2020, 2021 Peter Dimov
# Copyright 2026 Fedor Osetrov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
@@ -6,15 +7,13 @@ cmake_minimum_required(VERSION 3.8...4.20)
project(boost_stacktrace VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
function(stacktrace_add_library suffix opt libs defs)
function(stacktrace_add_library suffix opt public_libs libs defs)
if(NOT opt)
return()
endif()
add_library(boost_stacktrace_${suffix}
src/${suffix}.cpp
)
add_library(boost_stacktrace_${suffix})
add_library(Boost::stacktrace_${suffix} ALIAS boost_stacktrace_${suffix})
@@ -27,13 +26,21 @@ function(stacktrace_add_library suffix opt libs defs)
Boost::core
Boost::predef
Boost::winapi
${public_libs}
PRIVATE
${libs}
)
target_compile_definitions(boost_stacktrace_${suffix}
PUBLIC BOOST_STACKTRACE_NO_LIB
PRIVATE BOOST_STACKTRACE_SOURCE ${defs}
PUBLIC
BOOST_STACKTRACE_NO_LIB
PRIVATE
${defs}
)
target_sources(boost_stacktrace_${suffix}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/${suffix}.cpp
)
if(BUILD_SHARED_LIBS)
@@ -50,26 +57,25 @@ endfunction()
include(CheckCXXSourceCompiles)
function(stacktrace_check var source incs libs defs)
function(stacktrace_check var source incs libs)
set(CMAKE_REQUIRED_INCLUDES "${incs}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/build")
set(CMAKE_REQUIRED_LIBRARIES "${libs}")
set(CMAKE_REQUIRED_DEFINITIONS "${defs}")
check_cxx_source_compiles("#include \"${source}\"" ${var})
set(${var} ${${var}} PARENT_SCOPE)
endfunction()
stacktrace_check(BOOST_STACKTRACE_HAS_BACKTRACE has_backtrace.cpp "" "backtrace" "")
stacktrace_check(BOOST_STACKTRACE_HAS_BACKTRACE has_backtrace.cpp "" "backtrace")
set(_default_addr2line ON)
if(WIN32 AND NOT CMAKE_CXX_PLATFORM_ID MATCHES "Cygwin")
set(_default_addr2line OFF)
endif()
stacktrace_check(BOOST_STACKTRACE_HAS_WINDBG has_windbg.cpp "" "dbgeng;ole32" "")
stacktrace_check(BOOST_STACKTRACE_HAS_WINDBG_CACHED has_windbg_cached.cpp "${CMAKE_CURRENT_SOURCE_DIR}/../config/include" "dbgeng;ole32" "")
stacktrace_check(BOOST_STACKTRACE_HAS_WINDBG has_windbg.cpp "" "dbgeng;ole32")
stacktrace_check(BOOST_STACKTRACE_HAS_WINDBG_CACHED has_windbg_cached.cpp "${CMAKE_CURRENT_SOURCE_DIR}/../config/include" "dbgeng;ole32")
set(_default_from_exception ON)
if (CMAKE_CXX_PLATFORM_ID MATCHES "Cygwin")
@@ -97,51 +103,59 @@ message(STATUS "Boost.Stacktrace: "
"from_exception ${BOOST_STACKTRACE_ENABLE_FROM_EXCEPTION}"
)
stacktrace_add_library(noop ${BOOST_STACKTRACE_ENABLE_NOOP} "" "")
stacktrace_add_library(backtrace ${BOOST_STACKTRACE_ENABLE_BACKTRACE} "backtrace;${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")
stacktrace_add_library(windbg_cached ${BOOST_STACKTRACE_ENABLE_WINDBG_CACHED} "dbgeng;ole32" "_GNU_SOURCE=1")
if(BOOST_STACKTRACE_ENABLE_BACKTRACE OR
BOOST_STACKTRACE_ENABLE_ADDR2LINE OR
BOOST_STACKTRACE_ENABLE_BASIC OR
BOOST_STACKTRACE_ENABLE_WINDBG OR
BOOST_STACKTRACE_ENABLE_WINDBG_CACHED
)
set(_enable_non_noop_backend TRUE)
endif()
if(_enable_non_noop_backend)
stacktrace_add_library(dump ON "" "" "")
endif()
stacktrace_add_library(noop ${BOOST_STACKTRACE_ENABLE_NOOP} "" "" "")
stacktrace_add_library(backtrace ${BOOST_STACKTRACE_ENABLE_BACKTRACE} Boost::stacktrace_dump "backtrace;${CMAKE_DL_LIBS}" "")
stacktrace_add_library(addr2line ${BOOST_STACKTRACE_ENABLE_ADDR2LINE} Boost::stacktrace_dump "${CMAKE_DL_LIBS}" "")
stacktrace_add_library(basic ${BOOST_STACKTRACE_ENABLE_BASIC} Boost::stacktrace_dump "${CMAKE_DL_LIBS}" "")
stacktrace_add_library(windbg ${BOOST_STACKTRACE_ENABLE_WINDBG} Boost::stacktrace_dump "dbgeng;ole32" "_GNU_SOURCE=1")
stacktrace_add_library(windbg_cached ${BOOST_STACKTRACE_ENABLE_WINDBG_CACHED} Boost::stacktrace_dump "dbgeng;ole32" "_GNU_SOURCE=1")
# boost_stacktrace, default library
add_library(boost_stacktrace INTERFACE)
add_library(Boost::stacktrace ALIAS boost_stacktrace)
target_include_directories(boost_stacktrace INTERFACE include)
add_library(Boost::stacktrace ALIAS boost_stacktrace)
if(BOOST_STACKTRACE_ENABLE_WINDBG)
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_windbg)
set(__default_stacktrace_backend "windbg")
elseif(BOOST_STACKTRACE_ENABLE_WINDBG_CACHED)
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_windbg)
set(__default_stacktrace_backend "windbg_cached")
elseif(BOOST_STACKTRACE_ENABLE_BACKTRACE)
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_backtrace)
set(__default_stacktrace_backend "backtrace")
elseif(BOOST_STACKTRACE_ENABLE_ADDR2LINE)
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_addr2line)
set(__default_stacktrace_backend "addr2line")
elseif(BOOST_STACKTRACE_ENABLE_BASIC)
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_basic)
set(__default_stacktrace_backend "basic")
elseif(BOOST_STACKTRACE_ENABLE_NOOP)
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_noop)
set(__default_stacktrace_backend "noop")
else()
message(FATAL "All backends are disabled")
endif()
# Boost::stacktrace_from_exception is never the default
stacktrace_add_library(from_exception ${BOOST_STACKTRACE_ENABLE_FROM_EXCEPTION} "${CMAKE_DL_LIBS};boost_stacktrace" "")
message(STATUS "Boost.stacktrace default backend: ${__default_stacktrace_backend}")
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_${__default_stacktrace_backend})
#
# Boost::stacktrace_from_exception is never the default
if(_enable_non_noop_backend)
stacktrace_add_library(from_exception ${BOOST_STACKTRACE_ENABLE_FROM_EXCEPTION} Boost::stacktrace_dump "${CMAKE_DL_LIBS}" "")
unset(_enable_non_noop_backend)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()
unset(__default_stacktrace_backend)
+4 -1
View File
@@ -20,8 +20,9 @@ project /boost/stacktrace
;
explicit
[ alias boost_stacktrace_addr2line : build//boost_stacktrace_addr2line ]
[ alias boost_stacktrace_dump : build//boost_stacktrace_dump ]
[ alias boost_stacktrace_backtrace : build//boost_stacktrace_backtrace ]
[ alias boost_stacktrace_addr2line : build//boost_stacktrace_addr2line ]
[ 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 ]
@@ -29,6 +30,7 @@ explicit
[ alias boost_stacktrace_windbg_cached : build//boost_stacktrace_windbg_cached ]
[ alias boost_stacktrace : boost_stacktrace_noop ]
[ alias all :
boost_stacktrace_dump
boost_stacktrace_addr2line
boost_stacktrace_backtrace
boost_stacktrace_basic
@@ -42,6 +44,7 @@ explicit
call-if : boost-library stacktrace
: install
boost_stacktrace_dump
boost_stacktrace_addr2line
boost_stacktrace_backtrace
boost_stacktrace_basic
+23
View File
@@ -65,6 +65,17 @@ explicit WinDbg ;
mp-run-simple has_windbg_cached.cpp : : : <library>Dbgeng <library>ole32 : WinDbgCached ;
explicit WinDbgCached ;
lib boost_stacktrace_dump
: # sources
../src/dump.cpp
: # requirements
<warnings>all
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
: # default build
: # usage-requirements
<define>BOOST_STACKTRACE_NO_LIB=1
;
rule build-stacktrace-noop ( props * )
{
local enabled = [ property.select <boost.stacktrace.noop> : $(props) ] ;
@@ -109,6 +120,7 @@ lib boost_stacktrace_backtrace
: # requirements
<warnings>all
<target-os>linux:<library>dl
<library>boost_stacktrace_dump
<library>backtrace
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<conditional>@build-stacktrace-backtrace
@@ -116,6 +128,7 @@ lib boost_stacktrace_backtrace
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
<library>boost_stacktrace_dump
;
rule build-stacktrace-addr2line ( props * )
@@ -146,12 +159,14 @@ lib boost_stacktrace_addr2line
: # requirements
<warnings>all
<target-os>linux:<library>dl
<library>boost_stacktrace_dump
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<conditional>@build-stacktrace-addr2line
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
<library>boost_stacktrace_dump
;
rule build-stacktrace-basic ( props * )
@@ -175,12 +190,14 @@ lib boost_stacktrace_basic
: # requirements
<warnings>all
<target-os>linux:<library>dl
<library>boost_stacktrace_dump
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<conditional>@build-stacktrace-basic
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
<library>boost_stacktrace_dump
;
rule build-stacktrace-windbg ( props * )
@@ -203,6 +220,7 @@ lib boost_stacktrace_windbg
../src/windbg.cpp
: # requirements
<warnings>all
<library>boost_stacktrace_dump
<library>Dbgeng <library>ole32
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<conditional>@build-stacktrace-windbg
@@ -210,6 +228,7 @@ lib boost_stacktrace_windbg
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
<library>boost_stacktrace_dump
;
rule build-stacktrace-windbg-cached ( props * )
@@ -232,6 +251,7 @@ lib boost_stacktrace_windbg_cached
../src/windbg_cached.cpp
: # requirements
<warnings>all
<library>boost_stacktrace_dump
<library>Dbgeng <library>ole32
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<conditional>@build-stacktrace-windbg-cached
@@ -239,6 +259,7 @@ lib boost_stacktrace_windbg_cached
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
<library>boost_stacktrace_dump
;
rule build-stacktrace-from-exception ( props * )
@@ -264,6 +285,7 @@ lib boost_stacktrace_from_exception
: # requirements
<warnings>all
<target-os>linux:<library>dl
<library>boost_stacktrace_dump
<target-os>windows:<library>ucrt
# Enable build when explicitly requested, or by default, when on x86
@@ -272,4 +294,5 @@ lib boost_stacktrace_from_exception
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
<library>boost_stacktrace_dump
;
@@ -12,7 +12,6 @@
# pragma once
#endif
#include <iosfwd>
#include <string>
#include <boost/stacktrace/safe_dump_to.hpp> // boost::stacktrace::detail::native_frame_ptr_t
+1 -3
View File
@@ -15,8 +15,6 @@
#include <iosfwd>
#include <string>
#include <boost/stacktrace/safe_dump_to.hpp> // boost::stacktrace::detail::native_frame_ptr_t
#include <boost/stacktrace/detail/frame_decl.hpp>
#include <boost/stacktrace/detail/push_options.h>
@@ -64,7 +62,7 @@ std::basic_ostream<CharT, TraitsT>& operator<<(std::basic_ostream<CharT, TraitsT
#include <boost/stacktrace/detail/pop_options.h>
#ifndef BOOST_STACKTRACE_LINK
#if !defined(BOOST_STACKTRACE_LINK)
# if defined(BOOST_STACKTRACE_USE_NOOP)
# include <boost/stacktrace/detail/frame_noop.ipp>
# elif defined(BOOST_MSVC) || defined(BOOST_STACKTRACE_USE_WINDBG) || defined(BOOST_STACKTRACE_USE_WINDBG_CACHED)
+1 -1
View File
@@ -205,7 +205,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_dep
#include <boost/stacktrace/detail/pop_options.h>
#if !defined(BOOST_STACKTRACE_LINK) || defined(BOOST_STACKTRACE_INTERNAL_BUILD_LIBS)
#if !defined(BOOST_STACKTRACE_LINK)
# if defined(BOOST_STACKTRACE_USE_NOOP)
# include <boost/stacktrace/detail/safe_dump_noop.ipp>
# include <boost/stacktrace/detail/collect_noop.ipp>
+1 -1
View File
@@ -13,4 +13,4 @@
#endif
#include <boost/stacktrace/detail/frame_unwind.ipp>
#include <boost/stacktrace/safe_dump_to.hpp>
+1 -1
View File
@@ -13,4 +13,4 @@
#endif
#include <boost/stacktrace/detail/frame_unwind.ipp>
#include <boost/stacktrace/safe_dump_to.hpp>
-1
View File
@@ -12,4 +12,3 @@
#endif
#include <boost/stacktrace/detail/frame_unwind.ipp>
#include <boost/stacktrace/safe_dump_to.hpp>
+26
View File
@@ -0,0 +1,26 @@
// Copyright Antony Polukhin, 2025-2026
// Copyright Fedor Osetrov, 2025-2026
//
// 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_LINK
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include <boost/config.hpp>
#if defined(BOOST_WINDOWS)
# include <boost/stacktrace/detail/safe_dump_win.ipp>
#else
# include <boost/stacktrace/detail/safe_dump_posix.ipp>
#endif
#if defined(BOOST_WINDOWS) && !defined(BOOST_WINAPI_IS_MINGW) // MinGW does not provide RtlCaptureStackBackTrace. MinGW-w64 does.
# include <boost/stacktrace/detail/collect_msvc.ipp>
#else
# include <boost/stacktrace/detail/collect_unwind.ipp>
#endif
+7 -2
View File
@@ -4,10 +4,13 @@
// 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_LINK
#if defined(__MINGW32__) || defined(_MSC_VER)
#include <boost/stacktrace/safe_dump_to.hpp>
#include <windows.h>
#include <boost/stacktrace/safe_dump_to.hpp>
extern "C" void** __cdecl __current_exception(); // exported from vcruntime.dll
#define _pCurrentException static_cast<PEXCEPTION_RECORD>(*__current_exception())
@@ -154,7 +157,7 @@ BOOST_SYMBOL_EXPORT void assert_no_pending_traces() noexcept {
#endif
#include <boost/assert.hpp>
#include <boost/stacktrace/safe_dump_to.hpp>
#include <boost/config.hpp>
#include <cstddef>
#include <exception>
@@ -170,6 +173,8 @@ BOOST_SYMBOL_EXPORT void assert_no_pending_traces() noexcept {
#include <unistd.h>
#endif
#include <boost/stacktrace/safe_dump_to.hpp>
namespace {
constexpr std::size_t kStacktraceDumpSize = 4096;
+2 -1
View File
@@ -6,6 +6,7 @@
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
#define BOOST_STACKTRACE_LINK
#define BOOST_STACKTRACE_USE_NOOP
#include <boost/stacktrace/detail/frame_noop.ipp>
#include <boost/stacktrace/detail/safe_dump_noop.ipp>
#include <boost/stacktrace/detail/collect_noop.ipp>
+3 -3
View File
@@ -4,11 +4,11 @@
// 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_LINK
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
#define BOOST_STACKTRACE_LINK
#include <boost/stacktrace/detail/frame_msvc.ipp>
#include <boost/stacktrace/safe_dump_to.hpp>
+4 -4
View File
@@ -4,12 +4,12 @@
// 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_WINDBG_CACHED
#define BOOST_STACKTRACE_LINK
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
#define BOOST_STACKTRACE_LINK
#define BOOST_STACKTRACE_USE_WINDBG_CACHED
#include <boost/stacktrace/detail/frame_msvc.ipp>
#include <boost/stacktrace/safe_dump_to.hpp>
+24 -7
View File
@@ -1,14 +1,31 @@
# Copyright 2018-2020 Peter Dimov
# Copyright 2026 Fedor Osetrov
# 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(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(NOT HAVE_BOOST_TEST)
return()
if(NOT TARGET tests)
add_custom_target(tests)
endif()
boost_test(TYPE run SOURCES test.cpp test_impl.cpp LINK_LIBRARIES Boost::stacktrace Boost::core)
boost_test(TYPE run SOURCES test_noop.cpp test_impl.cpp LINK_LIBRARIES Boost::stacktrace_noop Boost::core)
function(add_stacktrace_test name libs sources)
set(test_name stacktrace_${name})
boost_test(TYPE run SOURCES test_trivial.cpp LINK_LIBRARIES Boost::stacktrace Boost::core)
add_executable(${test_name} ${name}.cpp ${sources})
target_link_libraries(${test_name} PRIVATE ${libs})
add_test(NAME ${test_name} COMMAND ${test_name})
add_dependencies(tests ${test_name})
endfunction()
add_stacktrace_test(test_num_conv Boost::stacktrace "")
add_stacktrace_test(test_void_ptr_cast Boost::stacktrace "")
add_stacktrace_test(test_noop Boost::stacktrace_noop test_impl.cpp)
add_stacktrace_test(test_trivial Boost::stacktrace test_impl.cpp)
add_stacktrace_test(test Boost::stacktrace test_impl.cpp)
add_stacktrace_test(test_thread_safety_checking "Boost::stacktrace;Boost::optional" test_impl.cpp)
add_stacktrace_test(test_from_exception_none Boost::stacktrace "")
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_stacktrace_test(test_from_exception "Boost::stacktrace;Boost::stacktrace_from_exception" "")
endif()
if(NOT __default_stacktrace_backend STREQUAL "addr2line")
add_stacktrace_test(test_torture Boost::stacktrace test_impl.cpp)
endif()
+20 -20
View File
@@ -120,23 +120,23 @@ test-suite stacktrace_tests
[ run test_trivial.cpp : : : <debug-symbols>on <library>.//test_impl_lib_basic $(LINKSHARED_BASIC) : trivial_basic_lib ]
# Thread safety with debug symbols
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT)
: backtrace_lib_threaded ]
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT)
<define>BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC
<library>/boost/optional//boost_optional
: backtrace_lib_threaded_static ]
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_windbg $(LINKSHARED_WIND)
<library>/boost/optional//boost_optional
: windbg_lib_threaded ]
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED)
<library>/boost/optional//boost_optional
: windbg_cached_lib_threaded ]
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_basic $(LINKSHARED_BASIC)
<library>/boost/optional//boost_optional
: basic_lib_threaded ]
@@ -163,23 +163,23 @@ test-suite stacktrace_tests
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_basic_no_dbg $(LINKSHARED_BASIC) : basic_lib_no_dbg ]
# Thread safety without debug symbols
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>off
<library>.//test_impl_lib_backtrace_no_dbg
<library>/boost/optional//boost_optional
$(LINKSHARED_BT)
: backtrace_lib_no_dbg_threaded ]
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>off
<library>.//test_impl_lib_windbg_no_dbg
$(LINKSHARED_WIND)
: windbg_lib_no_dbg_threaded ]
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>off
<library>.//test_impl_lib_windbg_cached_no_dbg
$(LINKSHARED_WIND_CACHED)
: windbg_cached_lib_no_dbg_threaded ]
[ run thread_safety_checking.cpp
[ run test_thread_safety_checking.cpp
: : : <debug-symbols>off
<library>.//test_impl_lib_basic_no_dbg
$(LINKSHARED_BASIC)
@@ -258,18 +258,18 @@ for local p in [ glob ../example/*.cpp ]
# Very long tests for detecting memory leaks and corruptions
test-suite stacktrace_torture
:
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : torture_backtrace_ho ]
#[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_ADDR2LINE $(AD2L_DEPS) : torture_addr2line_ho ]
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on $(WIND_DEPS) : torture_windbg_ho ]
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) : torture_windbg_cached_ho ]
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) : torture_basic_ho ]
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(BASIC_DEPS) : torture_basic_ho_empty ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : torture_backtrace_ho ]
#[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_ADDR2LINE $(AD2L_DEPS) : torture_addr2line_ho ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on $(WIND_DEPS) : torture_windbg_ho ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) : torture_windbg_cached_ho ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) : torture_basic_ho ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(BASIC_DEPS) : torture_basic_ho_empty ]
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : torture_backtrace_lib ]
#[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_addr2line $(LINKSHARED_AD2L) : torture_addr2line_lib ]
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_windbg $(LINKSHARED_WIND) : torture_windbg_lib ]
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED) : torture_windbg_cached_lib ]
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_basic $(LINKSHARED_BASIC) : torture_basic_lib ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : torture_backtrace_lib ]
#[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_addr2line $(LINKSHARED_AD2L) : torture_addr2line_lib ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_windbg $(LINKSHARED_WIND) : torture_windbg_lib ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED) : torture_windbg_cached_lib ]
[ run test_torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_basic $(LINKSHARED_BASIC) : torture_basic_lib ]
;
explicit stacktrace_torture ;
+1 -1
View File
@@ -13,6 +13,6 @@ int main()
try {
throw 42;
} catch (...) {
std::cout << "From current excption:\n" << boost::stacktrace::stacktrace::from_current_exception() << std::endl;
std::cout << "From current exception:\n" << boost::stacktrace::stacktrace::from_current_exception() << std::endl;
}
}
+13 -6
View File
@@ -2,15 +2,12 @@
# 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
cmake_minimum_required(VERSION 3.5...3.20)
cmake_minimum_required(VERSION 3.5...4.20)
project(cmake_subdir_test LANGUAGES CXX)
# Put boost_stacktrace_*.dll in the same directory as main.exe
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_subdirectory(../.. boostorg/stacktrace)
# boostdep --brief stacktrace
set(deps
@@ -29,6 +26,8 @@ winapi
describe
mp11
throw_exception
optional
type_traits
)
@@ -38,8 +37,16 @@ foreach(dep IN LISTS deps)
endforeach()
enable_testing()
add_subdirectory(../.. boostorg/stacktrace)
add_executable(main main.cpp)
target_link_libraries(main Boost::stacktrace)
enable_testing()
add_test(main main)
add_executable(main_header_only main.cpp)
target_include_directories(main_header_only PRIVATE ../../include)
target_compile_definitions(main_header_only PRIVATE "_GNU_SOURCE=1")
target_link_libraries(main_header_only PRIVATE Boost::core Boost::container_hash Boost::predef Boost::winapi)
add_test(NAME main COMMAND main)
add_test(NAME main_header_only COMMAND main_header_only)
+7 -1
View File
@@ -7,7 +7,6 @@
#include <boost/stacktrace/stacktrace_fwd.hpp>
#include <boost/stacktrace.hpp>
#include <stdexcept>
#include <fstream>
#include <iostream>
#include <sstream>
@@ -106,8 +105,15 @@ void test_nested(bool print = true) {
template <class Bt>
void test_comparisons_base(Bt nst, Bt st) {
Bt cst(st);
#if defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wself-assign-overloaded"
#endif
st = st;
cst = cst;
#if defined(__clang__)
#pragma GCC diagnostic pop
#endif
BOOST_TEST(nst);
BOOST_TEST(st);
#if !defined(BOOST_MSVC) && !defined(BOOST_STACKTRACE_USE_WINDBG)
+1 -1
View File
@@ -146,7 +146,7 @@ BOOST_NOINLINE BOOST_SYMBOL_VISIBLE void test_rethrow_nested() {
} catch (...) {
auto trace = stacktrace::from_current_exception();
BOOST_TEST(trace);
std::cout << "Tarce in test_rethrow_nested(): " << trace << '\n';
std::cout << "Trace in test_rethrow_nested(): " << trace << '\n';
BOOST_TEST(to_string(trace).find("in_test_throw_1") == std::string::npos);
#if defined(BOOST_MSVC)
BOOST_TEST(to_string(trace).find("in_test_throw_2") == std::string::npos);
+3 -2
View File
@@ -5,6 +5,9 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <stdexcept>
#include <utility>
#include <boost/stacktrace/stacktrace.hpp>
#if defined(BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP) || defined(BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP)
@@ -15,8 +18,6 @@
#error "windows.h header leaked into the boost/stacktrace/stacktrace.hpp"
#endif
#include <stdexcept>
using namespace boost::stacktrace;
#ifdef BOOST_STACKTRACE_DYN_LINK
+1 -5
View File
@@ -6,15 +6,11 @@
#include "test_impl.hpp"
#include <boost/stacktrace.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
#include <boost/functional/hash.hpp>
#include <boost/stacktrace.hpp>
using boost::stacktrace::stacktrace;
using boost::stacktrace::frame;
void test_deeply_nested_namespaces() {
BOOST_TEST(return_from_nested_namespaces().size() == 0);
+1 -1
View File
@@ -4,13 +4,13 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <array>
#include <boost/stacktrace/detail/to_dec_array.hpp>
#include <boost/stacktrace/detail/to_hex_array.hpp>
#include <boost/stacktrace/detail/try_dec_convert.hpp>
#include <boost/core/lightweight_test.hpp>
#include <string>
#include <iostream>
void test_to_hex_array() {
@@ -52,9 +52,9 @@ int main() {
t2.join();
t3.join();
const auto elapsed = t - std::chrono::steady_clock::now();
const auto elapsed = std::chrono::steady_clock::now() - t;
std::cout << "Elapsed: " << std::chrono::duration_cast<std::chrono::milliseconds>(
elapsed
). count() << "ms";
). count() << "ms\n";
return boost::report_errors();
}