mirror of
https://github.com/boostorg/stacktrace.git
synced 2026-07-21 13:33:41 +00:00
feat boost.stacktrace: C++20 modules support (#230)
- Introduce `boost.stacktrace_dump` module for safe_dump interface - Introduce `boost.stacktrace_<backend>` module for each unwind/collect implementation method - Introduce `boost.stacktrace` module exposing best available backend implementation Also many tests was added for checking all available backend build and also header only library version Moreover, there are some checks for `Boost::stacktrace_<backend>` and `Boost::stacktrace_from_exception` compatibility --------- Co-authored-by: Fedor Osetrov <fdr400@Fedors-MacBook-Pro.local>
This commit is contained in:
@@ -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"
|
||||
@@ -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: |
|
||||
@@ -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: |
|
||||
@@ -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:
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
build?*
|
||||
.cache
|
||||
.vscode
|
||||
+49
-18
@@ -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()
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -7,14 +7,22 @@
|
||||
#ifndef BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP
|
||||
#define BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/stacktrace/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <string>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#if !defined(BOOST_USE_MODULES)
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp> // boost::stacktrace::detail::native_frame_ptr_t
|
||||
#include <boost/stacktrace/detail/void_ptr_cast.hpp>
|
||||
|
||||
#include <boost/stacktrace/detail/push_options.h>
|
||||
@@ -22,6 +30,8 @@
|
||||
/// @file boost/stacktrace/detail/frame_decl.hpp
|
||||
/// Use <boost/stacktrace/frame.hpp> header instead of this one!
|
||||
|
||||
BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
|
||||
|
||||
namespace boost { namespace stacktrace {
|
||||
|
||||
/// @class boost::stacktrace::frame boost/stacktrace/detail/frame_decl.hpp <boost/stacktrace/frame.hpp>
|
||||
@@ -146,7 +156,10 @@ namespace detail {
|
||||
|
||||
}} // namespace boost::stacktrace
|
||||
|
||||
|
||||
#include <boost/stacktrace/detail/pop_options.h>
|
||||
|
||||
BOOST_STACKTRACE_END_MODULE_EXPORT
|
||||
|
||||
#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP
|
||||
|
||||
@@ -12,16 +12,9 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/frame.hpp>
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
|
||||
#ifndef BOOST_STACKTRACE_DISABLE_OFFSET_ADDR_BASE
|
||||
#include <boost/stacktrace/detail/addr_base_msvc.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
@@ -36,6 +29,16 @@
|
||||
#include "dbgeng.h"
|
||||
|
||||
#include <mutex>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#include <boost/stacktrace/frame.hpp>
|
||||
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
|
||||
#ifndef BOOST_STACKTRACE_DISABLE_OFFSET_ADDR_BASE
|
||||
#include <boost/stacktrace/detail/addr_base_msvc.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) || defined(BOOST_MSVC)
|
||||
# pragma comment(lib, "ole32.lib")
|
||||
|
||||
@@ -12,15 +12,18 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <boost/core/demangle.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#include <boost/stacktrace/frame.hpp>
|
||||
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
#include <boost/stacktrace/detail/location_from_symbol.hpp>
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/addr_base.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#ifdef BOOST_STACKTRACE_USE_BACKTRACE
|
||||
# include <boost/stacktrace/detail/libbacktrace_impls.hpp>
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/location_from_symbol.hpp>
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <boost/core/demangle.hpp>
|
||||
|
||||
#ifdef BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE
|
||||
@@ -22,6 +20,11 @@
|
||||
#else
|
||||
# include <backtrace.h>
|
||||
#endif
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/location_from_symbol.hpp>
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
# include <boost/winapi/dll.hpp>
|
||||
#endif
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#ifdef _AIX
|
||||
/* AIX doesn't provide dladdr syscall.
|
||||
@@ -26,6 +28,7 @@
|
||||
|
||||
#include <sys/ldr.h>
|
||||
#include <sys/debug.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <unistd.h> // ::write
|
||||
#include <fcntl.h> // ::open
|
||||
#include <sys/stat.h> // S_IWUSR and friends
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
|
||||
@@ -12,14 +12,16 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
|
||||
#include <boost/winapi/get_current_process.hpp>
|
||||
#include <boost/winapi/file_management.hpp>
|
||||
#include <boost/winapi/handles.hpp>
|
||||
#include <boost/winapi/access_rights.hpp>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <array>
|
||||
#include <cstddef> // std::size_t
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <array>
|
||||
#include <type_traits>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <cstdlib>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <type_traits>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301)
|
||||
# pragma GCC system_header
|
||||
@@ -22,7 +24,7 @@
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
// GCC warns when reinterpret_cast between function pointer and object pointer occur.
|
||||
// This functionsuppress the warnings and ensures that such casts are safe.
|
||||
// This function suppress the warnings and ensures that such casts are safe.
|
||||
template <class To, class From>
|
||||
To void_ptr_cast(From* v) noexcept {
|
||||
static_assert(
|
||||
|
||||
@@ -7,13 +7,18 @@
|
||||
#ifndef BOOST_STACKTRACE_FRAME_HPP
|
||||
#define BOOST_STACKTRACE_FRAME_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
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#include <boost/stacktrace/detail/frame_decl.hpp>
|
||||
#include <boost/stacktrace/detail/push_options.h>
|
||||
@@ -32,6 +37,8 @@ void* boost_stacktrace_impl_return_nullptr() { return nullptr; }
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
|
||||
|
||||
namespace boost { namespace stacktrace {
|
||||
|
||||
/// Comparison operators that provide platform dependant ordering and have O(1) complexity; are Async-Handler-Safe.
|
||||
@@ -58,6 +65,8 @@ std::basic_ostream<CharT, TraitsT>& operator<<(std::basic_ostream<CharT, TraitsT
|
||||
|
||||
}} // namespace boost::stacktrace
|
||||
|
||||
BOOST_STACKTRACE_END_MODULE_EXPORT
|
||||
|
||||
/// @cond
|
||||
|
||||
#include <boost/stacktrace/detail/pop_options.h>
|
||||
@@ -73,5 +82,6 @@ std::basic_ostream<CharT, TraitsT>& operator<<(std::basic_ostream<CharT, TraitsT
|
||||
#endif
|
||||
/// @endcond
|
||||
|
||||
#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_STACKTRACE_FRAME_HPP
|
||||
|
||||
@@ -7,16 +7,25 @@
|
||||
#ifndef BOOST_STACKTRACE_SAFE_DUMP_TO_HPP
|
||||
#define BOOST_STACKTRACE_SAFE_DUMP_TO_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/stacktrace/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_USE_MODULES) && !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
import boost.stacktrace.dump;
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(BOOST_WINDOWS)
|
||||
#include <boost/winapi/config.hpp>
|
||||
#endif
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#include <boost/stacktrace/detail/push_options.h>
|
||||
|
||||
@@ -35,7 +44,9 @@ namespace boost { namespace stacktrace {
|
||||
/// @cond
|
||||
namespace detail {
|
||||
|
||||
BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
|
||||
using native_frame_ptr_t = const void*;
|
||||
BOOST_STACKTRACE_END_MODULE_EXPORT
|
||||
enum helper{ max_frames_dump = 128 };
|
||||
|
||||
BOOST_STACKTRACE_FUNCTION std::size_t from_dump(const char* filename, native_frame_ptr_t* out_frames);
|
||||
@@ -48,6 +59,8 @@ namespace detail {
|
||||
#endif
|
||||
|
||||
|
||||
BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
|
||||
|
||||
struct this_thread_frames { // struct is required to avoid warning about usage of inline+BOOST_NOINLINE
|
||||
BOOST_NOINLINE BOOST_STACKTRACE_FUNCTION static std::size_t collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) noexcept;
|
||||
|
||||
@@ -79,9 +92,13 @@ struct this_thread_frames { // struct is required to avoid warning about usage o
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_STACKTRACE_END_MODULE_EXPORT
|
||||
|
||||
} // namespace detail
|
||||
/// @endcond
|
||||
|
||||
BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
|
||||
|
||||
/// @brief Stores current function call sequence into the memory.
|
||||
///
|
||||
/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined.
|
||||
@@ -199,6 +216,8 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_dep
|
||||
|
||||
}} // namespace boost::stacktrace
|
||||
|
||||
BOOST_STACKTRACE_END_MODULE_EXPORT
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
@@ -223,4 +242,6 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_dep
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_STACKTRACE_SAFE_DUMP_TO_HPP
|
||||
|
||||
@@ -7,11 +7,15 @@
|
||||
#ifndef BOOST_STACKTRACE_STACKTRACE_HPP
|
||||
#define BOOST_STACKTRACE_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
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
|
||||
@@ -22,9 +26,9 @@
|
||||
#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS
|
||||
# include <type_traits>
|
||||
#endif
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#include <boost/stacktrace/stacktrace_fwd.hpp>
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
#include <boost/stacktrace/detail/frame_decl.hpp>
|
||||
#include <boost/stacktrace/frame.hpp>
|
||||
|
||||
@@ -58,9 +62,15 @@ namespace impl {
|
||||
|
||||
#if defined(__GNUC__) && defined(__ELF__)
|
||||
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
extern "C++"
|
||||
#endif
|
||||
BOOST_NOINLINE BOOST_SYMBOL_VISIBLE __attribute__((weak))
|
||||
const char* current_exception_stacktrace() noexcept;
|
||||
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
extern "C++"
|
||||
#endif
|
||||
BOOST_NOINLINE BOOST_SYMBOL_VISIBLE __attribute__((weak))
|
||||
bool& ref_capture_stacktraces_at_throw() noexcept;
|
||||
|
||||
@@ -68,6 +78,8 @@ bool& ref_capture_stacktraces_at_throw() noexcept;
|
||||
|
||||
} // namespace impl
|
||||
|
||||
BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
|
||||
|
||||
/// Class that on construction copies minimal information about call stack into its internals and provides access to that information.
|
||||
/// @tparam Allocator Allocator to use during stack capture.
|
||||
template <class Allocator>
|
||||
@@ -482,10 +494,14 @@ std::basic_ostream<CharT, TraitsT>& operator<<(std::basic_ostream<CharT, TraitsT
|
||||
/// This is the typedef to use unless you'd like to provide a specific allocator to boost::stacktrace::basic_stacktrace.
|
||||
typedef basic_stacktrace<> stacktrace;
|
||||
|
||||
BOOST_STACKTRACE_END_MODULE_EXPORT
|
||||
|
||||
}} // namespace boost::stacktrace
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_STACKTRACE_STACKTRACE_HPP
|
||||
|
||||
@@ -7,13 +7,21 @@
|
||||
#ifndef BOOST_STACKTRACE_STACKTRACE_FWD_HPP
|
||||
#define BOOST_STACKTRACE_STACKTRACE_FWD_HPP
|
||||
|
||||
#include <boost/stacktrace/detail/backend_config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#endif // !defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
/// @file stacktrace_fwd.hpp This header contains only forward declarations of
|
||||
/// boost::stacktrace::frame, boost::stacktrace::basic_stacktrace, boost::stacktrace::stacktrace
|
||||
/// and does not include any other Boost headers.
|
||||
|
||||
BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
|
||||
|
||||
/// @cond
|
||||
namespace boost { namespace stacktrace {
|
||||
|
||||
@@ -24,5 +32,8 @@ typedef basic_stacktrace<> stacktrace;
|
||||
}} // namespace boost::stacktrace
|
||||
/// @endcond
|
||||
|
||||
BOOST_STACKTRACE_END_MODULE_EXPORT
|
||||
|
||||
#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_STACKTRACE_STACKTRACE_FWD_HPP
|
||||
|
||||
@@ -7,13 +7,18 @@
|
||||
#ifndef BOOST_STACKTRACE_THIS_THREAD_HPP
|
||||
#define BOOST_STACKTRACE_THIS_THREAD_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
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
BOOST_STACKTRACE_BEGIN_MODULE_EXPORT
|
||||
|
||||
namespace boost { namespace stacktrace { namespace this_thread {
|
||||
|
||||
/// @brief Invoking the function with the enable parameter equal to `true`
|
||||
@@ -59,4 +64,8 @@ inline bool get_capture_stacktraces_at_throw() noexcept {
|
||||
|
||||
}}} // namespace boost::stacktrace::this_thread
|
||||
|
||||
BOOST_STACKTRACE_END_MODULE_EXPORT
|
||||
|
||||
#endif // !defined(BOOST_USE_MODULES) || defined(BOOST_STACKTRACE_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_STACKTRACE_THIS_THREAD_HPP
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// 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)
|
||||
|
||||
export module boost.stacktrace;
|
||||
export import boost.stacktrace.BOOST_STACKTRACE_BACKEND_MODULE;
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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)
|
||||
|
||||
module;
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
#include <boost/predef.h>
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cxxabi.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define BOOST_STACKTRACE_INTERFACE_UNIT
|
||||
#define BOOST_STACKTRACE_LINK
|
||||
|
||||
export module boost.stacktrace.addr2line;
|
||||
|
||||
import boost.stacktrace.dump;
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
#include <boost/stacktrace/this_thread.hpp>
|
||||
|
||||
module :private;
|
||||
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
|
||||
#define BOOST_STACKTRACE_USE_ADDR2LINE
|
||||
#include <boost/stacktrace/detail/frame_unwind.ipp>
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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)
|
||||
|
||||
module;
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
#include <boost/predef.h>
|
||||
|
||||
#include <backtrace.h>
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cxxabi.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define BOOST_STACKTRACE_INTERFACE_UNIT
|
||||
#define BOOST_STACKTRACE_LINK
|
||||
|
||||
export module boost.stacktrace.backtrace;
|
||||
|
||||
import boost.stacktrace.dump;
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
#include <boost/stacktrace/this_thread.hpp>
|
||||
|
||||
module :private;
|
||||
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
|
||||
#define BOOST_STACKTRACE_USE_BACKTRACE
|
||||
#include <boost/stacktrace/detail/frame_unwind.ipp>
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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)
|
||||
|
||||
module;
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
#include <boost/predef.h>
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cxxabi.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define BOOST_STACKTRACE_INTERFACE_UNIT
|
||||
#define BOOST_STACKTRACE_LINK
|
||||
|
||||
export module boost.stacktrace.basic;
|
||||
|
||||
import boost.stacktrace.dump;
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
#include <boost/stacktrace/this_thread.hpp>
|
||||
|
||||
module :private;
|
||||
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
|
||||
#include <boost/stacktrace/detail/frame_unwind.ipp>
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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)
|
||||
|
||||
module;
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/predef.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unwind.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define BOOST_STACKTRACE_INTERFACE_UNIT
|
||||
#define BOOST_STACKTRACE_LINK
|
||||
|
||||
export module boost.stacktrace.dump;
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
|
||||
module :private;
|
||||
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// 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)
|
||||
|
||||
module;
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#define BOOST_STACKTRACE_INTERFACE_UNIT
|
||||
#define BOOST_STACKTRACE_LINK
|
||||
|
||||
export module boost.stacktrace.noop;
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
module :private;
|
||||
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
|
||||
#include <boost/stacktrace/detail/frame_noop.ipp>
|
||||
#include <boost/stacktrace/detail/safe_dump_noop.ipp>
|
||||
#include <boost/stacktrace/detail/collect_noop.ipp>
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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)
|
||||
|
||||
module;
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
#include <boost/predef.h>
|
||||
|
||||
#define BOOST_STACKTRACE_INTERFACE_UNIT
|
||||
#define BOOST_STACKTRACE_LINK
|
||||
|
||||
export module boost.stacktrace.windbg;
|
||||
|
||||
import boost.stacktrace.dump;
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
#include <boost/stacktrace/this_thread.hpp>
|
||||
|
||||
module :private;
|
||||
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
|
||||
#include <boost/stacktrace/detail/frame_msvc.ipp>
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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)
|
||||
|
||||
module;
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
#include <boost/predef.h>
|
||||
|
||||
#define BOOST_STACKTRACE_INTERFACE_UNIT
|
||||
#define BOOST_STACKTRACE_LINK
|
||||
|
||||
export module boost.stacktrace.windbg;
|
||||
|
||||
import boost.stacktrace.dump;
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
#include <boost/stacktrace/this_thread.hpp>
|
||||
|
||||
module :private;
|
||||
#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
|
||||
#define BOOST_STACKTRACE_USE_WINDBG_CACHED
|
||||
#include <boost/stacktrace/detail/frame_msvc.ipp>
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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)
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(STACKTRACE_MODULE)
|
||||
import STACKTRACE_MODULE;
|
||||
#else
|
||||
import boost.stacktrace;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
BOOST_NOINLINE void foo() {
|
||||
auto trace = boost::stacktrace::stacktrace{};
|
||||
std::cerr << trace;
|
||||
}
|
||||
|
||||
BOOST_NOINLINE void bar() {
|
||||
foo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
bar();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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)
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
BOOST_NOINLINE void foo() {
|
||||
throw std::logic_error{"Foo"};
|
||||
}
|
||||
|
||||
BOOST_NOINLINE void bar() {
|
||||
foo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
try {
|
||||
bar();
|
||||
} catch (const std::exception& ex) {
|
||||
const auto trace = boost::stacktrace::stacktrace::from_current_exception();
|
||||
std::cerr << "Exception: " << ex.what() << ", trace:\n" << trace << '\n';
|
||||
}
|
||||
}
|
||||
@@ -40,13 +40,39 @@ endforeach()
|
||||
enable_testing()
|
||||
add_subdirectory(../.. boostorg/stacktrace)
|
||||
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::stacktrace)
|
||||
add_executable(stacktrace_main main.cpp)
|
||||
target_link_libraries(stacktrace_main Boost::stacktrace)
|
||||
|
||||
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_executable(stacktrace_main_header_only main.cpp)
|
||||
target_include_directories(stacktrace_main_header_only PRIVATE ../../include)
|
||||
target_compile_definitions(stacktrace_main_header_only PRIVATE "_GNU_SOURCE=1")
|
||||
target_link_libraries(stacktrace_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)
|
||||
add_test(NAME stacktrace_main COMMAND stacktrace_main)
|
||||
add_test(NAME stacktrace_main_header_only COMMAND stacktrace_main_header_only)
|
||||
|
||||
if (BOOST_USE_MODULES)
|
||||
add_executable(boost_stacktrace_module_usage ../../modules/samples/usage_sample.cpp)
|
||||
target_link_libraries(boost_stacktrace_module_usage PRIVATE Boost::stacktrace)
|
||||
add_test(NAME boost_stacktrace_module_usage COMMAND boost_stacktrace_module_usage)
|
||||
|
||||
add_executable(boost_stacktrace_from_exception_module_usage ../../modules/samples/usage_sample_from_exception.cpp)
|
||||
target_link_libraries(boost_stacktrace_from_exception_module_usage PRIVATE Boost::stacktrace Boost::stacktrace_from_exception)
|
||||
add_test(NAME boost_stacktrace_from_exception_module_usage COMMAND boost_stacktrace_from_exception_module_usage)
|
||||
|
||||
foreach(backend noop basic addr2line backtrace)
|
||||
if (NOT TARGET Boost::stacktrace_${backend})
|
||||
message(STATUS "Skipping ${backend} backend")
|
||||
continue()
|
||||
endif()
|
||||
add_executable(boost_stacktrace_module_usage_${backend} ../../modules/samples/usage_sample.cpp)
|
||||
target_link_libraries(boost_stacktrace_module_usage_${backend} PRIVATE Boost::stacktrace_${backend})
|
||||
target_compile_definitions(boost_stacktrace_module_usage_${backend} PRIVATE STACKTRACE_MODULE=boost.stacktrace.${backend})
|
||||
add_test(NAME boost_stacktrace_module_usage_${backend} COMMAND boost_stacktrace_module_usage_${backend})
|
||||
|
||||
add_executable(boost_stacktrace_from_exception_module_usage_${backend} ../../modules/samples/usage_sample_from_exception.cpp)
|
||||
target_link_libraries(boost_stacktrace_from_exception_module_usage_${backend} PRIVATE Boost::stacktrace_${backend} Boost::stacktrace_from_exception)
|
||||
target_compile_definitions(boost_stacktrace_from_exception_module_usage_${backend} PRIVATE STACKTRACE_MODULE=boost.stacktrace.${backend})
|
||||
add_test(NAME boost_stacktrace_from_exception_module_usage_${backend} COMMAND boost_stacktrace_from_exception_module_usage_${backend})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
#include <iostream>
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
+2
-3
@@ -4,9 +4,6 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/stacktrace/stacktrace_fwd.hpp>
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -18,6 +15,8 @@
|
||||
|
||||
#include "test_impl.hpp"
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
using boost::stacktrace::stacktrace;
|
||||
using boost::stacktrace::frame;
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
namespace boost { namespace stacktrace { namespace impl {
|
||||
void assert_no_pending_traces() noexcept;
|
||||
}}}
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
using boost::stacktrace::stacktrace;
|
||||
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
// test and `top` does.
|
||||
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
#include <iostream>
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
#include "test_impl.hpp"
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
// See https://github.com/boostorg/stacktrace/issues/116
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
int main() {
|
||||
std::cout << boost::stacktrace::stacktrace() << std::endl;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/stacktrace/detail/void_ptr_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/stacktrace/detail/void_ptr_cast.hpp>
|
||||
|
||||
int foo1_func(int) { return 0; }
|
||||
void foo2_func(int, int, ...) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user