Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b3d0aca
work
fdr400 Mar 3, 2026
74eab9c
work
fdr400 Mar 4, 2026
5770d7b
work
fdr400 Mar 5, 2026
54e003b
work
fdr400 Mar 5, 2026
c7f12be
fix no modules build
fdr400 Mar 5, 2026
c0b2efb
fix build both modules and headers
fdr400 Mar 5, 2026
af51004
empty
fdr400 Mar 5, 2026
62f5c50
rollback not required changes
fdr400 Mar 5, 2026
1d00450
rollback not required changes
fdr400 Mar 5, 2026
b838908
remove comment
fdr400 Mar 5, 2026
31680b1
rollback not required diff
fdr400 Mar 5, 2026
a64218c
format
fdr400 Mar 5, 2026
70d614e
remove not needed file
fdr400 Mar 5, 2026
981f133
remove not required directive
fdr400 Mar 5, 2026
8079e49
build modules in link mode
fdr400 Mar 5, 2026
de755c5
make dump independent
fdr400 Mar 14, 2026
5afba8d
build tests without boost test
fdr400 Mar 14, 2026
7d56a55
include dump in windows
fdr400 Mar 14, 2026
e3dc26c
compile dump for Windows
fdr400 Mar 15, 2026
7b6741f
link public with dump
fdr400 Mar 15, 2026
3a24d58
include config to resolve windows
fdr400 Mar 15, 2026
9e0203b
add link options for header_only
fdr400 Mar 15, 2026
c32114c
maybe fix macro for mac
fdr400 Mar 15, 2026
fb7b00e
fix cmake install
fdr400 Mar 15, 2026
40e19f1
link public with dump
fdr400 Mar 15, 2026
a69bb3d
build exception internal
fdr400 Mar 15, 2026
258e663
include only required
fdr400 Mar 15, 2026
bc00bc4
rollback to frame.hpp
fdr400 Mar 15, 2026
76a4f74
do not test torture with addr2line
fdr400 Mar 15, 2026
d3706ff
disable from_exception test on MacOS
fdr400 Mar 15, 2026
5556978
try add dump to b2
fdr400 Mar 15, 2026
fb044fa
propagate dump to dependencies
fdr400 Mar 15, 2026
13127be
Merge branch 'feature/stacktrace-dump-library' into feature/cxx20-mod…
fdr400 Mar 17, 2026
e5b8689
fix cmake
fdr400 Mar 17, 2026
4aa1334
fix test command name
fdr400 Mar 17, 2026
c0860e2
fix test command name
fdr400 Mar 17, 2026
68c7205
fix cmake
fdr400 Mar 17, 2026
3bd3767
add copyright
fdr400 Mar 17, 2026
aab9aa3
introduce stacktrace_config.hpp
fdr400 Mar 17, 2026
64535c3
add missing includes in module
Mar 17, 2026
7f4940c
add copyrights
fdr400 Mar 17, 2026
35b556e
add modules CI
fdr400 Mar 17, 2026
479d967
fix install
fdr400 Mar 17, 2026
d46cae6
save default backend
fdr400 Mar 18, 2026
6050000
skip not supported backend
fdr400 Mar 18, 2026
6a7b901
try install libbacktrace in CI
fdr400 Mar 18, 2026
9d52c9d
fix build clang++-19
fdr400 Mar 22, 2026
11118f4
try use libbacktrace in CI
fdr400 Mar 22, 2026
1a2120b
try use libbacktrace in CI
fdr400 Mar 22, 2026
9c8eab0
bettern config name
fdr400 Apr 11, 2026
a8e80b0
ensure not missing includes
fdr400 Apr 11, 2026
8dfd0c1
ensure not missing includes in detail/
fdr400 Apr 11, 2026
5ef28a6
Merge branch 'develop' into feature/cxx20-modules
fdr400 Apr 28, 2026
f915a3b
rm build
fdr400 Apr 28, 2026
4fed6a0
rm vscode
fdr400 Apr 28, 2026
20d932c
fix conflict
fdr400 Apr 28, 2026
3f7c655
better
fdr400 Apr 28, 2026
a6860c4
fix addr2line module
fdr400 Apr 28, 2026
89e24a6
better
fdr400 Apr 28, 2026
ff00de6
better
fdr400 Apr 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 50 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,21 @@ jobs:
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
install: g++-9
install: [g++-9]
- toolset: clang-15
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
- toolset: clang-19
compiler: clang++-19
cxxstd: "20"
os: ubuntu-24.04
install: &cxx19
- clang-19
- llvm-19
- libclang-rt-19-dev
- libc++-19-dev
- libc++abi-19-dev
- clang-tools-19
# TODO: fix and uncomment
#- toolset: clang
# cxxstd: "03,11,14,17,2a"
Expand All @@ -45,7 +56,7 @@ jobs:

- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
run: sudo apt install -y ${{join(matrix.install, ' ')}}

- name: Setup Boost
run: |
Expand All @@ -71,6 +82,35 @@ jobs:
./bootstrap.sh
./b2 -d0 headers
./b2 -j4 variant=debug tools/inspect

- name: Build libbacktrace
if: ${{matrix.toolset == 'clang-19'}}
run: |
# libc++ do not have bundled libbacktrace implementation
git clone --depth=1 https://github.com/ianlancetaylor/libbacktrace.git
cd libbacktrace
CC=clang-19 OBJCOPY=/usr/bin/llvm-objcopy NM=/usr/bin/llvm-nm \
./configure --prefix="$HOME/.local" --with-system-libunwind
make -j"$(nproc)"
make install

- name: Run modules tests without 'import std;'
if: ${{matrix.toolset == 'clang-19'}}
run: |
pwd
cd ../boost-root/libs/$LIBRARY
cmake -S test/cmake_subdir_test \
-B build_module \
-GNinja \
-DBOOST_USE_MODULES=1 \
-DBUILD_TESTING=1 \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_CXX_COMPILER=${{matrix.compiler}} \
-DCMAKE_CXX_FLAGS="-stdlib=libc++ -I$HOME/.local/include" \
-DCMAKE_EXE_LINKER_FLAGS="-L$HOME/.local"
cmake --build build_module
ctest --test-dir build_module -VV
rm -rf build_module

- name: Run tests
run: |
Expand Down Expand Up @@ -205,11 +245,14 @@ jobs:

- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake -DBUILD_SHARED_LIBS=${{matrix.shared}} ..
cmake --build .
ctest --output-on-failure --no-tests=error
cd ../boost-root/libs/$LIBRARY
cmake -S test/cmake_subdir_test -B __build__ \
-GNinja \
-DBUILD_SHARED_LIBS=${{matrix.shared}}

cmake --build __build__
ctest --test-dir __build__ --output-on-failure --no-tests=error
rm -rf __build__

posix-cmake-install:
strategy:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build?*
.cache
.vscode
67 changes: 49 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ cmake_minimum_required(VERSION 3.8...4.20)

project(boost_stacktrace VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

function(stacktrace_add_library suffix opt public_libs libs defs)
function(stacktrace_add_module name)
target_sources(${name}
PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS "${CMAKE_CURRENT_LIST_DIR}/modules"
FILES "${CMAKE_CURRENT_LIST_DIR}/modules/${name}.cppm"
)
target_compile_features(${name} PUBLIC cxx_std_20)
target_compile_definitions(${name} PUBLIC BOOST_USE_MODULES)
endfunction()

function(stacktrace_add_library suffix opt public_libs libs defs add_module)

if(NOT opt)
return()
Expand Down Expand Up @@ -38,10 +49,14 @@ function(stacktrace_add_library suffix opt public_libs libs defs)
${defs}
)

target_sources(boost_stacktrace_${suffix}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/${suffix}.cpp
)
if (add_module)
stacktrace_add_module(boost_stacktrace_${suffix})
else()
target_sources(boost_stacktrace_${suffix}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/src/${suffix}.cpp"
)
endif()

if(BUILD_SHARED_LIBS)
target_compile_definitions(boost_stacktrace_${suffix} PUBLIC BOOST_STACKTRACE_DYN_LINK)
Expand Down Expand Up @@ -110,24 +125,40 @@ if(BOOST_STACKTRACE_ENABLE_BACKTRACE OR
BOOST_STACKTRACE_ENABLE_WINDBG_CACHED
)
set(_enable_non_noop_backend TRUE)
else()
set(_enable_non_noop_backend FALSE)
endif()

if(_enable_non_noop_backend)
stacktrace_add_library(dump ON "" "" "")
if(NOT BOOST_USE_MODULES)
set(BOOST_USE_MODULES OFF)
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")

stacktrace_add_library(dump ${_enable_non_noop_backend} "" "" "" ${BOOST_USE_MODULES})
stacktrace_add_library(noop ${BOOST_STACKTRACE_ENABLE_NOOP} "" "" "" ${BOOST_USE_MODULES})
stacktrace_add_library(backtrace ${BOOST_STACKTRACE_ENABLE_BACKTRACE} Boost::stacktrace_dump "backtrace;${CMAKE_DL_LIBS}" "" ${BOOST_USE_MODULES})
stacktrace_add_library(addr2line ${BOOST_STACKTRACE_ENABLE_ADDR2LINE} Boost::stacktrace_dump "${CMAKE_DL_LIBS}" "" ${BOOST_USE_MODULES})
stacktrace_add_library(basic ${BOOST_STACKTRACE_ENABLE_BASIC} Boost::stacktrace_dump "${CMAKE_DL_LIBS}" "" ${BOOST_USE_MODULES})
stacktrace_add_library(windbg ${BOOST_STACKTRACE_ENABLE_WINDBG} Boost::stacktrace_dump "dbgeng;ole32" "_GNU_SOURCE=1" ${BOOST_USE_MODULES})
stacktrace_add_library(windbg_cached ${BOOST_STACKTRACE_ENABLE_WINDBG_CACHED} Boost::stacktrace_dump "dbgeng;ole32" "_GNU_SOURCE=1" ${BOOST_USE_MODULES})

# boost_stacktrace, default library

add_library(boost_stacktrace INTERFACE)
if(BOOST_USE_MODULES)
add_library(boost_stacktrace)
stacktrace_add_module(boost_stacktrace boost_stacktrace)
set(__scope PUBLIC)

target_include_directories(boost_stacktrace INTERFACE include)
foreach(backend noop backtrace addr2line basic windbg windbg_cached)
if (TARGET boost_stacktrace_${backend})
target_compile_definitions(boost_stacktrace_${backend} INTERFACE BOOST_STACKTRACE_BACKEND_MODULE=${backend})
endif()
endforeach()
else()
add_library(boost_stacktrace INTERFACE)
set(__scope INTERFACE)
endif()

target_include_directories(boost_stacktrace ${__scope} "${CMAKE_CURRENT_LIST_DIR}/include")
add_library(Boost::stacktrace ALIAS boost_stacktrace)

if(BOOST_STACKTRACE_ENABLE_WINDBG)
Expand All @@ -147,13 +178,13 @@ else()
endif()

message(STATUS "Boost.stacktrace default backend: ${__default_stacktrace_backend}")
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_${__default_stacktrace_backend})
target_link_libraries(boost_stacktrace ${__scope} 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)
stacktrace_add_library(from_exception ${BOOST_STACKTRACE_ENABLE_FROM_EXCEPTION} Boost::stacktrace_dump "${CMAKE_DL_LIBS}" "" FALSE)
endif()
unset(_enable_non_noop_backend)

if(BUILD_TESTING)
add_subdirectory(test)
Expand Down
7 changes: 6 additions & 1 deletion include/boost/stacktrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
#ifndef BOOST_STACKTRACE_HPP
#define BOOST_STACKTRACE_HPP

#include <boost/config.hpp>
#include <boost/stacktrace/detail/backend_config.hpp>

#if !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)

#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
Expand All @@ -17,4 +20,6 @@
#include <boost/stacktrace/safe_dump_to.hpp>
#include <boost/stacktrace/this_thread.hpp>

#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)

#endif // BOOST_STACKTRACE_HPP
11 changes: 7 additions & 4 deletions include/boost/stacktrace/detail/addr2line_impls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@
# pragma once
#endif

#include <boost/stacktrace/detail/addr_base.hpp>
#include <boost/stacktrace/detail/to_hex_array.hpp>
#include <boost/stacktrace/detail/to_dec_array.hpp>
#include <boost/stacktrace/detail/try_dec_convert.hpp>
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
#include <boost/core/demangle.hpp>

#include <cstdio>
#include <cstring>

#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)

#include <boost/stacktrace/detail/addr_base.hpp>
#include <boost/stacktrace/detail/to_hex_array.hpp>
#include <boost/stacktrace/detail/to_dec_array.hpp>
#include <boost/stacktrace/detail/try_dec_convert.hpp>

namespace boost { namespace stacktrace { namespace detail {

Expand Down
2 changes: 2 additions & 0 deletions include/boost/stacktrace/detail/addr_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
# pragma once
#endif

#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
#include <fstream>
#include <sstream>
#include <cstdint>
#include <cstdlib>
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)

namespace boost { namespace stacktrace { namespace detail {

Expand Down
2 changes: 2 additions & 0 deletions include/boost/stacktrace/detail/addr_base_msvc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# pragma once
#endif

#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
#include <cstdio>
#include <cstdint>
#include <memory>
Expand All @@ -27,6 +28,7 @@
#include <psapi.h>
#undef WIN32_LEAN_AND_MEAN
#endif
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)

namespace boost { namespace stacktrace { namespace detail {
inline std::uintptr_t get_own_proc_addr_base(const void* addr) {
Expand Down
24 changes: 24 additions & 0 deletions include/boost/stacktrace/detail/backend_config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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)

#ifndef BOOST_STACKTRACE_DETAIL_BACKEND_CONFIG_HPP
#define BOOST_STACKTRACE_DETAIL_BACKEND_CONFIG_HPP

#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
# include <boost/config.hpp>
# ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
# endif
#endif

#include "boost/stacktrace/detail/config.hpp"

#if defined(BOOST_USE_MODULES) && !defined(BOOST_STACKTRACE_INTERFACE_UNIT) && !defined(BOOST_STACKTRACE_INTERNAL_BUILD_LIBS)
import boost.stacktrace.BOOST_STACKTRACE_BACKEND_MODULE;
#endif

#endif
6 changes: 4 additions & 2 deletions include/boost/stacktrace/detail/collect_msvc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
# pragma once
#endif

#include <boost/stacktrace/safe_dump_to.hpp>

#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
#include <boost/winapi/stack_backtrace.hpp>
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)

#include <boost/stacktrace/safe_dump_to.hpp>

namespace boost { namespace stacktrace { namespace detail {

Expand Down
6 changes: 4 additions & 2 deletions include/boost/stacktrace/detail/collect_unwind.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# pragma once
#endif

#include <boost/stacktrace/safe_dump_to.hpp>

#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
// On iOS 32-bit ARM architecture _Unwind_Backtrace function doesn't exist, symbol is undefined.
// Forcing libc backtrace() function usage.
#include <boost/predef.h>
Expand All @@ -28,11 +27,14 @@
#include <unwind.h>
#endif
#include <cstdio>
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)

#if !defined(_GNU_SOURCE) && !defined(BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED) && !defined(BOOST_WINDOWS)
#error "Boost.Stacktrace requires `_Unwind_Backtrace` function. Define `_GNU_SOURCE` macro or `BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED` if _Unwind_Backtrace is available without `_GNU_SOURCE`."
#endif

#include <boost/stacktrace/safe_dump_to.hpp>

namespace boost { namespace stacktrace { namespace detail {

#if !defined(BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION)
Expand Down
26 changes: 26 additions & 0 deletions include/boost/stacktrace/detail/config.hpp
Original file line number Diff line number Diff line change
@@ -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)

#ifndef BOOST_STACKTRACE_DETAIL_CONFIG_HPP
#define BOOST_STACKTRACE_DETAIL_CONFIG_HPP

#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
# include <boost/config.hpp>
# ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
# endif
#endif

#ifdef BOOST_STACKTRACE_INTERFACE_UNIT
# define BOOST_STACKTRACE_BEGIN_MODULE_EXPORT export {
# define BOOST_STACKTRACE_END_MODULE_EXPORT }
#else
# define BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
# define BOOST_STACKTRACE_END_MODULE_EXPORT
#endif

#endif
Loading
Loading