mirror of
https://github.com/boostorg/stacktrace.git
synced 2026-01-28 19:52:08 +00:00
Compare commits
48 Commits
boost-1.74
...
boost-1.83
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6e7712868 | ||
|
|
c836328054 | ||
|
|
71da3cfd56 | ||
|
|
95065ca638 | ||
|
|
b9a0a12f1c | ||
|
|
4cf47389c1 | ||
|
|
d904d26f4f | ||
|
|
cd4c5fe554 | ||
|
|
12e3743e58 | ||
|
|
6db6fd0c01 | ||
|
|
57db1f511e | ||
|
|
308b7f6b08 | ||
|
|
b856a99f9f | ||
|
|
6bf1a98d97 | ||
|
|
cc4d16e2ad | ||
|
|
7c6778e9f4 | ||
|
|
e5940e7103 | ||
|
|
bac3611ad8 | ||
|
|
9e8510076d | ||
|
|
a60ee55b36 | ||
|
|
75b7986f97 | ||
|
|
3f3f9020fb | ||
|
|
898fedac41 | ||
|
|
79aff77771 | ||
|
|
1be59df18e | ||
|
|
1dae3faf43 | ||
|
|
99b7015508 | ||
|
|
18012f81da | ||
|
|
76f902f366 | ||
|
|
b37e0d8e9f | ||
|
|
9a114f8256 | ||
|
|
b75a37dc48 | ||
|
|
1631213c0c | ||
|
|
cadf1bc311 | ||
|
|
26f66b58e9 | ||
|
|
7b19672b67 | ||
|
|
67cc2e9017 | ||
|
|
4b4472cccb | ||
|
|
08d720adbd | ||
|
|
a00587f4d7 | ||
|
|
9c462940b1 | ||
|
|
7fdaebb8ef | ||
|
|
15f6b30f12 | ||
|
|
4a8b14b2d7 | ||
|
|
e4576bfae2 | ||
|
|
7985a04380 | ||
|
|
d84457e2a0 | ||
|
|
66aba44f79 |
168
.github/workflows/ci.yml
vendored
Normal file
168
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
|
||||
linkflags: "linkflags=--coverage -lasan -lubsan"
|
||||
gcov_tool: "gcov-12"
|
||||
launcher: "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8"
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
# TODO: fix and uncomment
|
||||
#- toolset: clang
|
||||
# cxxstd: "03,11,14,17,2a"
|
||||
# os: macos-10.15
|
||||
# cxxflags: "cxxflags=-fsanitize=address,undefined -fno-sanitize-recover=undefined -D_GNU_SOURCE=1"
|
||||
# linkflags: "linkflags=-fsanitize=address,undefined"
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 10 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init --depth 10 --jobs 2 tools/boostdep tools/inspect libs/filesystem
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 3" filesystem
|
||||
rm -rf libs/$LIBRARY/*
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
./b2 -j4 variant=debug tools/inspect/build
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release "${{matrix.cxxflags}}" "${{matrix.linkflags}}" "${{matrix.launcher}}"
|
||||
dist/bin/inspect libs/$LIBRARY
|
||||
|
||||
- name: Prepare coverage data
|
||||
if: matrix.gcov_tool
|
||||
run: |
|
||||
mkdir -p $GITHUB_WORKSPACE/coveralls
|
||||
|
||||
echo -e "#!/bin/bash\nexec ${{matrix.gcov_tool}} \"\$@\"" > $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh
|
||||
chmod +x $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh
|
||||
wget https://github.com/linux-test-project/lcov/archive/v1.16.zip
|
||||
unzip v1.16.zip
|
||||
LCOV="`pwd`/lcov-1.16/bin/lcov --gcov-tool $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh"
|
||||
|
||||
echo "$LCOV --directory ../boost-root/bin.v2/libs/$LIBRARY/ --base-directory `pwd`/libs/$LIBRARY/test --capture --output-file $GITHUB_WORKSPACE/coveralls/coverage.info"
|
||||
$LCOV --directory ../boost-root/bin.v2/libs/$LIBRARY/ --base-directory ../boost-root/ --capture --output-file $GITHUB_WORKSPACE/coveralls/coverage.info
|
||||
$LCOV --remove $GITHUB_WORKSPACE/coveralls/coverage.info "/usr*" "*/$LIBRARY/test/*" ${{matrix.ignore_coverage}} "*/$LIBRARY/tests/*" "*/$LIBRARY/examples/*" "*/$LIBRARY/example/*" -o $GITHUB_WORKSPACE/coveralls/coverage.info
|
||||
|
||||
cd ../boost-root
|
||||
OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$LIBRARY\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
|
||||
echo $OTHER_LIBS
|
||||
eval "$LCOV --remove $GITHUB_WORKSPACE/coveralls/coverage.info $OTHER_LIBS -o $GITHUB_WORKSPACE/coveralls/coverage.info"
|
||||
|
||||
- name: Coveralls
|
||||
uses: coverallsapp/github-action@master
|
||||
if: matrix.gcov_tool
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
path-to-lcov: ./coveralls/coverage.info
|
||||
parallel: true
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 64
|
||||
os: windows-2022
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
#- toolset: gcc
|
||||
# cxxstd: "03,11,14,17,2a"
|
||||
# addrmd: 64
|
||||
# os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 10 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
|
||||
|
||||
finish:
|
||||
needs: posix
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Coveralls Finished
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
parallel-finished: true
|
||||
161
.travis.yml
161
.travis.yml
@@ -1,161 +0,0 @@
|
||||
# Use, modification, and distribution are
|
||||
# subject to 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)
|
||||
#
|
||||
# Copyright Antony Polukhin 2014-2020.
|
||||
|
||||
#
|
||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
||||
# and how it can be used with Boost libraries.
|
||||
#
|
||||
# File revision #10
|
||||
|
||||
language: cpp
|
||||
os: linux
|
||||
|
||||
# `--coverage` flags required to generate coverage info for Coveralls
|
||||
matrix:
|
||||
include:
|
||||
- env: B2_ARGS='cxxstd=98,03,11,14,1y toolset=gcc-6 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD -fno-rtti" linkflags="--coverage -lasan -lubsan" "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.3"'
|
||||
name: "GCC-6, no RTTI"
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-6
|
||||
|
||||
- env: B2_ARGS='cxxstd=98,03,11,14,1z toolset=gcc-8 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD" linkflags="--coverage -lasan -lubsan" "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.5"'
|
||||
name: "GCC-8"
|
||||
sudo: required # Required by leak sanitizer
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-8
|
||||
|
||||
- env: B2_ARGS='cxxstd=98,0x toolset=gcc-4.6 cxxflags="--coverage -DBOOST_TRAVISCI_BUILD" linkflags="--coverage"'
|
||||
name: "GCC-4.6"
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.6
|
||||
|
||||
# - env: B2_ARGS='cxxstd=98,03,11,14,1y toolset=gcc-8 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD -fno-exceptions" linkflags="--coverage -lasan -lubsan"'
|
||||
# name: "GCC-8, no exceptions"
|
||||
# sudo: required # Required by leak sanitizer
|
||||
# addons:
|
||||
# apt:
|
||||
# sources: ubuntu-toolchain-r-test
|
||||
# packages: g++-8
|
||||
|
||||
# Not running UBSan because it gives an error for some tests:
|
||||
# test_impl.cpp:14:16: runtime error: call to function (unknown) through pointer to incorrect function type 'std::pair<stacktrace, stacktrace> (*)(int)'
|
||||
- env: B2_ARGS='cxxstd=98,03,11,14,1z toolset=clang-8 cxxflags="--coverage -fsanitize=address,leak -DBOOST_TRAVISCI_BUILD" linkflags="--coverage -fsanitize=address,leak"'
|
||||
name: "Clang-8"
|
||||
sudo: required # Required by leak sanitizer
|
||||
addons:
|
||||
apt:
|
||||
sources: llvm-toolchain-trusty-8
|
||||
packages: clang-8
|
||||
|
||||
# Sanitizers disabled for this toolset as they started causing link troubles:
|
||||
# hidden symbol `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE11__recommendEm' isn't defined
|
||||
- env: B2_ARGS='cxxstd=03,11,14 toolset=clang-libc++ cxxflags="--coverage -DBOOST_TRAVISCI_BUILD" linkflags="--coverage"'
|
||||
name: "Clang-3.8, libc++"
|
||||
addons:
|
||||
apt:
|
||||
packages: libc++-dev
|
||||
|
||||
###############################################################################################################
|
||||
# From this point and below code is same for all the Boost libs
|
||||
###############################################################################################################
|
||||
|
||||
# Installing additional tools
|
||||
addons:
|
||||
apt:
|
||||
sources: git-core
|
||||
packages:
|
||||
- git
|
||||
- python-yaml
|
||||
- binutils # for addr2line tests of Boost.Stacktrace
|
||||
|
||||
before_install:
|
||||
# Autodetect Boost branch by using the following code: - BOOST_BRANCH=$TRAVIS_BRANCH
|
||||
# or just directly specify it
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
|
||||
# Files, which coverage results must be ignored (files from other projects).
|
||||
# Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/*'
|
||||
- IGNORE_COVERAGE='*/filesystem/src/* */thread/src/pthread/* */thread/src/future.cpp */timer/src/* operators.hpp'
|
||||
|
||||
# boost-local/libs/ folder to put this library into. This may be useful, if you're for example running Travis
|
||||
# from `Boost.DLL` repo while Boost already has `dll` and with to replace `dll` with content of`Boost.DLL`.
|
||||
#
|
||||
# Otherwise just leave the default value - BOOST_LIBS_FOLDER=$(basename $TRAVIS_BUILD_DIR)
|
||||
- BOOST_LIBS_FOLDER=$(basename $TRAVIS_BUILD_DIR)
|
||||
|
||||
# Global options for sanitizers
|
||||
- UBSAN_OPTIONS=print_stacktrace=1
|
||||
- LSAN_OPTIONS=verbosity=1:log_threads=1
|
||||
# Cloning minimal set of Boost libraries
|
||||
- BOOST=$HOME/boost-local
|
||||
- git clone -b $BOOST_BRANCH --depth 10 https://github.com/boostorg/boost.git $BOOST
|
||||
- cd $BOOST
|
||||
- git submodule update --init --depth 10 --jobs 2 tools/build tools/boostdep tools/inspect libs/filesystem libs/interprocess # Boost.Interprocess is required for examples
|
||||
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" $BOOST/libs/filesystem
|
||||
|
||||
# Replacing Boost module with this project and installing Boost dependencies
|
||||
- echo "Testing $BOOST/libs/$BOOST_LIBS_FOLDER moved from $TRAVIS_BUILD_DIR, branch $BOOST_BRANCH"
|
||||
- rm -rf $BOOST/libs/$BOOST_LIBS_FOLDER || true
|
||||
- mv $TRAVIS_BUILD_DIR $BOOST/libs/$BOOST_LIBS_FOLDER
|
||||
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" $BOOST_LIBS_FOLDER
|
||||
- git status
|
||||
|
||||
# Adding missing toolsets and preparing Boost headers
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
- ./b2 -j4 variant=debug tools/inspect/build
|
||||
- |-
|
||||
echo "using gcc ;" >> ~/user-config.jam
|
||||
echo "using clang ;" >> ~/user-config.jam
|
||||
echo "using clang : 3.8 : clang++-3.8 ;" >> ~/user-config.jam
|
||||
echo "using clang : 4 : clang++-4.0 ;" >> ~/user-config.jam
|
||||
echo "using clang : 5 : clang++-5.0 ;" >> ~/user-config.jam
|
||||
echo "using clang : 6 : clang++-6.0 ;" >> ~/user-config.jam
|
||||
echo "using clang : 7 : clang++-7.0 ;" >> ~/user-config.jam
|
||||
echo "using clang : 8 : clang++-8 ;" >> ~/user-config.jam
|
||||
echo "using clang : libc++ : clang++-libc++ ;" >> ~/user-config.jam
|
||||
- cd $BOOST/libs/$BOOST_LIBS_FOLDER/test/
|
||||
|
||||
script:
|
||||
- sh -c "../../../b2 -j2 $B2_ARGS"
|
||||
# inspect tool run without -link and checks
|
||||
- ../../../dist/bin/inspect .. -license -copyright -crlf -end -path_name -tab -ascii -apple_macro -deprecated_macro -minmax -unnamed -assert_macro
|
||||
|
||||
|
||||
after_success:
|
||||
# Copying Coveralls data to a separate folder
|
||||
- mkdir -p $TRAVIS_BUILD_DIR/coverals
|
||||
- find ../../../bin.v2/ -name "*.gcda" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
||||
- find ../../../bin.v2/ -name "*.gcno" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
||||
- find ../../../bin.v2/ -name "*.da" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
||||
- find ../../../bin.v2/ -name "*.no" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
||||
- wget https://github.com/linux-test-project/lcov/archive/v1.12.zip
|
||||
- unzip v1.12.zip
|
||||
- LCOV="`pwd`/lcov-1.12/bin/lcov --gcov-tool gcov-6"
|
||||
|
||||
# Preparing Coveralls data by changind data format to a readable one
|
||||
- echo "$LCOV --directory $TRAVIS_BUILD_DIR/coverals --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info"
|
||||
- $LCOV --directory $TRAVIS_BUILD_DIR/coverals --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info
|
||||
|
||||
# ... erasing /test/ /example/ folder data
|
||||
- cd $BOOST
|
||||
- $LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info "/usr*" "*/$BOOST_LIBS_FOLDER/test/*" $IGNORE_COVERAGE "*/$BOOST_LIBS_FOLDER/tests/*" "*/$BOOST_LIBS_FOLDER/examples/*" "*/$BOOST_LIBS_FOLDER/example/*" -o $TRAVIS_BUILD_DIR/coverals/coverage.info
|
||||
|
||||
# ... erasing data that is not related to this project directly
|
||||
- OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$BOOST_LIBS_FOLDER\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
|
||||
- echo $OTHER_LIBS
|
||||
- eval "$LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info $OTHER_LIBS -o $TRAVIS_BUILD_DIR/coverals/coverage.info"
|
||||
|
||||
# Sending data to Coveralls
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
- gem install coveralls-lcov
|
||||
- coveralls-lcov coverals/coverage.info
|
||||
106
CMakeLists.txt
Normal file
106
CMakeLists.txt
Normal file
@@ -0,0 +1,106 @@
|
||||
# Copyright 2020, 2021 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(boost_stacktrace VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
function(stacktrace_add_library suffix opt libs defs)
|
||||
|
||||
if(NOT opt)
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_library(boost_stacktrace_${suffix}
|
||||
src/${suffix}.cpp
|
||||
)
|
||||
|
||||
add_library(Boost::stacktrace_${suffix} ALIAS boost_stacktrace_${suffix})
|
||||
|
||||
target_include_directories(boost_stacktrace_${suffix} PUBLIC include)
|
||||
|
||||
target_link_libraries(boost_stacktrace_${suffix}
|
||||
PUBLIC
|
||||
Boost::array
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::predef
|
||||
Boost::static_assert
|
||||
Boost::type_traits
|
||||
Boost::winapi
|
||||
PRIVATE
|
||||
${libs}
|
||||
)
|
||||
|
||||
target_compile_definitions(boost_stacktrace_${suffix}
|
||||
PUBLIC BOOST_STACKTRACE_NO_LIB
|
||||
PRIVATE BOOST_STACKTRACE_SOURCE ${defs}
|
||||
)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(boost_stacktrace_${suffix} PUBLIC BOOST_STACKTRACE_DYN_LINK)
|
||||
else()
|
||||
target_compile_definitions(boost_stacktrace_${suffix} PUBLIC BOOST_STACKTRACE_STATIC_LINK)
|
||||
endif()
|
||||
|
||||
if(BOOST_SUPERPROJECT_VERSION AND NOT CMAKE_VERSION VERSION_LESS 3.13)
|
||||
boost_install(TARGETS boost_stacktrace_${suffix} VERSION ${BOOST_SUPERPROJECT_VERSION} HEADER_DIRECTORY include)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
function(stacktrace_check var source incs libs defs)
|
||||
|
||||
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" "")
|
||||
|
||||
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" "")
|
||||
|
||||
option(BOOST_STACKTRACE_ENABLE_NOOP "Boost.Stacktrace: build boost_stacktrace_noop" ON)
|
||||
option(BOOST_STACKTRACE_ENABLE_BACKTRACE "Boost.Stacktrace: build boost_stacktrace_backtrace" ${BOOST_STACKTRACE_HAS_BACKTRACE})
|
||||
option(BOOST_STACKTRACE_ENABLE_ADDR2LINE "Boost.Stacktrace: build boost_stacktrace_addr2line" ${_default_addr2line})
|
||||
option(BOOST_STACKTRACE_ENABLE_BASIC "Boost.Stacktrace: build boost_stacktrace_basic" ON)
|
||||
option(BOOST_STACKTRACE_ENABLE_WINDBG "Boost.Stacktrace: build boost_stacktrace_windbg" ${BOOST_STACKTRACE_HAS_WINDBG})
|
||||
option(BOOST_STACKTRACE_ENABLE_WINDBG_CACHED "Boost.Stacktrace: build boost_stacktrace_windbg_cached" ${BOOST_STACKTRACE_HAS_WINDBG_CACHED})
|
||||
|
||||
unset(_default_addr2line)
|
||||
|
||||
message(STATUS "Boost.Stacktrace: "
|
||||
"noop ${BOOST_STACKTRACE_ENABLE_NOOP}, "
|
||||
"backtrace ${BOOST_STACKTRACE_ENABLE_BACKTRACE}, "
|
||||
"addr2line ${BOOST_STACKTRACE_ENABLE_ADDR2LINE}, "
|
||||
"basic ${BOOST_STACKTRACE_ENABLE_BASIC}, "
|
||||
"windbg ${BOOST_STACKTRACE_ENABLE_WINDBG}, "
|
||||
"windbg_cached ${BOOST_STACKTRACE_ENABLE_WINDBG_CACHED}"
|
||||
)
|
||||
|
||||
stacktrace_add_library(noop ${BOOST_STACKTRACE_ENABLE_NOOP} "" "")
|
||||
stacktrace_add_library(backtrace ${BOOST_STACKTRACE_ENABLE_BACKTRACE} "backtrace" "")
|
||||
stacktrace_add_library(addr2line ${BOOST_STACKTRACE_ENABLE_ADDR2LINE} "" "")
|
||||
stacktrace_add_library(basic ${BOOST_STACKTRACE_ENABLE_BASIC} "" "")
|
||||
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(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
12
README.md
12
README.md
@@ -1,15 +1,17 @@
|
||||
### Stacktrace
|
||||
# [Boost.Stacktrace](https://boost.org/libs/stacktrace)
|
||||
|
||||
Library for storing and printing backtraces.
|
||||
|
||||
[Documentation and examples.](http://boostorg.github.io/stacktrace/index.html)
|
||||
Boost.Stacktrace is a part of the [Boost C++ Libraries](https://github.com/boostorg).
|
||||
|
||||
|
||||
### Test results
|
||||
@ | Build | Tests coverage | More info
|
||||
----------------|-------------- | -------------- |-----------
|
||||
Develop branch: | [](https://travis-ci.org/boostorg/stacktrace) [](https://ci.appveyor.com/project/apolukhin/stacktrace/branch/develop) | [](https://coveralls.io/github/boostorg/stacktrace?branch=develop) | [details...](http://www.boost.org/development/tests/develop/developer/stacktrace.html)
|
||||
Master branch: | [](https://travis-ci.org/boostorg/stacktrace) [](https://ci.appveyor.com/project/apolukhin/stacktrace/branch/master) | [](https://coveralls.io/github/boostorg/stacktrace?branch=master) | [details...](http://www.boost.org/development/tests/master/developer/stacktrace.html)
|
||||
Develop branch: | [](https://github.com/boostorg/stacktrace/actions/workflows/ci.yml) [](https://ci.appveyor.com/project/apolukhin/stacktrace/branch/develop) | [](https://coveralls.io/github/boostorg/stacktrace?branch=develop) | [details...](https://www.boost.org/development/tests/develop/developer/stacktrace.html)
|
||||
Master branch: | [](https://github.com/boostorg/stacktrace/actions/workflows/ci.yml) [](https://ci.appveyor.com/project/apolukhin/stacktrace/branch/master) | [](https://coveralls.io/github/boostorg/stacktrace?branch=master) | [details...](https://www.boost.org/development/tests/master/developer/stacktrace.html)
|
||||
|
||||
[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/stacktrace.html)
|
||||
|
||||
### License
|
||||
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
|
||||
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2016-2019, Antony Polukhin.
|
||||
# Copyright (C) 2016-2022, Antony Polukhin.
|
||||
#
|
||||
# Use, modification and distribution is subject to the Boost Software License,
|
||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -51,8 +51,6 @@ explicit WinDbg ;
|
||||
mp-run-simple has_windbg_cached.cpp : : : <library>Dbgeng <library>ole32 : WinDbgCached ;
|
||||
explicit WinDbgCached ;
|
||||
|
||||
local libraries ;
|
||||
|
||||
lib boost_stacktrace_noop
|
||||
: # sources
|
||||
../src/noop.cpp
|
||||
@@ -64,8 +62,6 @@ lib boost_stacktrace_noop
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
libraries += boost_stacktrace_noop ;
|
||||
|
||||
lib boost_stacktrace_backtrace
|
||||
: # sources
|
||||
../src/backtrace.cpp
|
||||
@@ -80,8 +76,6 @@ lib boost_stacktrace_backtrace
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
libraries += boost_stacktrace_backtrace ;
|
||||
|
||||
lib boost_stacktrace_addr2line
|
||||
: # sources
|
||||
../src/addr2line.cpp
|
||||
@@ -95,8 +89,6 @@ lib boost_stacktrace_addr2line
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
libraries += boost_stacktrace_addr2line ;
|
||||
|
||||
lib boost_stacktrace_basic
|
||||
: # sources
|
||||
../src/basic.cpp
|
||||
@@ -110,8 +102,6 @@ lib boost_stacktrace_basic
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
libraries += boost_stacktrace_basic ;
|
||||
|
||||
lib boost_stacktrace_windbg
|
||||
: # sources
|
||||
../src/windbg.cpp
|
||||
@@ -125,8 +115,6 @@ lib boost_stacktrace_windbg
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
libraries += boost_stacktrace_windbg ;
|
||||
|
||||
lib boost_stacktrace_windbg_cached
|
||||
: # sources
|
||||
../src/windbg_cached.cpp
|
||||
@@ -140,6 +128,4 @@ lib boost_stacktrace_windbg_cached
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
libraries += boost_stacktrace_windbg_cached ;
|
||||
|
||||
boost-install $(libraries) ;
|
||||
boost-install boost_stacktrace_noop boost_stacktrace_backtrace boost_stacktrace_addr2line boost_stacktrace_basic boost_stacktrace_windbg boost_stacktrace_windbg_cached ;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// 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 <backtrace.h>
|
||||
#ifdef BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE
|
||||
# include BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE
|
||||
#else
|
||||
# include <backtrace.h>
|
||||
#endif
|
||||
|
||||
#include <unwind.h>
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright Antony Polukhin 2016-2019.
|
||||
# Copyright Antony Polukhin, 2016-2023.
|
||||
# Use, modification, and distribution are
|
||||
# subject to 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)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
[quickbook 1.6]
|
||||
[version 1.0]
|
||||
[id stacktrace]
|
||||
[copyright 2016-2020 Antony Polukhin]
|
||||
[copyright 2016-2023 Antony Polukhin]
|
||||
[category Language Features Emulation]
|
||||
[license
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -57,53 +57,6 @@ Code from above will output something like this:
|
||||
[note By default the Stacktrace library is very conservative in methods to decode stacktrace. If your output does not look as fancy as in example from above, see [link stacktrace.configuration_and_build section "Configuration and Build"] for allowing advanced features of the library. ]
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Handle terminates, aborts and Segmentation Faults]
|
||||
|
||||
Segmentation Faults and `std::terminate` calls sometimes happen in programs. Programmers usually wish to get as much information as possible on such incidents, so having a stacktrace will significantly improve debugging and fixing.
|
||||
|
||||
`std::terminate` calls `std::abort`, so we need to capture stack traces on Segmentation Faults and Abort signals.
|
||||
|
||||
[warning Writing a signal handler requires high attention! Only a few system calls allowed in signal handlers, so there's no cross platform way to print a stacktrace without a risk of deadlocking. The only way to deal with the problem - [*dump raw stacktrace into file/socket and parse it on program restart].]
|
||||
|
||||
[warning Not all the platforms provide means for even getting stacktrace in async signal safe way. No stack trace will be saved on such platforms. ]
|
||||
|
||||
Let's write a handler to safely dump stacktrace:
|
||||
|
||||
[getting_started_terminate_handlers]
|
||||
|
||||
Registering our handler:
|
||||
|
||||
[getting_started_setup_handlers]
|
||||
|
||||
At program start we check for a file with stacktrace and if it exist - we're writing it in human readable format:
|
||||
|
||||
[getting_started_on_program_restart]
|
||||
|
||||
Now we'll get the following output on `std::terminate` call after the program restarts:
|
||||
|
||||
```
|
||||
Previous run crashed:
|
||||
0# 0x00007F2EC0A6A8EF
|
||||
1# my_signal_handler(int) at ../example/terminate_handler.cpp:37
|
||||
2# 0x00007F2EBFD84CB0
|
||||
3# 0x00007F2EBFD84C37
|
||||
4# 0x00007F2EBFD88028
|
||||
5# 0x00007F2EC0395BBD
|
||||
6# 0x00007F2EC0393B96
|
||||
7# 0x00007F2EC0393BE1
|
||||
8# bar(int) at ../example/terminate_handler.cpp:18
|
||||
9# foo(int) at ../example/terminate_handler.cpp:22
|
||||
10# bar(int) at ../example/terminate_handler.cpp:14
|
||||
11# foo(int) at ../example/terminate_handler.cpp:22
|
||||
12# main at ../example/terminate_handler.cpp:84
|
||||
13# 0x00007F2EBFD6FF45
|
||||
14# 0x0000000000402209
|
||||
```
|
||||
|
||||
[note Function names from shared libraries may not be decoded due to address space layout randomization. Still better than nothing.]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Better asserts]
|
||||
@@ -137,6 +90,44 @@ Backtrace:
|
||||
|
||||
Now we do know the steps that led to the assertion and can find the error without debugger.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Handle terminates]
|
||||
|
||||
`std::terminate` calls sometimes happen in programs. Programmers usually wish to get as much information as possible on such incidents, so having a stacktrace significantly improves debugging and fixing.
|
||||
|
||||
Here's how to write a terminate handler that dumps stacktrace:
|
||||
|
||||
[getting_started_terminate_handlers]
|
||||
|
||||
Here's how to register it:
|
||||
|
||||
[getting_started_setup_terminate_handlers]
|
||||
|
||||
Now we'll get the following output on `std::terminate` call:
|
||||
|
||||
```
|
||||
Previous run crashed:
|
||||
0# my_terminate_handler(int) at ../example/terminate_handler.cpp:37
|
||||
1# __cxxabiv1::__terminate(void (*)()) at ../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:48
|
||||
2# 0x00007F3CE65E5901 in /usr/lib/x86_64-linux-gnu/libstdc++.so.6
|
||||
3# bar(int) at ../example/terminate_handler.cpp:18
|
||||
4# foo(int) at ../example/terminate_handler.cpp:22
|
||||
5# bar(int) at ../example/terminate_handler.cpp:14
|
||||
6# foo(int) at ../example/terminate_handler.cpp:22
|
||||
7# main at ../example/terminate_handler.cpp:84
|
||||
8# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
|
||||
9# 0x0000000000402209
|
||||
```
|
||||
|
||||
[warning There's a temptation to write a signal handler that prints the stacktrace on `SIGSEGV` or abort. Unfortunately, there's no cross platform way to do that without a risk of deadlocking. Not all the platforms provide means for even getting stacktrace in async signal safe way.
|
||||
|
||||
Signal handler is often invoked on a separate stack and trash is returned on attempt to get a trace!
|
||||
|
||||
Generic recommendation is to *avoid signal handlers! Use* platform specific ways to store and decode *core files*.
|
||||
]
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -294,11 +285,11 @@ By default Boost.Stacktrace is a header-only library, but you may change that an
|
||||
|
||||
In header only mode library could be tuned by macro. If one of the link macro from above is defined, you have to manually link with one of the libraries:
|
||||
[table:libconfig Config
|
||||
[[Macro name or default] [Library] [Effect] [Platforms] [Uses debug information [footnote This will provide more readable backtraces with *source code locations* if the binary is built with debug information.]] [Uses dynamic exports information [footnote This will provide readable function names in backtrace for functions that are exported by the binary. Compiling with `-rdynamic` flag, without `-fisibility=hidden` or marking functions as exported produce a better stacktraces.]] ]
|
||||
[[['default for MSVC, Intel on Windows, MinGW-w64] / *BOOST_STACKTRACE_USE_WINDBG*] [*boost_stacktrace_windbg*] [ Uses COM to show debug info. May require linking with *ole32* and *dbgeng*. ] [MSVC, MinGW-w64, Intel on Windows] [yes] [no]]
|
||||
[[Macro name or default] [Library] [Effect] [Platforms] [Uses debug information [footnote This will provide more readable backtraces with *source code locations* if the binary is built with debug information.]] [Uses dynamic exports information [footnote This will provide readable function names in backtrace for functions that are exported by the binary. Compiling with `-rdynamic` flag, without `-fvisibility=hidden` or marking functions as exported produce a better stacktraces.]] ]
|
||||
[[['default for MSVC, Intel on Windows, MinGW-w64] / *BOOST_STACKTRACE_USE_WINDBG*] [*boost_stacktrace_windbg*] [ Uses `dbgeng.h` to show debug info. May require linking with *ole32* and *dbgeng*. ] [MSVC, MinGW-w64, Intel on Windows] [yes] [no]]
|
||||
[[['default for other platforms]] [*boost_stacktrace_basic*] [Uses compiler intrinsics to collect stacktrace and if possible `::dladdr` to show information about the symbol. Requires linking with *libdl* library on POSIX platforms.] [Any compiler on POSIX or MinGW] [no] [yes]]
|
||||
[[*BOOST_STACKTRACE_USE_WINDBG_CACHED*] [*boost_stacktrace_windbg_cached*] [ Uses COM to show debug info and caches COM instances in TLS for better performance. Useful only for cases when traces are gathered very often. [footnote This may affect other components of your program that use COM, because this mode calls the `CoInitializeEx(0, COINIT_MULTITHREADED)` on first use and does not call `::CoUninitialize();` until the current thread is destroyed. ] May require linking with *ole32* and *dbgeng*. ] [MSVC, Intel on Windows] [yes] [no]]
|
||||
[[*BOOST_STACKTRACE_USE_BACKTRACE*] [*boost_stacktrace_backtrace*] [Requires linking with *libdl* on POSIX and *libbacktrace* libraries. *libbacktrace* is probably already installed in your system[footnote If you are using Clang with libstdc++ you could get into troubles of including `<backtrace.h>`, because on some platforms Clang does not search for headers in the GCC's include paths and any attempt to add GCC's include path leads to linker errors. To explicitly specify a path to the `<backtrace.h>` header you could define the *BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE* to a full path to the header. For example on Ubuntu Xenial use the command line option *-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=</usr/lib/gcc/x86_64-linux-gnu/5/include/backtrace.h>* while building with Clang. ], or built into your compiler.
|
||||
[[*BOOST_STACKTRACE_USE_WINDBG_CACHED*] [*boost_stacktrace_windbg_cached*] [ Uses `dbgeng.h` to show debug info and caches internals in TLS for better performance. Useful only for cases when traces are gathered very often. May require linking with *ole32* and *dbgeng*. ] [MSVC, Intel on Windows] [yes] [no]]
|
||||
[[*BOOST_STACKTRACE_USE_BACKTRACE*] [*boost_stacktrace_backtrace*] [Requires linking with *libdl* on POSIX and *libbacktrace* libraries[footnote Some *libbacktrace* packages SEGFAULT if there's a concurrent work with the same `backtrace_state` instance. To avoid that issue the Boost.Stacktrace library uses `thread_local` states, unfortunately this may consume a lot of memory if you often create and destroy execution threads in your application. Define *BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC* to force single instance, but make sure that [@https://github.com/boostorg/stacktrace/blob/develop/test/thread_safety_checking.cpp thread_safety_checking.cpp] works well in your setup. ]. *libbacktrace* is probably already installed in your system[footnote If you are using Clang with libstdc++ you could get into troubles of including `<backtrace.h>`, because on some platforms Clang does not search for headers in the GCC's include paths and any attempt to add GCC's include path leads to linker errors. To explicitly specify a path to the `<backtrace.h>` header you could define the *BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE* to a full path to the header. For example on Ubuntu Xenial use the command line option *-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=</usr/lib/gcc/x86_64-linux-gnu/5/include/backtrace.h>* while building with Clang. ], or built into your compiler.
|
||||
|
||||
Otherwise (if you are a *MinGW*/*MinGW-w64* user for example) it can be downloaded [@https://github.com/ianlancetaylor/libbacktrace from here] or [@https://github.com/gcc-mirror/gcc/tree/master/libbacktrace from here]. ] [Any compiler on POSIX, or MinGW, or MinGW-w64] [yes] [yes]]
|
||||
[[*BOOST_STACKTRACE_USE_ADDR2LINE*] [*boost_stacktrace_addr2line*] [Use *addr2line* program to retrieve stacktrace. Requires linking with *libdl* library and `::fork` system call. Macro *BOOST_STACKTRACE_ADDR2LINE_LOCATION* must be defined to the absolute path to the addr2line executable if it is not located in /usr/bin/addr2line. ] [Any compiler on POSIX] [yes] [yes]]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -23,25 +23,44 @@ BOOST_NOINLINE void foo(int i) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//[getting_started_terminate_handlers
|
||||
//[getting_started_signal_handlers
|
||||
|
||||
#include <signal.h> // ::signal, ::raise
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
void my_signal_handler(int signum) {
|
||||
::signal(signum, SIG_DFL);
|
||||
|
||||
// Outputs nothing or trash on majority of platforms
|
||||
boost::stacktrace::safe_dump_to("./backtrace.dump");
|
||||
|
||||
::raise(SIGABRT);
|
||||
}
|
||||
//]
|
||||
|
||||
void setup_handlers() {
|
||||
//[getting_started_setup_handlers
|
||||
//[getting_started_setup_signel_handlers
|
||||
::signal(SIGSEGV, &my_signal_handler);
|
||||
::signal(SIGABRT, &my_signal_handler);
|
||||
//]
|
||||
}
|
||||
|
||||
|
||||
//[getting_started_terminate_handlers
|
||||
#include <cstdlib> // std::abort
|
||||
#include <exception> // std::set_terminate
|
||||
#include <iostream> // std::cerr
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
void my_terminate_handler() {
|
||||
try {
|
||||
std::cerr << boost::stacktrace::stacktrace();
|
||||
} catch (...) {}
|
||||
std::abort();
|
||||
}
|
||||
//]
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOST_CONSTEXPR_OR_CONST std::size_t shared_memory_size = 4096 * 8;
|
||||
@@ -58,7 +77,7 @@ boost::interprocess::mapped_region g_region; // inited at program start
|
||||
void my_signal_handler2(int signum) {
|
||||
::signal(signum, SIG_DFL);
|
||||
void** f = static_cast<void**>(g_region.get_address());
|
||||
*f = reinterpret_cast<void*>(1); // Setting flag that shared memory now constains stacktrace.
|
||||
*f = reinterpret_cast<void*>(1); // Setting flag that shared memory now contains stacktrace.
|
||||
boost::stacktrace::safe_dump_to(f + 1, g_region.get_size() - sizeof(void*));
|
||||
|
||||
::raise(SIGABRT);
|
||||
@@ -92,6 +111,15 @@ inline void copy_and_run(const char* exec_name, char param, bool not_null) {
|
||||
}
|
||||
}
|
||||
|
||||
int run_0(const char* /*argv*/[]) {
|
||||
//[getting_started_setup_terminate_handlers
|
||||
std::set_terminate(&my_terminate_handler);
|
||||
//]
|
||||
foo(5);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int run_1(const char* /*argv*/[]) {
|
||||
setup_handlers();
|
||||
foo(5);
|
||||
@@ -168,8 +196,8 @@ int run_4(const char* argv[]) {
|
||||
|
||||
//[getting_started_on_program_restart_shmem
|
||||
void** f = static_cast<void**>(g_region.get_address());
|
||||
if (*f) { // Checking if memory constains stacktrace.
|
||||
boost::stacktrace::stacktrace st
|
||||
if (*f) { // Checking if memory contains stacktrace.
|
||||
boost::stacktrace::stacktrace st
|
||||
= boost::stacktrace::stacktrace::from_dump(f + 1, g_region.get_size() - sizeof(bool));
|
||||
|
||||
std::cout << "Previous run crashed and left trace in shared memory:\n" << st << std::endl;
|
||||
@@ -300,7 +328,10 @@ int test_inplace() {
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
if (argc < 2) {
|
||||
// On Windows the debugger could be active. In that case tests hang and the CI run fails.
|
||||
#ifndef BOOST_WINDOWS
|
||||
copy_and_run(argv[0], '0', true);
|
||||
|
||||
// We are copying files to make sure that stacktrace printing works independently from executable name
|
||||
copy_and_run(argv[0], '1', true);
|
||||
copy_and_run(argv[0], '2', false);
|
||||
@@ -314,6 +345,7 @@ int main(int argc, const char* argv[]) {
|
||||
}
|
||||
|
||||
switch (argv[1][0]) {
|
||||
case '0': return run_0(argv);
|
||||
case '1': return run_1(argv);
|
||||
case '2': return run_2(argv);
|
||||
case '3': return run_3(argv);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -13,7 +13,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/frame.hpp>
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
#include <boost/stacktrace/stacktrace.hpp> // Actually already includes all the headers
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
|
||||
#endif // BOOST_STACKTRACE_HPP
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -44,37 +44,12 @@
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
class com_global_initer: boost::noncopyable {
|
||||
bool ok_;
|
||||
|
||||
public:
|
||||
com_global_initer() BOOST_NOEXCEPT
|
||||
: ok_(false)
|
||||
{
|
||||
// COINIT_MULTITHREADED means that we must serialize access to the objects manually.
|
||||
// This is the fastest way to work. If user calls CoInitializeEx before us - we
|
||||
// can end up with other mode (which is OK for us).
|
||||
//
|
||||
// If we call CoInitializeEx befire user - user may end up with different mode, which is a problem.
|
||||
// So we need to call that initialization function as late as possible.
|
||||
const DWORD res = ::CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
ok_ = (res == S_OK || res == S_FALSE);
|
||||
}
|
||||
|
||||
~com_global_initer() BOOST_NOEXCEPT {
|
||||
if (ok_) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class com_holder: boost::noncopyable {
|
||||
T* holder_;
|
||||
|
||||
public:
|
||||
com_holder(const com_global_initer&) BOOST_NOEXCEPT
|
||||
com_holder() BOOST_NOEXCEPT
|
||||
: holder_(0)
|
||||
{}
|
||||
|
||||
@@ -126,13 +101,13 @@ inline void trim_right_zeroes(std::string& s) {
|
||||
}
|
||||
|
||||
class debugging_symbols: boost::noncopyable {
|
||||
static void try_init_com(com_holder< ::IDebugSymbols>& idebug, const com_global_initer& com) BOOST_NOEXCEPT {
|
||||
com_holder< ::IDebugClient> iclient(com);
|
||||
static void try_init_com(com_holder< ::IDebugSymbols>& idebug) BOOST_NOEXCEPT {
|
||||
com_holder< ::IDebugClient> iclient;
|
||||
if (S_OK != ::DebugCreate(__uuidof(IDebugClient), iclient.to_void_ptr_ptr())) {
|
||||
return;
|
||||
}
|
||||
|
||||
com_holder< ::IDebugControl> icontrol(com);
|
||||
com_holder< ::IDebugControl> icontrol;
|
||||
const bool res0 = (S_OK == iclient->QueryInterface(
|
||||
__uuidof(IDebugControl),
|
||||
icontrol.to_void_ptr_ptr()
|
||||
@@ -154,20 +129,17 @@ class debugging_symbols: boost::noncopyable {
|
||||
return;
|
||||
}
|
||||
|
||||
// No cheking: QueryInterface sets the output parameter to NULL in case of error.
|
||||
// No checking: QueryInterface sets the output parameter to NULL in case of error.
|
||||
iclient->QueryInterface(__uuidof(IDebugSymbols), idebug.to_void_ptr_ptr());
|
||||
}
|
||||
|
||||
#ifndef BOOST_STACKTRACE_USE_WINDBG_CACHED
|
||||
|
||||
boost::stacktrace::detail::com_global_initer com_;
|
||||
com_holder< ::IDebugSymbols> idebug_;
|
||||
public:
|
||||
debugging_symbols() BOOST_NOEXCEPT
|
||||
: com_()
|
||||
, idebug_(com_)
|
||||
{
|
||||
try_init_com(idebug_, com_);
|
||||
try_init_com(idebug_);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -179,11 +151,10 @@ public:
|
||||
static com_holder< ::IDebugSymbols>& get_thread_local_debug_inst() BOOST_NOEXCEPT {
|
||||
// [class.mfct]: A static local variable or local type in a member function always refers to the same entity, whether
|
||||
// or not the member function is inline.
|
||||
static thread_local boost::stacktrace::detail::com_global_initer com;
|
||||
static thread_local com_holder< ::IDebugSymbols> idebug(com);
|
||||
static thread_local com_holder< ::IDebugSymbols> idebug;
|
||||
|
||||
if (!idebug.is_inited()) {
|
||||
try_init_com(idebug, com);
|
||||
try_init_com(idebug);
|
||||
}
|
||||
|
||||
return idebug;
|
||||
@@ -228,9 +199,12 @@ public:
|
||||
&size,
|
||||
0
|
||||
));
|
||||
trim_right_zeroes(result);
|
||||
|
||||
// According to https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/dbgeng/nf-dbgeng-idebugsymbols-getnamebyoffset
|
||||
// "This size includes the space for the '\0' terminating character."
|
||||
result.resize(size - 1);
|
||||
} else if (res) {
|
||||
result = name;
|
||||
result.assign(name, size - 1);
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -82,31 +82,35 @@ BOOST_SYMBOL_VISIBLE inline ::backtrace_state* construct_state(const program_loc
|
||||
//
|
||||
//
|
||||
// Unfortunately, that solution segfaults when `construct_state()` function is in .so file
|
||||
// and multiple threads concurrently work with state.
|
||||
// and multiple threads concurrently work with state. I failed to localize the root cause:
|
||||
// https://gcc.gnu.org/bugzilla//show_bug.cgi?id=87653
|
||||
|
||||
#define BOOST_STACKTRACE_DETAIL_IS_MT 1
|
||||
|
||||
#ifndef BOOST_HAS_THREADS
|
||||
static
|
||||
#if !defined(BOOST_HAS_THREADS)
|
||||
# define BOOST_STACKTRACE_DETAIL_STORAGE static
|
||||
# undef BOOST_STACKTRACE_DETAIL_IS_MT
|
||||
# define BOOST_STACKTRACE_DETAIL_IS_MT 0
|
||||
#elif defined(BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC)
|
||||
# define BOOST_STACKTRACE_DETAIL_STORAGE static
|
||||
#elif !defined(BOOST_NO_CXX11_THREAD_LOCAL)
|
||||
# define BOOST_STACKTRACE_DETAIL_STORAGE thread_local
|
||||
#elif defined(__GNUC__) && !defined(__clang__)
|
||||
# define BOOST_STACKTRACE_DETAIL_STORAGE static __thread
|
||||
#else
|
||||
|
||||
// Result of `construct_state()` invocation is not stored by the callers, so `thread_local`
|
||||
// gives a single `state` per thread and that state is not shared between threads in any way.
|
||||
|
||||
# ifndef BOOST_NO_CXX11_THREAD_LOCAL
|
||||
thread_local
|
||||
# elif defined(__GNUC__)
|
||||
static __thread
|
||||
# else
|
||||
/* just a local variable */
|
||||
# endif
|
||||
|
||||
# define BOOST_STACKTRACE_DETAIL_STORAGE /* just a local variable */
|
||||
#endif
|
||||
::backtrace_state* state = ::backtrace_create_state(
|
||||
|
||||
BOOST_STACKTRACE_DETAIL_STORAGE ::backtrace_state* state = ::backtrace_create_state(
|
||||
prog_location.name(),
|
||||
0,
|
||||
BOOST_STACKTRACE_DETAIL_IS_MT,
|
||||
boost::stacktrace::detail::libbacktrace_error_callback,
|
||||
0
|
||||
);
|
||||
|
||||
#undef BOOST_STACKTRACE_DETAIL_IS_MT
|
||||
#undef BOOST_STACKTRACE_DETAIL_STORAGE
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
// Copyright Antony Polukhin, 2015-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -12,6 +12,24 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
|
||||
defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) || \
|
||||
defined(BOOST_NO_CXX11_CONSTEXPR) || \
|
||||
defined(BOOST_NO_CXX11_NULLPTR) || \
|
||||
defined(BOOST_NO_CXX11_NOEXCEPT) || \
|
||||
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \
|
||||
defined(BOOST_NO_CXX11_FINAL) || \
|
||||
defined(BOOST_NO_CXX11_ALIGNOF) || \
|
||||
defined(BOOST_NO_CXX11_STATIC_ASSERT) || \
|
||||
defined(BOOST_NO_CXX11_SMART_PTR) || \
|
||||
defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) || \
|
||||
defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("C++03 support is deprecated in Boost.Stacktrace 1.82 and will be removed in Boost.Stacktrace 1.84.")
|
||||
|
||||
#endif
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -27,6 +27,7 @@
|
||||
#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>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
# pragma warning(push)
|
||||
@@ -134,7 +135,7 @@ public:
|
||||
///
|
||||
/// @b Async-Handler-Safety: Safe if Allocator construction, copying, Allocator::allocate and Allocator::deallocate are async signal safe.
|
||||
///
|
||||
/// @param a Allocator that would be passed to underlying storeage.
|
||||
/// @param a Allocator that would be passed to underlying storage.
|
||||
BOOST_FORCEINLINE explicit basic_stacktrace(const allocator_type& a) BOOST_NOEXCEPT
|
||||
: impl_(a)
|
||||
{
|
||||
@@ -151,7 +152,7 @@ public:
|
||||
///
|
||||
/// @param max_depth Max call sequence depth to collect.
|
||||
///
|
||||
/// @param a Allocator that would be passed to underlying storeage.
|
||||
/// @param a Allocator that would be passed to underlying storage.
|
||||
///
|
||||
/// @throws Nothing. Note that default construction of allocator may throw, however it is
|
||||
/// performed outside the constructor and exception in `allocator_type()` would not result in calling `std::terminate`.
|
||||
@@ -319,7 +320,7 @@ public:
|
||||
|
||||
/// Constructs stacktrace from raw memory dump. Terminating zero frame is discarded.
|
||||
///
|
||||
/// @param begin Begining of the memory where the stacktrace was saved using the boost::stacktrace::safe_dump_to
|
||||
/// @param begin Beginning of the memory where the stacktrace was saved using the boost::stacktrace::safe_dump_to
|
||||
///
|
||||
/// @param buffer_size_in_bytes Size of the memory. Usually the same value that was passed to the boost::stacktrace::safe_dump_to
|
||||
///
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright (c) 2014-2019 Antony Polukhin
|
||||
Copyright (c) Antony Polukhin, 2014-2023
|
||||
antoshkka at gmail dot com
|
||||
|
||||
Distributed under the Boost Software License,
|
||||
@@ -10,7 +10,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="refresh" content="0; url=../../doc/html/stacktrace.html">
|
||||
<meta http-equiv="refresh" content="0; url=https://www.boost.org/doc/libs/master/doc/html/stacktrace.html">
|
||||
<title>Boost.Stacktrace</title>
|
||||
<style>
|
||||
body {
|
||||
@@ -26,10 +26,10 @@
|
||||
<body>
|
||||
<p>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../../doc/html/stacktrace.html">../../doc/html/stacktrace.html</a>
|
||||
<a href="https://www.boost.org/doc/libs/master/doc/html/stacktrace.html">https://www.boost.org/doc/libs/master/doc/html/stacktrace.html</a>
|
||||
</p>
|
||||
<p>
|
||||
© 2014-2019 Antony Polukhin
|
||||
© Antony Polukhin, 2014-2023
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"Antony Polukhin <antoshkka -at- gmail.com>"
|
||||
],
|
||||
"description": "Gather, store, copy and print backtraces.",
|
||||
"std": [ "proposal" ],
|
||||
"std": [ "c++23" ],
|
||||
"category": [
|
||||
"System", "Correctness"
|
||||
]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2016-2019, Antony Polukhin.
|
||||
# Copyright (C) 2016-2021, Antony Polukhin.
|
||||
#
|
||||
# Use, modification and distribution is subject to the Boost Software License,
|
||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -81,6 +81,7 @@ test-suite stacktrace_tests
|
||||
|
||||
# Header only tests with debug symbols
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : backtrace_ho ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_BACKTRACE <define>BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC $(BT_DEPS) : backtrace_ho_static ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_ADDR2LINE $(AD2L_DEPS) : addr2line_ho ]
|
||||
[ run test_noop.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : noop_ho ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on $(WIND_DEPS) : windbg_ho ]
|
||||
@@ -88,6 +89,15 @@ test-suite stacktrace_tests
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) : basic_ho ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(BASIC_DEPS) : basic_ho_empty ]
|
||||
|
||||
# Header only trivial
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : trivial_backtrace_ho ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_ADDR2LINE $(AD2L_DEPS) : trivial_addr2line_ho ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : trivial_noop_ho ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on $(WIND_DEPS) : trivial_windbg_ho ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) : trivial_windbg_cached_ho ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) : trivial_basic_ho ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(BASIC_DEPS) : trivial_basic_ho_empty ]
|
||||
|
||||
# Test with shared linked implementations with debug symbols
|
||||
[ run test.cpp : : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : backtrace_lib ]
|
||||
[ run test.cpp : : : <debug-symbols>on <library>.//test_impl_lib_addr2line $(LINKSHARED_AD2L) : addr2line_lib ]
|
||||
@@ -96,10 +106,22 @@ test-suite stacktrace_tests
|
||||
[ run test_noop.cpp : : : <debug-symbols>on <library>.//test_impl_lib_noop $(LINKSHARED_NOOP) : noop_lib ]
|
||||
[ run test.cpp : : : <debug-symbols>on <library>.//test_impl_lib_basic $(LINKSHARED_BASIC) : basic_lib ]
|
||||
|
||||
# Trivial test with shared linked implementations with debug symbols
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : trivial_backtrace_lib ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <library>.//test_impl_lib_addr2line $(LINKSHARED_AD2L) : trivial_addr2line_lib ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <library>.//test_impl_lib_windbg $(LINKSHARED_WIND) : trivial_windbg_lib ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <library>.//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED) : trivial_windbg_cached_lib ]
|
||||
[ run test_trivial.cpp : : : <debug-symbols>on <library>.//test_impl_lib_noop $(LINKSHARED_NOOP) : trivial_noop_lib ]
|
||||
[ 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
|
||||
: : : <debug-symbols>on <library>/boost/thread//boost_thread <library>/boost/timer//boost_timer <library>.//test_impl_lib_backtrace $(LINKSHARED_BT)
|
||||
: backtrace_lib_threaded ]
|
||||
[ run thread_safety_checking.cpp
|
||||
: : : <debug-symbols>on <library>/boost/thread//boost_thread <library>/boost/timer//boost_timer <library>.//test_impl_lib_backtrace $(LINKSHARED_BT)
|
||||
<define>BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC
|
||||
: backtrace_lib_threaded_static ]
|
||||
[ run thread_safety_checking.cpp
|
||||
: : : <debug-symbols>on <library>/boost/thread//boost_thread <library>/boost/timer//boost_timer <library>.//test_impl_lib_windbg $(LINKSHARED_WIND)
|
||||
: windbg_lib_threaded ]
|
||||
@@ -110,15 +132,6 @@ test-suite stacktrace_tests
|
||||
: : : <debug-symbols>on <library>/boost/thread//boost_thread <library>/boost/timer//boost_timer <library>.//test_impl_lib_basic $(LINKSHARED_BASIC)
|
||||
: basic_lib_threaded ]
|
||||
|
||||
[ run thread_safety_checking.cpp
|
||||
: : : <debug-symbols>on <library>/boost/thread//boost_thread <library>/boost/timer//boost_timer <library>.//test_impl_lib_windbg
|
||||
$(LINKSHARED_WIND) <define>BOOST_STACKTRACE_TEST_COM_PREINIT_MT
|
||||
: windbg_lib_threaded_com_mt ]
|
||||
[ run thread_safety_checking.cpp
|
||||
: : : <debug-symbols>on <library>/boost/thread//boost_thread <library>/boost/timer//boost_timer <library>.//test_impl_lib_windbg_cached
|
||||
$(LINKSHARED_WIND_CACHED) <define>BOOST_STACKTRACE_TEST_COM_PREINIT_ST
|
||||
: windbg_cached_lib_threaded_com_st ]
|
||||
|
||||
##### Tests with disabled debug symbols #####
|
||||
|
||||
# Header only tests without debug symbols
|
||||
@@ -170,23 +183,6 @@ test-suite stacktrace_tests
|
||||
$(LINKSHARED_BASIC)
|
||||
: basic_lib_no_dbg_threaded ]
|
||||
|
||||
[ run thread_safety_checking.cpp
|
||||
: : : <debug-symbols>off
|
||||
<library>/boost/thread//boost_thread
|
||||
<library>/boost/timer//boost_timer
|
||||
<library>.//test_impl_lib_windbg
|
||||
$(LINKSHARED_WIND)
|
||||
<define>BOOST_STACKTRACE_TEST_COM_PREINIT_MT
|
||||
: windbg_lib_threaded_com_mt ]
|
||||
[ run thread_safety_checking.cpp
|
||||
: : : <debug-symbols>off
|
||||
<library>/boost/thread//boost_thread
|
||||
<library>/boost/timer//boost_timer
|
||||
<library>.//test_impl_lib_windbg_cached
|
||||
$(LINKSHARED_WIND_CACHED)
|
||||
<define>BOOST_STACKTRACE_TEST_COM_PREINIT_ST
|
||||
: windbg_cached_lib_threaded_com_st ]
|
||||
|
||||
[ run test_void_ptr_cast.cpp ]
|
||||
[ run test_num_conv.cpp ]
|
||||
;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# subject to 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)
|
||||
#
|
||||
# Copyright Antony Polukhin 2016-2019.
|
||||
# Copyright Antony Polukhin, 2016-2023.
|
||||
|
||||
#
|
||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
15
test/test_trivial.cpp
Normal file
15
test/test_trivial.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright Antony Polukhin, 2022-2023.
|
||||
//
|
||||
// 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)
|
||||
|
||||
// See https://github.com/boostorg/stacktrace/issues/116
|
||||
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << boost::stacktrace::stacktrace() << std::endl;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
// Copyright Antony Polukhin, 2016-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -41,18 +41,7 @@ void main_test_loop() {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_STACKTRACE_TEST_COM_PREINIT_MT) || defined(BOOST_STACKTRACE_TEST_COM_PREINIT_ST)
|
||||
# include <windows.h>
|
||||
# include "dbgeng.h"
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
#if defined(BOOST_STACKTRACE_TEST_COM_PREINIT_MT)
|
||||
::CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
#elif defined(BOOST_STACKTRACE_TEST_COM_PREINIT_ST)
|
||||
::CoInitializeEx(0, COINIT_APARTMENTTHREADED);
|
||||
#endif
|
||||
|
||||
boost::timer::auto_cpu_timer t;
|
||||
|
||||
boost::thread t1(main_test_loop);
|
||||
@@ -64,9 +53,5 @@ int main() {
|
||||
t2.join();
|
||||
t3.join();
|
||||
|
||||
#if defined(BOOST_STACKTRACE_TEST_COM_PREINIT_MT) || defined(BOOST_STACKTRACE_TEST_COM_PREINIT_ST)
|
||||
::CoUninitialize();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user