mirror of
https://github.com/boostorg/stacktrace.git
synced 2026-01-28 19:52:08 +00:00
Compare commits
102 Commits
boost-1.66
...
boost-1.74
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e75d2ff93b | ||
|
|
a8a4cefb52 | ||
|
|
f931528c87 | ||
|
|
9b5bc54fe3 | ||
|
|
178d2875d7 | ||
|
|
ade7d54dc7 | ||
|
|
211d291253 | ||
|
|
b72cc6cdfd | ||
|
|
99e07cbea6 | ||
|
|
922305ea7d | ||
|
|
2fce6957d6 | ||
|
|
2cfcbf4247 | ||
|
|
0bddb90c1d | ||
|
|
b6bc847b0c | ||
|
|
6c5b7e51d5 | ||
|
|
acf5b12d02 | ||
|
|
9c3bdd4d0e | ||
|
|
dc0f0c752b | ||
|
|
09255fc94b | ||
|
|
293e1f43f6 | ||
|
|
7379a5cc08 | ||
|
|
7c7271d9bc | ||
|
|
6007c216b9 | ||
|
|
d5bbf7853a | ||
|
|
0be61ab0b8 | ||
|
|
43b837d181 | ||
|
|
2f75119cd0 | ||
|
|
36734b1531 | ||
|
|
2d810e294f | ||
|
|
6e79da7420 | ||
|
|
71acd94944 | ||
|
|
324a303fb0 | ||
|
|
876349f0d6 | ||
|
|
63d5d2730f | ||
|
|
248eedd52f | ||
|
|
c906a69c1d | ||
|
|
4f9da2ae71 | ||
|
|
1ad62e582a | ||
|
|
5c6740b680 | ||
|
|
d9d6512743 | ||
|
|
158a59ae51 | ||
|
|
839a1a127d | ||
|
|
411d92cbf3 | ||
|
|
1b7956a40d | ||
|
|
d708d17ecd | ||
|
|
d946b124ba | ||
|
|
39486260ae | ||
|
|
cbd625bd91 | ||
|
|
b08dab1c44 | ||
|
|
77405d8d7f | ||
|
|
324a24abba | ||
|
|
5e85e7414a | ||
|
|
4123beb4af | ||
|
|
f0a9ba6809 | ||
|
|
b414d35518 | ||
|
|
42bf318144 | ||
|
|
61c94e65e1 | ||
|
|
d573d2a405 | ||
|
|
9f232606cb | ||
|
|
d6f0c65a83 | ||
|
|
3089b733a8 | ||
|
|
99da94f5bd | ||
|
|
3f047cbfc4 | ||
|
|
e14dd6560a | ||
|
|
f328647e45 | ||
|
|
6d101ba4d6 | ||
|
|
c63afe54a2 | ||
|
|
745c6aa7a0 | ||
|
|
7a595a164f | ||
|
|
b4b84780b1 | ||
|
|
1289134b6d | ||
|
|
819f2b1c86 | ||
|
|
fb47f17836 | ||
|
|
b8dec8b126 | ||
|
|
7fedfa1265 | ||
|
|
4a5471a239 | ||
|
|
e4e2d4c3c1 | ||
|
|
14852ad597 | ||
|
|
87b4789289 | ||
|
|
e99f858990 | ||
|
|
c8165e7cf1 | ||
|
|
d6e2a56825 | ||
|
|
f8b8a806ed | ||
|
|
4603c1725d | ||
|
|
a0f948e9f5 | ||
|
|
7f20c8c676 | ||
|
|
31a630ced5 | ||
|
|
5b34577683 | ||
|
|
7cf669eaa6 | ||
|
|
910fe6ea4e | ||
|
|
40b792c7e4 | ||
|
|
b658a12183 | ||
|
|
caaea11dfa | ||
|
|
998334c3b5 | ||
|
|
57699543e8 | ||
|
|
940440bd3e | ||
|
|
168d9a7544 | ||
|
|
4fef2cb469 | ||
|
|
9523e26aad | ||
|
|
b7f4710c70 | ||
|
|
8f0735d9bd | ||
|
|
eba6db7bde |
210
.travis.yml
210
.travis.yml
@@ -2,122 +2,160 @@
|
||||
# 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-2016.
|
||||
# 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 #7
|
||||
# File revision #10
|
||||
|
||||
sudo: false
|
||||
language: cpp
|
||||
compiler:
|
||||
- gcc
|
||||
# - clang
|
||||
os: linux
|
||||
|
||||
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:
|
||||
global:
|
||||
# Autodetect Boost branch by using the following code: - BRANCH_TO_TEST=$TRAVIS_BRANCH
|
||||
# or just directly specify it
|
||||
#- BRANCH_TO_TEST=$TRAVIS_BRANCH
|
||||
- BRANCH_TO_TEST=develop
|
||||
- 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
|
||||
|
||||
# Files, which coverage results must be ignored (files from other projects).
|
||||
# Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/*'
|
||||
- IGNORE_COVERAGE='*/numeric/conversion/converter_policies.hpp */boost/progress.hpp */filesystem/src/* */libs/timer/src/* */thread/src/* */pthread/once_atomic.cpp */src/pthread/thread.cpp */thread/src/future.cpp */boost/operators.hpp'
|
||||
- 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
|
||||
|
||||
# Explicitly remove the following library from Boost. This may be usefull, if you're for example running Travis
|
||||
# from `Boost.DLL` repo, while Boost already has `dll`.
|
||||
#
|
||||
# By default is eaual to - BOOST_REMOVE=$(basename $TRAVIS_BUILD_DIR)
|
||||
# This will force to use local repo content, instead of the Boost's default.
|
||||
- BOOST_REMOVE=$(basename $TRAVIS_BUILD_DIR)
|
||||
# - 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
|
||||
|
||||
matrix:
|
||||
# Note that "--coverage -fsanitize=address,leak,undefined -DBOOST_TRAVISCI_BUILD" are added automatically lower in code
|
||||
- CXX_FLAGS="-std=c++98" LINK_FLAGS="" TOOLSET=gcc-6
|
||||
- CXX_FLAGS="-std=c++11" LINK_FLAGS="" TOOLSET=gcc-6
|
||||
- CXX_FLAGS="-std=c++1y" LINK_FLAGS="" TOOLSET=gcc-6
|
||||
- CXX_FLAGS="-std=c++11 -O0" LINK_FLAGS="" TOOLSET=gcc-6
|
||||
- CXX_FLAGS="-std=c++11 -O1" LINK_FLAGS="" TOOLSET=gcc-6
|
||||
#- CXX_FLAGS="-std=c++11 -stdlib=libc++" LINK_FLAGS="-stdlib=libc++" TOOLSET=clang
|
||||
#- CXX_FLAGS="-std=c++1y -stdlib=libc++" LINK_FLAGS="-stdlib=libc++" TOOLSET=clang
|
||||
# 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:
|
||||
- ubuntu-toolchain-r-test
|
||||
- git-core
|
||||
sources: git-core
|
||||
packages:
|
||||
- git
|
||||
- python-yaml
|
||||
- gcc-6
|
||||
- g++-6
|
||||
- clang
|
||||
- libc++-dev
|
||||
- binutils # for addr2line tests of Boost.Stacktrace
|
||||
|
||||
before_install:
|
||||
# Set this to the name of the library
|
||||
- PROJECT_TO_TEST=`basename $TRAVIS_BUILD_DIR`
|
||||
# Cloning Boost libraries (fast nondeep cloning)
|
||||
- BOOST=$HOME/boost-local
|
||||
- echo "Testing $PROJECT_TO_TEST, to remove $BOOST/libs/$BOOST_REMOVE, testing branch $BRANCH_TO_TEST"
|
||||
- git init $BOOST
|
||||
- cd $BOOST
|
||||
- git remote add --no-tags -t $BRANCH_TO_TEST origin https://github.com/boostorg/boost.git
|
||||
- git fetch --depth=1
|
||||
- git checkout $BRANCH_TO_TEST
|
||||
- git submodule update --jobs=3 --init --merge
|
||||
- git remote set-branches --add origin $BRANCH_TO_TEST
|
||||
- git pull --recurse-submodules
|
||||
- git status
|
||||
- rm -rf $BOOST/libs/$BOOST_REMOVE
|
||||
- mv $TRAVIS_BUILD_DIR $BOOST/libs/$PROJECT_TO_TEST
|
||||
- TRAVIS_BUILD_DIR=$BOOST/libs/$PROJECT_TO_TEST
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
- cd $BOOST/libs/$PROJECT_TO_TEST/test/
|
||||
# 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:
|
||||
# `--coverage` flags required to generate coverage info for Coveralls
|
||||
- ../../../b2 -a "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.3 " address-model=64 architecture=x86 toolset=$TOOLSET cxxflags="--coverage -fsanitize=address,leak,undefined -DBOOST_TRAVISCI_BUILD $CXX_FLAGS" linkflags="$LINK_FLAGS --coverage -lasan -lubsan"
|
||||
- ../../../b2 -a address-model=64 architecture=x86 toolset=$TOOLSET cxxflags="-fsanitize=thread -DBOOST_TRAVISCI_BUILD $CXX_FLAGS" linkflags="$LINK_FLAGS -ltsan"
|
||||
- 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"
|
||||
# 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
|
||||
# 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*" "*/$PROJECT_TO_TEST/test/*" $IGNORE_COVERAGE "*/$PROJECT_TO_TEST/tests/*" "*/$PROJECT_TO_TEST/examples/*" "*/$PROJECT_TO_TEST/example/*" -o $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\/$PROJECT_TO_TEST\/\*\"/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"
|
||||
# ... 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
|
||||
# Sending data to Coveralls
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
- gem install coveralls-lcov
|
||||
- coveralls-lcov coverals/coverage.info
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2016-2017, Antony Polukhin.
|
||||
# Copyright (C) 2016-2019, 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
|
||||
@@ -8,7 +8,7 @@
|
||||
project
|
||||
: source-location .
|
||||
: requirements
|
||||
<target-os>linux:<cxxflags>"-fvisibility=hidden"
|
||||
<visibility>hidden
|
||||
;
|
||||
|
||||
lib dl ;
|
||||
@@ -51,6 +51,8 @@ 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
|
||||
@@ -62,7 +64,7 @@ lib boost_stacktrace_noop
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_stacktrace_noop ;
|
||||
libraries += boost_stacktrace_noop ;
|
||||
|
||||
lib boost_stacktrace_backtrace
|
||||
: # sources
|
||||
@@ -78,7 +80,7 @@ lib boost_stacktrace_backtrace
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_stacktrace_backtrace ;
|
||||
libraries += boost_stacktrace_backtrace ;
|
||||
|
||||
lib boost_stacktrace_addr2line
|
||||
: # sources
|
||||
@@ -93,7 +95,7 @@ lib boost_stacktrace_addr2line
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_stacktrace_addr2line ;
|
||||
libraries += boost_stacktrace_addr2line ;
|
||||
|
||||
lib boost_stacktrace_basic
|
||||
: # sources
|
||||
@@ -108,7 +110,7 @@ lib boost_stacktrace_basic
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_stacktrace_basic ;
|
||||
libraries += boost_stacktrace_basic ;
|
||||
|
||||
lib boost_stacktrace_windbg
|
||||
: # sources
|
||||
@@ -123,7 +125,7 @@ lib boost_stacktrace_windbg
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_stacktrace_windbg ;
|
||||
libraries += boost_stacktrace_windbg ;
|
||||
|
||||
lib boost_stacktrace_windbg_cached
|
||||
: # sources
|
||||
@@ -138,5 +140,6 @@ lib boost_stacktrace_windbg_cached
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_stacktrace_windbg_cached ;
|
||||
libraries += boost_stacktrace_windbg_cached ;
|
||||
|
||||
boost-install $(libraries) ;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,7 +18,7 @@
|
||||
int foo() {
|
||||
static thread_local std::string i = std::string();
|
||||
|
||||
return i.size();
|
||||
return static_cast<int>(i.size());
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright Antony Polukhin 2016-2017.
|
||||
# Copyright Antony Polukhin 2016-2019.
|
||||
# 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-2017 Antony Polukhin]
|
||||
[copyright 2016-2020 Antony Polukhin]
|
||||
[category Language Features Emulation]
|
||||
[license
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -67,6 +67,8 @@ Segmentation Faults and `std::terminate` calls sometimes happen in programs. Pro
|
||||
|
||||
[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]
|
||||
@@ -140,7 +142,7 @@ Now we do know the steps that led to the assertion and can find the error withou
|
||||
|
||||
[section Exceptions with stacktrace]
|
||||
|
||||
You can provide more information along with exception by embedding stacktraces into the exception. There are many ways to do that, here's how to doe that using Boost.Exception:
|
||||
You can provide more information along with exception by embedding stacktraces into the exception. There are many ways to do that, here's how to do that using Boost.Exception:
|
||||
|
||||
* Declare a `boost::error_info` typedef that holds the stacktrace:
|
||||
|
||||
@@ -296,7 +298,7 @@ In header only mode library could be tuned by macro. If one of the link macro fr
|
||||
[[['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]]
|
||||
[[['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, or built into your compiler.
|
||||
[[*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.
|
||||
|
||||
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]]
|
||||
@@ -306,8 +308,8 @@ In header only mode library could be tuned by macro. If one of the link macro fr
|
||||
[*Examples:]
|
||||
|
||||
* if you wish to switch to more powerful implementation on Clang/MinGW and *BOOST_STACKTRACE_LINK* is defined, you just need link with "*-lboost_stacktrace_backtrace -ldl -lbacktrace*" or "*-lboost_stacktrace_addr2line -ldl*"
|
||||
* if you wish to disable backtracing and you use the library in header only mode, you just need to define *BOOST_STACKTRACE_USE_NOOP* for the whole project
|
||||
* if you wish to disable backtracing and *BOOST_STACKTRACE_LINK* is defined, you just need link with *-lboost_stacktrace_noop*
|
||||
* if you wish to disable backtracing and you use the library in header only mode, you just need to define *BOOST_STACKTRACE_USE_NOOP* for the whole project and recompile it
|
||||
|
||||
[section MinGW and MinGW-w64 specific notes]
|
||||
|
||||
@@ -328,6 +330,17 @@ Let's assume that you've installed MinGW into C:\MinGW and downloaded [@https://
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Windows deployment and symbol files]
|
||||
|
||||
Function names may not be resolved after deployment of your application to a different system.
|
||||
|
||||
There are multiple ways to deal with that issue if you distribute PDB files along with your application:
|
||||
|
||||
* Link your application and shared libraries with a properly set `/PDBALTPATH` flag, for example `/PDBALTPATH:%_PDB%`. See [@https://docs.microsoft.com/en-us/cpp/build/reference/pdbaltpath-use-alternate-pdb-path official documentation for more info].
|
||||
* Set the `_NT_ALT_SYMBOL_PATH` or `_NT_SYMBOL_PATH` environment variables of the target system to the path of the PDBs. See [@https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/symbol-path#controlling-the-symbol-path official documentation for more info].
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Acknowledgements]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -24,9 +24,6 @@ BOOST_NOINLINE void foo(int i) {
|
||||
bar(--i);
|
||||
}
|
||||
|
||||
namespace std { inline void ignore_abort(){ std::exit(0); } }
|
||||
#define abort ignore_abort
|
||||
|
||||
//[getting_started_assert_handlers
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER is defined for the whole project
|
||||
@@ -38,7 +35,8 @@ namespace boost {
|
||||
inline void assertion_failed_msg(char const* expr, char const* msg, char const* function, char const* /*file*/, long /*line*/) {
|
||||
std::cerr << "Expression '" << expr << "' is false in function '" << function << "': " << (msg ? msg : "<...>") << ".\n"
|
||||
<< "Backtrace:\n" << boost::stacktrace::stacktrace() << '\n';
|
||||
std::abort();
|
||||
/*<-*/ std::exit(0); /*->*/
|
||||
/*=std::abort();*/
|
||||
}
|
||||
|
||||
inline void assertion_failed(char const* expr, char const* function, char const* file, long line) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -28,8 +28,6 @@ void my_signal_handler(int /*signum*/) {
|
||||
int main() {
|
||||
::signal(SIGSEGV, &my_signal_handler);
|
||||
print_signal_handler_and_exit();
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -271,6 +271,13 @@ int test_inplace() {
|
||||
|
||||
boost::filesystem::remove("./backtrace3.dump");
|
||||
|
||||
#ifdef BOOST_WINDOWS
|
||||
// `ss2` could be empty on some combinations of Windows+MSVC.
|
||||
if (!ss2) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ss1.size() != ss2.size()) {
|
||||
std::cerr << "Stacktraces differ:\n" << ss1 << "\n vs \n" << ss2 << '\n';
|
||||
return 58;
|
||||
@@ -293,12 +300,12 @@ int test_inplace() {
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
if (argc < 2) {
|
||||
#ifndef BOOST_WINDOWS
|
||||
// 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);
|
||||
|
||||
#ifndef BOOST_WINDOWS
|
||||
// There are some issues with async-safety of shared mmory writes on Windows.
|
||||
// There are some issues with async-safety of shared memory writes on Windows.
|
||||
copy_and_run(argv[0], '3', true);
|
||||
copy_and_run(argv[0], '4', false);
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -35,7 +35,7 @@ BOOST_NOINLINE void oops(int i) {
|
||||
if (i >= 4)
|
||||
throw_with_trace(std::out_of_range("'i' must be less than 4 in oops()"));
|
||||
if (i <= 0)
|
||||
throw_with_trace(std::logic_error("'i' must not be greater than zero in oops()"));
|
||||
throw_with_trace(std::logic_error("'i' must be greater than zero in oops()"));
|
||||
//]
|
||||
foo(i);
|
||||
std::exit(1);
|
||||
@@ -68,8 +68,8 @@ int main() {
|
||||
std::cerr << e.what() << '\n';
|
||||
const boost::stacktrace::stacktrace* st = boost::get_error_info<traced>(e);
|
||||
if (st) {
|
||||
std::cerr << *st << '\n'; /*<-*/ std::exit(0); /*->*/
|
||||
} /*<-*/ std::exit(3); /*->*/
|
||||
std::cerr << *st << '\n'; /*<-*/ return 0; /*->*/
|
||||
} /*<-*/ return 3; /*->*/
|
||||
}
|
||||
//]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -29,6 +29,9 @@ std::basic_ostream<CharT, TraitsT>& operator<<(std::basic_ostream<CharT, TraitsT
|
||||
|
||||
#ifndef USER_CONFIG2_HPP
|
||||
#define USER_CONFIG2_HPP
|
||||
|
||||
#include <ios> // std::streamsize
|
||||
|
||||
//[getting_started_user_config_impl
|
||||
namespace boost { namespace stacktrace {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -13,8 +13,9 @@
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/try_dec_convert.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -212,7 +213,7 @@ std::size_t frame::source_line() const {
|
||||
}
|
||||
res = res.substr(last + 1);
|
||||
|
||||
if (!boost::conversion::try_lexical_convert(res, line_num)) {
|
||||
if (!boost::stacktrace::detail::try_dec_convert(res.c_str(), line_num)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,15 +14,15 @@
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
|
||||
#include <boost/detail/winapi/stack_backtrace.hpp>
|
||||
#include <boost/winapi/stack_backtrace.hpp>
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) BOOST_NOEXCEPT {
|
||||
return boost::detail::winapi::RtlCaptureStackBackTrace(
|
||||
static_cast<boost::detail::winapi::ULONG_>(skip),
|
||||
static_cast<boost::detail::winapi::ULONG_>(max_frames_count),
|
||||
const_cast<boost::detail::winapi::PVOID_*>(out_frames),
|
||||
return boost::winapi::RtlCaptureStackBackTrace(
|
||||
static_cast<boost::winapi::ULONG_>(skip),
|
||||
static_cast<boost::winapi::ULONG_>(max_frames_count),
|
||||
const_cast<boost::winapi::PVOID_*>(out_frames),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,7 +14,19 @@
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
|
||||
// On iOS 32-bit ARM architecture _Unwind_Backtrace function doesn't exist, symbol is undefined.
|
||||
// Forcing libc backtrace() function usage.
|
||||
#include <boost/predef.h>
|
||||
#if defined(BOOST_OS_IOS_AVAILABLE) && defined(BOOST_ARCH_ARM_AVAILABLE) && BOOST_VERSION_NUMBER_MAJOR(BOOST_ARCH_ARM) < 8
|
||||
#define BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION)
|
||||
#include <execinfo.h>
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include <unwind.h>
|
||||
#endif
|
||||
#include <cstdio>
|
||||
|
||||
#if !defined(_GNU_SOURCE) && !defined(BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED) && !defined(BOOST_WINDOWS)
|
||||
@@ -23,6 +35,7 @@
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
#if !defined(BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION)
|
||||
struct unwind_state {
|
||||
std::size_t frames_to_skip;
|
||||
native_frame_ptr_t* current;
|
||||
@@ -48,16 +61,35 @@ inline _Unwind_Reason_Code unwind_callback(::_Unwind_Context* context, void* arg
|
||||
}
|
||||
return ::_URC_NO_REASON;
|
||||
}
|
||||
#endif //!defined(BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION)
|
||||
|
||||
std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) BOOST_NOEXCEPT {
|
||||
std::size_t frames_count = 0;
|
||||
if (!max_frames_count) {
|
||||
return frames_count;
|
||||
}
|
||||
skip += 1;
|
||||
|
||||
boost::stacktrace::detail::unwind_state state = { skip + 1, out_frames, out_frames + max_frames_count };
|
||||
#if defined(BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION)
|
||||
// According to https://opensource.apple.com/source/Libc/Libc-1272.200.26/gen/backtrace.c.auto.html
|
||||
// it looks like the `::backtrace` is async signal safe.
|
||||
frames_count = static_cast<size_t>(::backtrace(const_cast<void **>(out_frames), static_cast<int>(max_frames_count)));
|
||||
|
||||
// NOTE: There is no way to pass "skip" count to backtrace function so we need to perform left shift operation.
|
||||
// If number of elements in result backtrace is >= max_frames_count then "skip" elements are wasted.
|
||||
if (frames_count && skip) {
|
||||
if (skip >= frames_count) {
|
||||
frames_count = 0;
|
||||
} else {
|
||||
std::copy(out_frames + skip, out_frames + frames_count, out_frames);
|
||||
frames_count -= skip;
|
||||
}
|
||||
}
|
||||
#else
|
||||
boost::stacktrace::detail::unwind_state state = { skip, out_frames, out_frames + max_frames_count };
|
||||
::_Unwind_Backtrace(&boost::stacktrace::detail::unwind_callback, &state);
|
||||
frames_count = state.current - out_frames;
|
||||
#endif //defined(BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION)
|
||||
|
||||
if (frames_count && out_frames[frames_count - 1] == 0) {
|
||||
-- frames_count;
|
||||
@@ -69,4 +101,6 @@ std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::siz
|
||||
|
||||
}}} // namespace boost::stacktrace::detail
|
||||
|
||||
#undef BOOST_STACKTRACE_USE_LIBC_BACKTRACE_FUNCTION
|
||||
|
||||
#endif // BOOST_STACKTRACE_DETAIL_COLLECT_UNWIND_IPP
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
#include <windows.h>
|
||||
#include "dbgeng.h"
|
||||
|
||||
#include <boost/detail/winapi/get_current_process.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma comment(lib, "ole32.lib")
|
||||
# pragma comment(lib, "Dbgeng.lib")
|
||||
@@ -59,7 +57,7 @@ public:
|
||||
//
|
||||
// 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 boost::detail::winapi::DWORD_ res = ::CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
const DWORD res = ::CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
ok_ = (res == S_OK || res == S_FALSE);
|
||||
}
|
||||
|
||||
@@ -100,7 +98,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
static std::string minwg_demangling_workaround(const std::string& s) {
|
||||
inline std::string mingw_demangling_workaround(const std::string& s) {
|
||||
#ifdef BOOST_GCC
|
||||
if (s.empty()) {
|
||||
return s;
|
||||
@@ -116,6 +114,17 @@ static std::string minwg_demangling_workaround(const std::string& s) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void trim_right_zeroes(std::string& s) {
|
||||
// MSVC-9 does not have back() and pop_back() functions in std::string
|
||||
while (!s.empty()) {
|
||||
const std::size_t last = static_cast<std::size_t>(s.size() - 1);
|
||||
if (s[last] != '\0') {
|
||||
break;
|
||||
}
|
||||
s.resize(last);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -219,6 +228,7 @@ public:
|
||||
&size,
|
||||
0
|
||||
));
|
||||
trim_right_zeroes(result);
|
||||
} else if (res) {
|
||||
result = name;
|
||||
}
|
||||
@@ -239,7 +249,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
result = minwg_demangling_workaround(
|
||||
result = mingw_demangling_workaround(
|
||||
result.substr(delimiter + 1)
|
||||
);
|
||||
|
||||
@@ -303,6 +313,7 @@ public:
|
||||
&size,
|
||||
0
|
||||
));
|
||||
trim_right_zeroes(result.first);
|
||||
result.second = line_num;
|
||||
|
||||
if (!res) {
|
||||
@@ -331,7 +342,7 @@ public:
|
||||
res += " at ";
|
||||
res += source_line.first;
|
||||
res += ':';
|
||||
res += boost::lexical_cast<boost::array<char, 40> >(source_line.second).data();
|
||||
res += boost::stacktrace::detail::to_dec_array(source_line.second).data();
|
||||
} else if (!module_name.empty()) {
|
||||
res += " in ";
|
||||
res += module_name;
|
||||
@@ -351,7 +362,7 @@ std::string to_string(const frame* frames, std::size_t size) {
|
||||
if (i < 10) {
|
||||
res += ' ';
|
||||
}
|
||||
res += boost::lexical_cast<boost::array<char, 40> >(i).data();
|
||||
res += boost::stacktrace::detail::to_dec_array(i).data();
|
||||
res += '#';
|
||||
res += ' ';
|
||||
idebug.to_string_impl(frames[i].address(), res);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
#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/core/demangle.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
@@ -59,6 +59,9 @@ public:
|
||||
|
||||
std::string to_string(const frame* frames, std::size_t size) {
|
||||
std::string res;
|
||||
if (size == 0) {
|
||||
return res;
|
||||
}
|
||||
res.reserve(64 * size);
|
||||
|
||||
to_string_impl impl;
|
||||
@@ -67,7 +70,7 @@ std::string to_string(const frame* frames, std::size_t size) {
|
||||
if (i < 10) {
|
||||
res += ' ';
|
||||
}
|
||||
res += boost::lexical_cast<boost::array<char, 40> >(i).data();
|
||||
res += boost::stacktrace::detail::to_dec_array(i).data();
|
||||
res += '#';
|
||||
res += ' ';
|
||||
res += impl(frames[i].address());
|
||||
@@ -82,9 +85,13 @@ std::string to_string(const frame* frames, std::size_t size) {
|
||||
|
||||
|
||||
std::string frame::name() const {
|
||||
if (!addr_) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
::Dl_info dli;
|
||||
const bool dl_ok = !!::dladdr(addr_, &dli);
|
||||
const bool dl_ok = !!::dladdr(const_cast<void*>(addr_), &dli); // `dladdr` on Solaris accepts nonconst addresses
|
||||
if (dl_ok && dli.dli_sname) {
|
||||
return boost::core::demangle(dli.dli_sname);
|
||||
}
|
||||
@@ -93,6 +100,10 @@ std::string frame::name() const {
|
||||
}
|
||||
|
||||
std::string to_string(const frame& f) {
|
||||
if (!f) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
boost::stacktrace::detail::to_string_impl impl;
|
||||
return impl(f.address());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -13,11 +13,15 @@
|
||||
#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>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <backtrace.h>
|
||||
#ifdef BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE
|
||||
# include BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE
|
||||
#else
|
||||
# include <backtrace.h>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
@@ -28,6 +32,18 @@ struct pc_data {
|
||||
std::size_t line;
|
||||
};
|
||||
|
||||
inline void libbacktrace_syminfo_callback(void *data, uintptr_t /*pc*/, const char *symname, uintptr_t /*symval*/, uintptr_t /*symsize*/) {
|
||||
pc_data& d = *static_cast<pc_data*>(data);
|
||||
if (d.function && symname) {
|
||||
*d.function = symname;
|
||||
}
|
||||
}
|
||||
|
||||
// Old versions of libbacktrace have different signature for the callback
|
||||
inline void libbacktrace_syminfo_callback(void *data, uintptr_t pc, const char *symname, uintptr_t symval) {
|
||||
boost::stacktrace::detail::libbacktrace_syminfo_callback(data, pc, symname, symval, 0);
|
||||
}
|
||||
|
||||
inline int libbacktrace_full_callback(void *data, uintptr_t /*pc*/, const char *filename, int lineno, const char *function) {
|
||||
pc_data& d = *static_cast<pc_data*>(data);
|
||||
if (d.filename && filename) {
|
||||
@@ -44,30 +60,54 @@ inline void libbacktrace_error_callback(void* /*data*/, const char* /*msg*/, int
|
||||
// Do nothing, just return.
|
||||
}
|
||||
|
||||
|
||||
inline ::backtrace_state* construct_state(const program_location& prog_location) BOOST_NOEXCEPT {
|
||||
// Currently `backtrace_create_state` can not detect file name on Windows https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82543
|
||||
// That's why we provide a `prog_location` here.
|
||||
return ::backtrace_create_state(
|
||||
prog_location.name(), 0 /*thread-safe*/, boost::stacktrace::detail::libbacktrace_error_callback, 0
|
||||
);
|
||||
|
||||
// TODO: this does not seem to work well when this function is in .so:
|
||||
// Not async-signal-safe, so this method is not called from async-safe functions.
|
||||
//
|
||||
// This function is not async signal safe because:
|
||||
// * Dynamic initialization of a block-scope variable with static storage duration could lock a mutex
|
||||
// * No guarantees on `backtrace_create_state` function.
|
||||
|
||||
// Not async-signal-safe, so this method is not called from async-safe functions.
|
||||
//
|
||||
// This function is not async signal safe because:
|
||||
// * Dynamic initialization of a block-scope variable with static storage duration could lock a mutex
|
||||
// * No guarantees on `backtrace_create_state` function.
|
||||
//
|
||||
// Currently `backtrace_create_state` can not detect file name on Windows https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82543
|
||||
// That's why we provide a `prog_location` here.
|
||||
BOOST_SYMBOL_VISIBLE inline ::backtrace_state* construct_state(const program_location& prog_location) BOOST_NOEXCEPT {
|
||||
// [dcl.inline]: A static local variable in an inline function with external linkage always refers to the same object.
|
||||
|
||||
/*
|
||||
static ::backtrace_state* state = ::backtrace_create_state(
|
||||
0, 1 , boost::stacktrace::detail::libbacktrace_error_callback, 0
|
||||
);
|
||||
// TODO: The most obvious solution:
|
||||
//
|
||||
//static ::backtrace_state* state = ::backtrace_create_state(
|
||||
// prog_location.name(),
|
||||
// 1, // allow safe concurrent usage of the same state
|
||||
// boost::stacktrace::detail::libbacktrace_error_callback,
|
||||
// 0 // pointer to data that will be passed to callback
|
||||
//);
|
||||
//
|
||||
//
|
||||
// Unfortunately, that solution segfaults when `construct_state()` function is in .so file
|
||||
// and multiple threads concurrently work with state.
|
||||
|
||||
|
||||
#ifndef BOOST_HAS_THREADS
|
||||
static
|
||||
#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
|
||||
|
||||
#endif
|
||||
::backtrace_state* state = ::backtrace_create_state(
|
||||
prog_location.name(),
|
||||
0,
|
||||
boost::stacktrace::detail::libbacktrace_error_callback,
|
||||
0
|
||||
);
|
||||
return state;
|
||||
*/
|
||||
}
|
||||
|
||||
struct to_string_using_backtrace {
|
||||
@@ -86,6 +126,14 @@ struct to_string_using_backtrace {
|
||||
boost::stacktrace::detail::libbacktrace_full_callback,
|
||||
boost::stacktrace::detail::libbacktrace_error_callback,
|
||||
&data
|
||||
)
|
||||
||
|
||||
::backtrace_syminfo(
|
||||
state,
|
||||
reinterpret_cast<uintptr_t>(addr),
|
||||
boost::stacktrace::detail::libbacktrace_syminfo_callback,
|
||||
boost::stacktrace::detail::libbacktrace_error_callback,
|
||||
&data
|
||||
);
|
||||
}
|
||||
line = data.line;
|
||||
@@ -99,7 +147,7 @@ struct to_string_using_backtrace {
|
||||
res += " at ";
|
||||
res += filename;
|
||||
res += ':';
|
||||
res += boost::lexical_cast<boost::array<char, 40> >(line).data();
|
||||
res += boost::stacktrace::detail::to_dec_array(line).data();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -125,6 +173,14 @@ inline std::string name_impl(const void* addr) {
|
||||
boost::stacktrace::detail::libbacktrace_full_callback,
|
||||
boost::stacktrace::detail::libbacktrace_error_callback,
|
||||
&data
|
||||
)
|
||||
||
|
||||
::backtrace_syminfo(
|
||||
state,
|
||||
reinterpret_cast<uintptr_t>(addr),
|
||||
boost::stacktrace::detail::libbacktrace_syminfo_callback,
|
||||
boost::stacktrace::detail::libbacktrace_error_callback,
|
||||
&data
|
||||
);
|
||||
}
|
||||
if (!res.empty()) {
|
||||
@@ -139,6 +195,10 @@ inline std::string name_impl(const void* addr) {
|
||||
std::string frame::source_file() const {
|
||||
std::string res;
|
||||
|
||||
if (!addr_) {
|
||||
return res;
|
||||
}
|
||||
|
||||
boost::stacktrace::detail::program_location prog_location;
|
||||
::backtrace_state* state = boost::stacktrace::detail::construct_state(prog_location);
|
||||
|
||||
@@ -157,6 +217,10 @@ std::string frame::source_file() const {
|
||||
}
|
||||
|
||||
std::size_t frame::source_line() const {
|
||||
if (!addr_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
boost::stacktrace::detail::program_location prog_location;
|
||||
::backtrace_state* state = boost::stacktrace::detail::construct_state(prog_location);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -15,7 +15,7 @@
|
||||
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
# include <boost/detail/winapi/dll.hpp>
|
||||
# include <boost/winapi/dll.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
explicit location_from_symbol(const void* addr) BOOST_NOEXCEPT
|
||||
: dli_()
|
||||
{
|
||||
if (!::dladdr(addr, &dli_)) {
|
||||
if (!::dladdr(const_cast<void*>(addr), &dli_)) { // `dladdr` on Solaris accepts nonconst addresses
|
||||
dli_.dli_fname = 0;
|
||||
}
|
||||
}
|
||||
@@ -52,20 +52,20 @@ public:
|
||||
#else
|
||||
|
||||
class location_from_symbol {
|
||||
BOOST_STATIC_CONSTEXPR boost::detail::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260;
|
||||
BOOST_STATIC_CONSTEXPR boost::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260;
|
||||
char file_name_[DEFAULT_PATH_SIZE_];
|
||||
|
||||
public:
|
||||
explicit location_from_symbol(const void* addr) BOOST_NOEXCEPT {
|
||||
file_name_[0] = '\0';
|
||||
|
||||
boost::detail::winapi::MEMORY_BASIC_INFORMATION_ mbi;
|
||||
if (!boost::detail::winapi::VirtualQuery(addr, &mbi, sizeof(mbi))) {
|
||||
boost::winapi::MEMORY_BASIC_INFORMATION_ mbi;
|
||||
if (!boost::winapi::VirtualQuery(addr, &mbi, sizeof(mbi))) {
|
||||
return;
|
||||
}
|
||||
|
||||
boost::detail::winapi::HMODULE_ handle = reinterpret_cast<boost::detail::winapi::HMODULE_>(mbi.AllocationBase);
|
||||
if (!boost::detail::winapi::GetModuleFileNameA(handle, file_name_, DEFAULT_PATH_SIZE_)) {
|
||||
boost::winapi::HMODULE_ handle = reinterpret_cast<boost::winapi::HMODULE_>(mbi.AllocationBase);
|
||||
if (!boost::winapi::GetModuleFileNameA(handle, file_name_, DEFAULT_PATH_SIZE_)) {
|
||||
file_name_[0] = '\0';
|
||||
return;
|
||||
}
|
||||
@@ -81,15 +81,15 @@ public:
|
||||
};
|
||||
|
||||
class program_location {
|
||||
BOOST_STATIC_CONSTEXPR boost::detail::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260;
|
||||
BOOST_STATIC_CONSTEXPR boost::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260;
|
||||
char file_name_[DEFAULT_PATH_SIZE_];
|
||||
|
||||
public:
|
||||
program_location() BOOST_NOEXCEPT {
|
||||
file_name_[0] = '\0';
|
||||
|
||||
const boost::detail::winapi::HMODULE_ handle = 0;
|
||||
if (!boost::detail::winapi::GetModuleFileNameA(handle, file_name_, DEFAULT_PATH_SIZE_)) {
|
||||
const boost::winapi::HMODULE_ handle = 0;
|
||||
if (!boost::winapi::GetModuleFileNameA(handle, file_name_, DEFAULT_PATH_SIZE_)) {
|
||||
file_name_[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2019.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,43 +16,49 @@
|
||||
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
|
||||
#include <boost/detail/winapi/get_current_process.hpp>
|
||||
#include <boost/detail/winapi/file_management.hpp>
|
||||
#include <boost/detail/winapi/handles.hpp>
|
||||
#include <boost/detail/winapi/access_rights.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>
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
std::size_t dump(void* fd, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT {
|
||||
boost::detail::winapi::DWORD_ written;
|
||||
const boost::detail::winapi::DWORD_ bytes_to_write = static_cast<boost::detail::winapi::DWORD_>(
|
||||
std::size_t dump(void* /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT {
|
||||
#if 0 // This code potentially could cause deadlocks (according to the MSDN). Disabled
|
||||
boost::winapi::DWORD_ written;
|
||||
const boost::winapi::DWORD_ bytes_to_write = static_cast<boost::winapi::DWORD_>(
|
||||
sizeof(native_frame_ptr_t) * frames_count
|
||||
);
|
||||
if (!boost::detail::winapi::WriteFile(fd, frames, bytes_to_write, &written, 0)) {
|
||||
if (!boost::winapi::WriteFile(fd, frames, bytes_to_write, &written, 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return frames_count;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::size_t dump(const char* file, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT {
|
||||
void* const fd = boost::detail::winapi::CreateFileA(
|
||||
std::size_t dump(const char* /*file*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT {
|
||||
#if 0 // This code causing deadlocks on some platforms. Disabled
|
||||
void* const fd = boost::winapi::CreateFileA(
|
||||
file,
|
||||
boost::detail::winapi::GENERIC_WRITE_,
|
||||
boost::winapi::GENERIC_WRITE_,
|
||||
0,
|
||||
0,
|
||||
boost::detail::winapi::CREATE_ALWAYS_,
|
||||
boost::detail::winapi::FILE_ATTRIBUTE_NORMAL_,
|
||||
boost::winapi::CREATE_ALWAYS_,
|
||||
boost::winapi::FILE_ATTRIBUTE_NORMAL_,
|
||||
0
|
||||
);
|
||||
|
||||
if (fd == boost::detail::winapi::invalid_handle_value) {
|
||||
if (fd == boost::winapi::invalid_handle_value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std::size_t size = boost::stacktrace::detail::dump(fd, frames, frames_count);
|
||||
boost::detail::winapi::CloseHandle(fd);
|
||||
boost::winapi::CloseHandle(fd);
|
||||
return size;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
}}} // namespace boost::stacktrace::detail
|
||||
|
||||
46
include/boost/stacktrace/detail/to_dec_array.hpp
Normal file
46
include/boost/stacktrace/detail/to_dec_array.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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_TO_DEC_ARRAY_HPP
|
||||
#define BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
// We do not use boost::lexical_cast in this function to reduce module dependencies
|
||||
inline boost::array<char, 40> to_dec_array(std::size_t value) BOOST_NOEXCEPT {
|
||||
boost::array<char, 40> ret;
|
||||
if (!value) {
|
||||
ret[0] = '0';
|
||||
ret[1] = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::size_t digits = 0;
|
||||
for (std::size_t value_copy = value; value_copy; value_copy /= 10) {
|
||||
++ digits;
|
||||
}
|
||||
|
||||
for (std::size_t i = 1; i <= digits; ++i) {
|
||||
ret[digits - i] = static_cast<char>('0' + (value % 10));
|
||||
value /= 10;
|
||||
}
|
||||
|
||||
ret[digits] = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}}} // namespace boost::stacktrace::detail
|
||||
|
||||
#endif // BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
29
include/boost/stacktrace/detail/try_dec_convert.hpp
Normal file
29
include/boost/stacktrace/detail/try_dec_convert.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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_TRY_DEC_CONVERT_HPP
|
||||
#define BOOST_STACKTRACE_DETAIL_TRY_DEC_CONVERT_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
|
||||
// We do not use boost::lexical_cast in this function to reduce module dependencies
|
||||
inline bool try_dec_convert(const char* s, std::size_t& res) BOOST_NOEXCEPT {
|
||||
char* end_ptr = 0;
|
||||
res = std::strtoul(s, &end_ptr, 10);
|
||||
return *end_ptr == '\0';
|
||||
}
|
||||
|
||||
|
||||
}}} // namespace boost::stacktrace::detail
|
||||
|
||||
#endif // BOOST_STACKTRACE_DETAIL_TRY_DEC_CONVERT_HPP
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -12,7 +12,10 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/detail/winapi/config.hpp>
|
||||
#if defined(BOOST_WINDOWS)
|
||||
#include <boost/winapi/config.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/stacktrace/detail/push_options.h>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
@@ -81,7 +84,7 @@ struct this_thread_frames { // struct is required to avoid warning about usage o
|
||||
///
|
||||
/// @b Async-Handler-Safety: Safe.
|
||||
///
|
||||
/// @returns Stored call sequence depth including terminating zero frame.
|
||||
/// @returns Stored call sequence depth including terminating zero frame. To get the actually consumed bytes multiply this value by the sizeof(boost::stacktrace::frame::native_frame_ptr_t)
|
||||
///
|
||||
/// @param memory Preallocated buffer to store current function call sequence into.
|
||||
///
|
||||
@@ -96,7 +99,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(void* memory, std::size_t size) BOOST
|
||||
///
|
||||
/// @b Async-Handler-Safety: Safe.
|
||||
///
|
||||
/// @returns Stored call sequence depth including terminating zero frame.
|
||||
/// @returns Stored call sequence depth including terminating zero frame. To get the actually consumed bytes multiply this value by the sizeof(boost::stacktrace::frame::native_frame_ptr_t)
|
||||
///
|
||||
/// @param skip How many top calls to skip and do not store.
|
||||
///
|
||||
@@ -108,7 +111,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, void* memory, std::
|
||||
}
|
||||
|
||||
|
||||
/// @brief Opens a file and rewrites its content with current function call sequence.
|
||||
/// @brief Opens a file and rewrites its content with current function call sequence if such operations are async signal safe.
|
||||
///
|
||||
/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined.
|
||||
///
|
||||
@@ -121,7 +124,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(const char* file) BOOST_NOEXCEPT {
|
||||
return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(file, 0, boost::stacktrace::detail::max_frames_dump);
|
||||
}
|
||||
|
||||
/// @brief Opens a file and rewrites its content with current function call sequence.
|
||||
/// @brief Opens a file and rewrites its content with current function call sequence if such operations are async signal safe.
|
||||
///
|
||||
/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined.
|
||||
///
|
||||
@@ -140,7 +143,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_dep
|
||||
|
||||
#ifdef BOOST_STACKTRACE_DOXYGEN_INVOKED
|
||||
|
||||
/// @brief Writes into the provided file descriptor the current function call sequence.
|
||||
/// @brief Writes into the provided file descriptor the current function call sequence if such operation is async signal safe.
|
||||
///
|
||||
/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined.
|
||||
///
|
||||
@@ -151,7 +154,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_dep
|
||||
/// @param file File to store current function call sequence.
|
||||
BOOST_FORCEINLINE std::size_t safe_dump_to(platform_specific_descriptor fd) BOOST_NOEXCEPT;
|
||||
|
||||
/// @brief Writes into the provided file descriptor the current function call sequence.
|
||||
/// @brief Writes into the provided file descriptor the current function call sequence if such operation is async signal safe.
|
||||
///
|
||||
/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined.
|
||||
///
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -13,6 +13,8 @@
|
||||
#endif
|
||||
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/container_hash/hash_fwd.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
@@ -31,13 +33,6 @@
|
||||
# pragma warning(disable:2196) // warning #2196: routine is both "inline" and "noinline"
|
||||
#endif
|
||||
|
||||
/// @cond
|
||||
namespace boost {
|
||||
// Forward declaration
|
||||
template <class It> std::size_t hash_range(It, It);
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
namespace boost { namespace stacktrace {
|
||||
|
||||
/// Class that on construction copies minimal information about call stack into its internals and provides access to that information.
|
||||
@@ -75,33 +70,36 @@ class basic_stacktrace {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
BOOST_TRY {
|
||||
{ // Fast path without additional allocations
|
||||
native_frame_ptr_t buffer[buffer_size];
|
||||
const std::size_t frames_count = boost::stacktrace::detail::this_thread_frames::collect(buffer, buffer_size, frames_to_skip + 1);
|
||||
if (buffer_size > frames_count || frames_count >= max_depth) {
|
||||
const std::size_t size = (max_depth < frames_count ? max_depth : frames_count);
|
||||
fill(buffer, size);
|
||||
const std::size_t frames_count = boost::stacktrace::detail::this_thread_frames::collect(buffer, buffer_size < max_depth ? buffer_size : max_depth, frames_to_skip + 1);
|
||||
if (buffer_size > frames_count || frames_count == max_depth) {
|
||||
fill(buffer, frames_count);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Failed to fit in `buffer_size`. Allocating memory:
|
||||
#ifdef BOOST_NO_CXX11_ALLOCATOR
|
||||
typedef typename Allocator::template rebind<native_frame_ptr_t>::other allocator_void_t;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Allocator>::template rebind_alloc<native_frame_ptr_t> allocator_void_t;
|
||||
#endif
|
||||
std::vector<native_frame_ptr_t, allocator_void_t> buf(buffer_size * 2, 0, impl_.get_allocator());
|
||||
do {
|
||||
const std::size_t frames_count = boost::stacktrace::detail::this_thread_frames::collect(&buf[0], buf.size(), frames_to_skip + 1);
|
||||
if (buf.size() > frames_count || frames_count >= max_depth) {
|
||||
const std::size_t size = (max_depth < frames_count ? max_depth : frames_count);
|
||||
fill(&buf[0], size);
|
||||
const std::size_t frames_count = boost::stacktrace::detail::this_thread_frames::collect(&buf[0], buf.size() < max_depth ? buf.size() : max_depth, frames_to_skip + 1);
|
||||
if (buf.size() > frames_count || frames_count == max_depth) {
|
||||
fill(&buf[0], frames_count);
|
||||
return;
|
||||
}
|
||||
|
||||
buf.resize(buf.size() * 2);
|
||||
} while (buf.size() < buf.max_size()); // close to `true`, but suppresses `C4127: conditional expression is constant`.
|
||||
} catch (...) {
|
||||
} BOOST_CATCH (...) {
|
||||
// ignore exception
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
@@ -321,6 +319,10 @@ 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 buffer_size_in_bytes Size of the memory. Usually the same value that was passed to the boost::stacktrace::safe_dump_to
|
||||
///
|
||||
/// @b Complexity: O(size) in worst case
|
||||
static basic_stacktrace from_dump(const void* begin, std::size_t buffer_size_in_bytes, const allocator_type& a = allocator_type()) {
|
||||
basic_stacktrace ret(0, 0, a);
|
||||
@@ -392,14 +394,20 @@ std::size_t hash_value(const basic_stacktrace<Allocator>& st) BOOST_NOEXCEPT {
|
||||
return boost::hash_range(st.as_vector().begin(), st.as_vector().end());
|
||||
}
|
||||
|
||||
/// Outputs stacktrace in a human readable format to output stream; unsafe to use in async handlers.
|
||||
template <class CharT, class TraitsT, class Allocator>
|
||||
std::basic_ostream<CharT, TraitsT>& operator<<(std::basic_ostream<CharT, TraitsT>& os, const basic_stacktrace<Allocator>& bt) {
|
||||
if (bt) {
|
||||
os << boost::stacktrace::detail::to_string(&bt.as_vector()[0], bt.size());
|
||||
/// Returns std::string with the stacktrace in a human readable format; unsafe to use in async handlers.
|
||||
template <class Allocator>
|
||||
std::string to_string(const basic_stacktrace<Allocator>& bt) {
|
||||
if (!bt) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return os;
|
||||
return boost::stacktrace::detail::to_string(&bt.as_vector()[0], bt.size());
|
||||
}
|
||||
|
||||
/// Outputs stacktrace in a human readable format to the output stream `os`; unsafe to use in async handlers.
|
||||
template <class CharT, class TraitsT, class Allocator>
|
||||
std::basic_ostream<CharT, TraitsT>& operator<<(std::basic_ostream<CharT, TraitsT>& os, const basic_stacktrace<Allocator>& bt) {
|
||||
return os << boost::stacktrace::to_string(bt);
|
||||
}
|
||||
|
||||
/// This is the typedef to use unless you'd like to provide a specific allocator to boost::stacktrace::basic_stacktrace.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017 Antony Polukhin
|
||||
Copyright (c) 2014-2019 Antony Polukhin
|
||||
antoshkka at gmail dot com
|
||||
|
||||
Distributed under the Boost Software License,
|
||||
@@ -29,7 +29,7 @@
|
||||
<a href="../../doc/html/stacktrace.html">../../doc/html/stacktrace.html</a>
|
||||
</p>
|
||||
<p>
|
||||
© 2014-2017 Antony Polukhin
|
||||
© 2014-2019 Antony Polukhin
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"Antony Polukhin <antoshkka -at- gmail.com>"
|
||||
],
|
||||
"description": "Gather, store, copy and print backtraces.",
|
||||
"std": [ "proposal" ],
|
||||
"category": [
|
||||
"System", "Correctness"
|
||||
]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
123
test/Jamfile.v2
123
test/Jamfile.v2
@@ -1,10 +1,12 @@
|
||||
# Copyright (C) 2016-2017, Antony Polukhin.
|
||||
# Copyright (C) 2016-2019, 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
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
lib dl : : <link>shared ;
|
||||
lib gcc_s ;
|
||||
lib rt ;
|
||||
@@ -24,30 +26,33 @@ project
|
||||
: requirements
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
<toolset>intel:<cxxflags>-wd2196
|
||||
<target-os>linux:<linkflags>-lpthread
|
||||
<warnings>all
|
||||
<test-info>always_show_run_output
|
||||
<visibility>hidden
|
||||
;
|
||||
|
||||
local RDYNAMIC = <target-os>freebsd:<linkflags>"-rdynamic" <target-os>solaris:<linkflags>"-Bdynamic" <target-os>aix:<linkflags>"-rdynamic"
|
||||
local FORCE_SYMBOL_EXPORT = <target-os>freebsd:<linkflags>"-rdynamic" <target-os>solaris:<linkflags>"-Bdynamic" <target-os>aix:<linkflags>"-rdynamic"
|
||||
<target-os>qnxnto,<toolset>qcc:<linkflags>"-Bdynamic" <target-os>qnxnto,<toolset>gcc:<linkflags>"-rdynamic"
|
||||
<target-os>android:<linkflags>"-rdynamic" <target-os>linux:<linkflags>"-rdynamic" <target-os>darwin,<toolset>gcc:<linkflags>"-dynamic"
|
||||
<target-os>darwin,<toolset>clang:<linkflags>"-rdynamic" <target-os>iphone:<linkflags>"-rdynamic" ;
|
||||
<target-os>darwin,<toolset>clang:<linkflags>"-rdynamic" <target-os>iphone:<linkflags>"-rdynamic"
|
||||
<define>BOOST_STACKTRACE_TEST_EXPORTS_TABLE_USAGE ;
|
||||
|
||||
local HIDE_SYMBS = <target-os>linux:<cxxflags>"-fvisibility=hidden" ;
|
||||
|
||||
local BT_DEPS = $(HIDE_SYMBS) <target-os>linux:<library>dl <library>backtrace [ check-target-builds ../build//libbacktrace : : <build>no ] ;
|
||||
local AD2L_DEPS = $(HIDE_SYMBS) <target-os>linux:<library>dl [ check-target-builds ../build//addr2line : : <build>no ] ;
|
||||
local WIND_DEPS = $(HIDE_SYMBS) <library>Dbgeng <library>ole32 [ check-target-builds ../build//WinDbg : : <build>no ] ;
|
||||
local WICA_DEPS = $(HIDE_SYMBS) <library>Dbgeng <library>ole32 [ check-target-builds ../build//WinDbgCached : : <build>no ] ;
|
||||
local NOOP_DEPS = $(HIDE_SYMBS) ;
|
||||
local BASIC_DEPS = $(RDYNAMIC) <target-os>linux:<library>dl [ check-target-builds ../build//WinDbg : <build>no ] ;
|
||||
local BT_DEPS = <target-os>linux:<library>dl <library>backtrace [ check-target-builds ../build//libbacktrace : : <build>no ] ;
|
||||
local AD2L_DEPS = <target-os>linux:<library>dl [ check-target-builds ../build//addr2line : : <build>no ]
|
||||
<define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL # Some old versions of addr2line may not produce readable names for a modern compilers
|
||||
;
|
||||
local WIND_DEPS = <library>Dbgeng <library>ole32 [ check-target-builds ../build//WinDbg : : <build>no ] ;
|
||||
local WICA_DEPS = <library>Dbgeng <library>ole32 [ check-target-builds ../build//WinDbgCached : : <build>no ] ;
|
||||
local NOOP_DEPS = ;
|
||||
local BASIC_DEPS = <target-os>linux:<library>dl [ check-target-builds ../build//WinDbg : <build>no ] ;
|
||||
|
||||
local LINKSHARED_BT = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_backtrace $(BT_DEPS) ;
|
||||
local LINKSHARED_AD2L = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_addr2line $(AD2L_DEPS) ;
|
||||
local LINKSHARED_WIND = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_windbg $(WIND_DEPS) ;
|
||||
local LINKSHARED_WIND_CACHED = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_windbg_cached $(WICA_DEPS) ;
|
||||
local LINKSHARED_NOOP = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_noop $(NOOP_DEPS) ;
|
||||
local LINKSHARED_BASIC = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_basic $(BASIC_DEPS) ;
|
||||
local LINKSHARED_BASIC = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_basic $(BASIC_DEPS) $(FORCE_SYMBOL_EXPORT) ;
|
||||
|
||||
# Libs with debug symbols
|
||||
lib test_impl_lib_backtrace : test_impl.cpp : <debug-symbols>on $(LINKSHARED_BT) ;
|
||||
@@ -75,12 +80,13 @@ 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_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 ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) : windbg_cached_ho ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on $(BASIC_DEPS) : basic_ho ]
|
||||
[ 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_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 ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) : windbg_cached_ho ]
|
||||
[ 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 ]
|
||||
|
||||
# Test with shared linked implementations with debug symbols
|
||||
[ run test.cpp : : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : backtrace_lib ]
|
||||
@@ -116,47 +122,73 @@ test-suite stacktrace_tests
|
||||
##### Tests with disabled debug symbols #####
|
||||
|
||||
# Header only tests without debug symbols
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>off <define>BOOST_STACKTRACE_USE_BACKTRACE <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(BT_DEPS) : backtrace_ho_no_dbg ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>off <define>BOOST_STACKTRACE_USE_BACKTRACE $(FORCE_SYMBOL_EXPORT) $(BT_DEPS) : backtrace_ho_no_dbg ]
|
||||
[ run test_noop.cpp test_impl.cpp : : : <debug-symbols>off <define>BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : noop_ho_no_dbg ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>off <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(WIND_DEPS) : windbg_ho_no_dbg ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>off <define>BOOST_STACKTRACE_USE_WINDBG_CACHED <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(WICA_DEPS) : windbg_cached_ho_no_dbg ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>off $(BASIC_DEPS) : basic_ho_no_dbg ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>off $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) : basic_ho_no_dbg ]
|
||||
[ run test.cpp test_impl.cpp : : : <debug-symbols>off <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(BASIC_DEPS) : basic_ho_no_dbg_empty ]
|
||||
[ run test.cpp test_impl.cpp
|
||||
: : : <debug-symbols>off <define>BOOST_STACKTRACE_USE_ADDR2LINE <define>BOOST_STACKTRACE_ADDR2LINE_LOCATION="/usr/bin/addr2line" $(AD2L_DEPS)
|
||||
: addr2line_ho_no_dbg ]
|
||||
|
||||
# Test with shared linked implementations without debug symbols
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_backtrace_no_dbg $(LINKSHARED_BT) <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL : backtrace_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_addr2line_no_dbg $(LINKSHARED_AD2L) : addr2line_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_windbg_no_dbg $(LINKSHARED_WIND) <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL : windbg_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_windbg_cached_no_dbg $(LINKSHARED_WIND_CACHED) <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL : windbg_cached_lib_no_dbg ]
|
||||
[ run test_noop.cpp : : : <debug-symbols>off <library>.//test_impl_lib_noop_no_dbg $(LINKSHARED_NOOP) : noop_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_basic_no_dbg $(LINKSHARED_BASIC) : basic_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_backtrace_no_dbg $(LINKSHARED_BT) $(FORCE_SYMBOL_EXPORT) : backtrace_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_addr2line_no_dbg $(LINKSHARED_AD2L) : addr2line_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_windbg_no_dbg $(LINKSHARED_WIND) <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL : windbg_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_windbg_cached_no_dbg $(LINKSHARED_WIND_CACHED) <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL : windbg_cached_lib_no_dbg ]
|
||||
[ run test_noop.cpp : : : <debug-symbols>off <library>.//test_impl_lib_noop_no_dbg $(LINKSHARED_NOOP) : noop_lib_no_dbg ]
|
||||
[ run test.cpp : : : <debug-symbols>off <library>.//test_impl_lib_basic_no_dbg $(LINKSHARED_BASIC) : basic_lib_no_dbg ]
|
||||
|
||||
# Thread safety without debug symbols
|
||||
[ run thread_safety_checking.cpp
|
||||
: : : <debug-symbols>off <library>/boost/thread//boost_thread <library>/boost/timer//boost_timer <library>.//test_impl_lib_backtrace_no_dbg $(LINKSHARED_BT)
|
||||
: : : <debug-symbols>off
|
||||
<library>/boost/thread//boost_thread
|
||||
<library>/boost/timer//boost_timer
|
||||
<library>.//test_impl_lib_backtrace_no_dbg
|
||||
$(LINKSHARED_BT)
|
||||
: backtrace_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_no_dbg $(LINKSHARED_WIND)
|
||||
: : : <debug-symbols>off
|
||||
<library>/boost/thread//boost_thread
|
||||
<library>/boost/timer//boost_timer
|
||||
<library>.//test_impl_lib_windbg_no_dbg
|
||||
$(LINKSHARED_WIND)
|
||||
: windbg_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_cached_no_dbg $(LINKSHARED_WIND_CACHED)
|
||||
: : : <debug-symbols>off
|
||||
<library>/boost/thread//boost_thread
|
||||
<library>/boost/timer//boost_timer
|
||||
<library>.//test_impl_lib_windbg_cached_no_dbg
|
||||
$(LINKSHARED_WIND_CACHED)
|
||||
: windbg_cached_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_basic_no_dbg $(LINKSHARED_BASIC)
|
||||
: : : <debug-symbols>off
|
||||
<library>/boost/thread//boost_thread
|
||||
<library>/boost/timer//boost_timer
|
||||
<library>.//test_impl_lib_basic_no_dbg
|
||||
$(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
|
||||
: : : <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
|
||||
: : : <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 ]
|
||||
;
|
||||
|
||||
# Assuring that examples compile and run. Adding sources from `examples` directory to the `type_index` test suite.
|
||||
@@ -169,6 +201,11 @@ for local p in [ glob ../example/*.cpp ]
|
||||
additional_dependency = <library>/boost/filesystem//boost_filesystem <library>/boost/system//boost_system <target-os>linux:<library>rt ;
|
||||
}
|
||||
|
||||
if $(target_name) = "throwing_st"
|
||||
{
|
||||
additional_dependency = [ requires rtti ] ;
|
||||
}
|
||||
|
||||
stacktrace_tests += [ run $(p) : : : <debug-symbols>on $(LINKSHARED_BT) $(additional_dependency) : backtrace_$(p2[1]:B) ] ;
|
||||
stacktrace_tests += [ run $(p) : : : <debug-symbols>on $(LINKSHARED_AD2L) $(additional_dependency) : addr2line_$(p[1]:B) ] ;
|
||||
stacktrace_tests += [ run $(p) : : : <debug-symbols>on $(LINKSHARED_WIND) $(additional_dependency) : windbg_$(p[1]:B) ] ;
|
||||
@@ -188,3 +225,21 @@ for local p in [ glob ../example/*.cpp ]
|
||||
|
||||
}
|
||||
|
||||
# Very long tests for detecting memory leaks and corruptions
|
||||
test-suite stacktrace_torture
|
||||
:
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : torture_backtrace_ho ]
|
||||
#[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_ADDR2LINE $(AD2L_DEPS) : torture_addr2line_ho ]
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on $(WIND_DEPS) : torture_windbg_ho ]
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_USE_WINDBG_CACHED $(WICA_DEPS) : torture_windbg_cached_ho ]
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on $(FORCE_SYMBOL_EXPORT) $(BASIC_DEPS) : torture_basic_ho ]
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <define>BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL $(BASIC_DEPS) : torture_basic_ho_empty ]
|
||||
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : torture_backtrace_lib ]
|
||||
#[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_addr2line $(LINKSHARED_AD2L) : torture_addr2line_lib ]
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_windbg $(LINKSHARED_WIND) : torture_windbg_lib ]
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED) : torture_windbg_cached_lib ]
|
||||
[ run torture.cpp test_impl.cpp : : : <debug-symbols>on <library>.//test_impl_lib_basic $(LINKSHARED_BASIC) : torture_basic_lib ]
|
||||
;
|
||||
explicit stacktrace_torture ;
|
||||
|
||||
|
||||
@@ -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-2017.
|
||||
# Copyright Antony Polukhin 2016-2019.
|
||||
|
||||
#
|
||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -10,54 +10,31 @@
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#include "test_impl.hpp"
|
||||
|
||||
using boost::stacktrace::stacktrace;
|
||||
using boost::stacktrace::frame;
|
||||
|
||||
#ifdef BOOST_STACKTRACE_DYN_LINK
|
||||
# define BOOST_ST_API BOOST_SYMBOL_IMPORT
|
||||
#else
|
||||
# define BOOST_ST_API
|
||||
#endif
|
||||
|
||||
|
||||
#if (defined(BOOST_GCC) && defined(BOOST_WINDOWS) && !defined(BOOST_STACKTRACE_USE_BACKTRACE) && !defined(BOOST_STACKTRACE_USE_ADDR2LINE)) \
|
||||
|| defined(BOOST_STACKTRACE_TEST_NO_DEBUG_AT_ALL)
|
||||
|
||||
# define BOOST_STACKTRACE_SYMNAME 0
|
||||
# define BOOST_STACKTRACE_TEST_SHOULD_OUTPUT_READABLE_NAMES 0
|
||||
#else
|
||||
# define BOOST_STACKTRACE_SYMNAME 1
|
||||
# define BOOST_STACKTRACE_TEST_SHOULD_OUTPUT_READABLE_NAMES 1
|
||||
#endif
|
||||
|
||||
typedef std::pair<stacktrace, stacktrace> (*foo1_t)(int i);
|
||||
BOOST_ST_API std::pair<stacktrace, stacktrace> foo2(int i, foo1_t foo1);
|
||||
BOOST_ST_API stacktrace return_from_nested_namespaces();
|
||||
BOOST_ST_API boost::stacktrace::stacktrace bar1();
|
||||
BOOST_ST_API boost::stacktrace::stacktrace bar2();
|
||||
|
||||
BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo1(int i) {
|
||||
if (i) {
|
||||
return foo2(i - 1, foo1);
|
||||
}
|
||||
|
||||
std::pair<stacktrace, stacktrace> ret;
|
||||
try {
|
||||
throw std::logic_error("test");
|
||||
} catch (const std::logic_error& /*e*/) {
|
||||
ret.second = stacktrace();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
void test_deeply_nested_namespaces() {
|
||||
std::stringstream ss;
|
||||
ss << return_from_nested_namespaces();
|
||||
std::cout << ss.str() << '\n';
|
||||
#if BOOST_STACKTRACE_SYMNAME
|
||||
#if BOOST_STACKTRACE_TEST_SHOULD_OUTPUT_READABLE_NAMES
|
||||
BOOST_TEST(ss.str().find("main") != std::string::npos);
|
||||
|
||||
BOOST_TEST(ss.str().find("get_backtrace_from_nested_namespaces") != std::string::npos
|
||||
@@ -70,16 +47,37 @@ void test_deeply_nested_namespaces() {
|
||||
BOOST_TEST(ns1 != return_from_nested_namespaces()); // Different addresses in test_deeply_nested_namespaces() function
|
||||
}
|
||||
|
||||
std::size_t count_unprintable_chars(const std::string& s) {
|
||||
std::size_t result = 0;
|
||||
for (std::size_t i = 0; i < s.size(); ++i) {
|
||||
result += (std::isprint(s[i]) ? 0 : 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void test_frames_string_data_validity() {
|
||||
stacktrace trace = return_from_nested_namespaces();
|
||||
for (std::size_t i = 0; i < trace.size(); ++i) {
|
||||
BOOST_TEST_EQ(count_unprintable_chars(trace[i].source_file()), 0);
|
||||
BOOST_TEST_EQ(count_unprintable_chars(trace[i].name()), 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(to_string(trace).find('\0') == std::string::npos);
|
||||
}
|
||||
|
||||
// Template parameter Depth is to produce different functions on each Depth. This simplifies debugging when one of the tests catches error
|
||||
template <std::size_t Depth>
|
||||
void test_nested() {
|
||||
std::pair<stacktrace, stacktrace> res = foo2(Depth, foo1);
|
||||
void test_nested(bool print = true) {
|
||||
std::pair<stacktrace, stacktrace> res = function_from_library(Depth, function_from_main_translation_unit);
|
||||
|
||||
std::stringstream ss1, ss2;
|
||||
|
||||
ss1 << res.first;
|
||||
ss2 << res.second;
|
||||
std::cout << "'" << ss1.str() << "'\n\n" << ss2.str() << std::endl;
|
||||
if (print) {
|
||||
std::cout << "'" << ss1.str() << "'\n\n" << ss2.str() << std::endl;
|
||||
}
|
||||
BOOST_TEST(!ss1.str().empty());
|
||||
BOOST_TEST(!ss2.str().empty());
|
||||
|
||||
@@ -92,18 +90,16 @@ void test_nested() {
|
||||
BOOST_TEST(ss1.str().find(" in ") != std::string::npos);
|
||||
BOOST_TEST(ss2.str().find(" in ") != std::string::npos);
|
||||
|
||||
#if BOOST_STACKTRACE_SYMNAME
|
||||
#if BOOST_STACKTRACE_TEST_SHOULD_OUTPUT_READABLE_NAMES
|
||||
BOOST_TEST(ss1.str().find("main") != std::string::npos);
|
||||
BOOST_TEST(ss2.str().find("main") != std::string::npos);
|
||||
|
||||
BOOST_TEST(ss1.str().find("foo2") != std::string::npos);
|
||||
BOOST_TEST(ss2.str().find("foo2") != std::string::npos);
|
||||
BOOST_TEST(ss1.str().find("function_from_library") != std::string::npos);
|
||||
BOOST_TEST(ss2.str().find("function_from_library") != std::string::npos);
|
||||
|
||||
BOOST_TEST(ss1.str().find("foo1") != std::string::npos);
|
||||
BOOST_TEST(ss2.str().find("foo1") != std::string::npos);
|
||||
BOOST_TEST(ss1.str().find("function_from_main_translation_unit") != std::string::npos);
|
||||
BOOST_TEST(ss2.str().find("function_from_main_translation_unit") != std::string::npos);
|
||||
#endif
|
||||
|
||||
//BOOST_TEST(false);
|
||||
}
|
||||
|
||||
template <class Bt>
|
||||
@@ -194,7 +190,7 @@ void test_iterators() {
|
||||
|
||||
void test_frame() {
|
||||
stacktrace nst = return_from_nested_namespaces();
|
||||
stacktrace st;
|
||||
stacktrace st = make_some_stacktrace1();
|
||||
|
||||
const std::size_t min_size = (nst.size() < st.size() ? nst.size() : st.size());
|
||||
BOOST_TEST(min_size > 2);
|
||||
@@ -231,9 +227,9 @@ void test_frame() {
|
||||
|
||||
boost::stacktrace::frame empty_frame;
|
||||
BOOST_TEST(!empty_frame);
|
||||
BOOST_TEST(empty_frame.source_file() == "");
|
||||
BOOST_TEST(empty_frame.name() == "");
|
||||
BOOST_TEST(empty_frame.source_line() == 0);
|
||||
BOOST_TEST_EQ(empty_frame.source_file(), "");
|
||||
BOOST_TEST_EQ(empty_frame.name(), "");
|
||||
BOOST_TEST_EQ(empty_frame.source_line(), 0);
|
||||
}
|
||||
|
||||
// Template parameter bool BySkip is to produce different functions on each BySkip. This simplifies debugging when one of the tests catches error
|
||||
@@ -263,6 +259,7 @@ void test_empty_basic_stacktrace() {
|
||||
|
||||
int main() {
|
||||
test_deeply_nested_namespaces();
|
||||
test_frames_string_data_validity();
|
||||
test_nested<15>();
|
||||
test_comparisons();
|
||||
test_iterators();
|
||||
@@ -270,14 +267,14 @@ int main() {
|
||||
test_empty_basic_stacktrace<true>();
|
||||
test_empty_basic_stacktrace<false>();
|
||||
|
||||
BOOST_TEST(&bar1 != &bar2);
|
||||
boost::stacktrace::stacktrace b1 = bar1();
|
||||
BOOST_TEST(&make_some_stacktrace1 != &make_some_stacktrace2);
|
||||
boost::stacktrace::stacktrace b1 = make_some_stacktrace1();
|
||||
BOOST_TEST(b1.size() == 4);
|
||||
boost::stacktrace::stacktrace b2 = bar2();
|
||||
boost::stacktrace::stacktrace b2 = make_some_stacktrace2();
|
||||
BOOST_TEST(b2.size() == 4);
|
||||
test_comparisons_base(bar1(), bar2());
|
||||
test_comparisons_base(make_some_stacktrace1(), make_some_stacktrace2());
|
||||
|
||||
test_nested<300>();
|
||||
test_nested<260>(false);
|
||||
BOOST_TEST(boost::stacktrace::stacktrace(0, 1).size() == 1);
|
||||
BOOST_TEST(boost::stacktrace::stacktrace(1, 1).size() == 1);
|
||||
|
||||
|
||||
@@ -1,32 +1,15 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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 <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
#if defined(BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP) || defined(BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP)
|
||||
#error "LexicalCast headers leaked into the boost/stacktrace/stacktrace.hpp"
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_USE_WINDOWS_H) && defined(_WINDOWS_H)
|
||||
#error "windows.h header leaked into the boost/stacktrace/stacktrace.hpp"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#define BOOST_STACKTRACE_TEST_IMPL_LIB 1
|
||||
#include "test_impl.hpp"
|
||||
|
||||
using namespace boost::stacktrace;
|
||||
|
||||
#ifdef BOOST_STACKTRACE_DYN_LINK
|
||||
# define BOOST_ST_API BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
# define BOOST_ST_API
|
||||
#endif
|
||||
|
||||
typedef std::pair<stacktrace, stacktrace> (*foo1_t)(int i);
|
||||
BOOST_ST_API BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo2(int i, foo1_t foo1) {
|
||||
BOOST_ST_API BOOST_NOINLINE std::pair<stacktrace, stacktrace> function_from_library(int i, foo1_t foo1) {
|
||||
if (i) {
|
||||
return foo1(--i);
|
||||
} else {
|
||||
@@ -59,31 +42,31 @@ BOOST_ST_API BOOST_NOINLINE stacktrace return_from_nested_namespaces() {
|
||||
return get_backtrace_from_nested_namespaces();
|
||||
}
|
||||
|
||||
BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace bar1_impl(int d = 0) {
|
||||
BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace make_some_stacktrace1_impl(int d = 0) {
|
||||
boost::stacktrace::stacktrace result(0, 4);
|
||||
if (result.size() < 4) {
|
||||
if (d > 4) throw std::runtime_error("Stack is not growing in test OR stacktrace fails to work in `bar1` function.");
|
||||
return bar1_impl(d + 1);
|
||||
return make_some_stacktrace1_impl(d + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace bar2_impl(int d = 0) {
|
||||
BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace make_some_stacktrace2_impl(int d = 0) {
|
||||
boost::stacktrace::stacktrace result(0, 4);
|
||||
if (result.size() < 4) {
|
||||
if (d > 4) throw std::runtime_error("Stack is not growing in test OR stacktrace fails to work in `bar2` function.");
|
||||
return bar2_impl(d + 1);
|
||||
return make_some_stacktrace2_impl(d + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace bar1() {
|
||||
boost::stacktrace::stacktrace result = bar1_impl();
|
||||
BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace make_some_stacktrace1() {
|
||||
boost::stacktrace::stacktrace result = make_some_stacktrace1_impl();
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace bar2() {
|
||||
boost::stacktrace::stacktrace result = bar2_impl();
|
||||
BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace make_some_stacktrace2() {
|
||||
boost::stacktrace::stacktrace result = make_some_stacktrace2_impl();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
58
test/test_impl.hpp
Normal file
58
test/test_impl.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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 <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
#if defined(BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP) || defined(BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP)
|
||||
#error "LexicalCast headers leaked into the boost/stacktrace/stacktrace.hpp"
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_USE_WINDOWS_H) && defined(_WINDOWS_H)
|
||||
#error "windows.h header leaked into the boost/stacktrace/stacktrace.hpp"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace boost::stacktrace;
|
||||
|
||||
#ifdef BOOST_STACKTRACE_DYN_LINK
|
||||
# ifdef BOOST_STACKTRACE_TEST_IMPL_LIB
|
||||
# define BOOST_ST_API BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define BOOST_ST_API BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# ifdef BOOST_STACKTRACE_TEST_EXPORTS_TABLE_USAGE
|
||||
# define BOOST_ST_API BOOST_SYMBOL_VISIBLE
|
||||
# else
|
||||
# define BOOST_ST_API
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef std::pair<boost::stacktrace::stacktrace, boost::stacktrace::stacktrace> st_pair;
|
||||
typedef st_pair (*foo1_t)(int i);
|
||||
BOOST_ST_API st_pair function_from_library(int i, foo1_t foo1);
|
||||
BOOST_ST_API boost::stacktrace::stacktrace return_from_nested_namespaces();
|
||||
BOOST_ST_API boost::stacktrace::stacktrace make_some_stacktrace1();
|
||||
BOOST_ST_API boost::stacktrace::stacktrace make_some_stacktrace2();
|
||||
|
||||
#ifdef BOOST_STACKTRACE_TEST_EXPORTS_TABLE_USAGE
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
#endif
|
||||
inline st_pair function_from_main_translation_unit(int i) {
|
||||
if (i) {
|
||||
return function_from_library(i - 1, function_from_main_translation_unit);
|
||||
}
|
||||
|
||||
std::pair<stacktrace, stacktrace> ret;
|
||||
try {
|
||||
throw std::logic_error("test");
|
||||
} catch (const std::logic_error& /*e*/) {
|
||||
ret.second = stacktrace();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,21 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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 "test_impl.hpp"
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
using boost::stacktrace::stacktrace;
|
||||
using boost::stacktrace::frame;
|
||||
|
||||
#ifdef BOOST_STACKTRACE_DYN_LINK
|
||||
# define BOOST_ST_API BOOST_SYMBOL_IMPORT
|
||||
#else
|
||||
# define BOOST_ST_API
|
||||
#endif
|
||||
|
||||
typedef std::pair<stacktrace, stacktrace> (*foo1_t)(int i);
|
||||
BOOST_ST_API std::pair<stacktrace, stacktrace> foo2(int i, foo1_t foo1);
|
||||
BOOST_ST_API stacktrace return_from_nested_namespaces();
|
||||
|
||||
|
||||
BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo1(int i) {
|
||||
if (i) {
|
||||
return foo2(i - 1, foo1);
|
||||
}
|
||||
|
||||
std::pair<stacktrace, stacktrace> ret;
|
||||
try {
|
||||
throw std::logic_error("test");
|
||||
} catch (const std::logic_error& /*e*/) {
|
||||
ret.second = stacktrace();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
void test_deeply_nested_namespaces() {
|
||||
BOOST_TEST(return_from_nested_namespaces().size() == 0);
|
||||
BOOST_TEST(return_from_nested_namespaces().empty());
|
||||
@@ -46,7 +23,7 @@ void test_deeply_nested_namespaces() {
|
||||
}
|
||||
|
||||
void test_nested() {
|
||||
std::pair<stacktrace, stacktrace> res = foo2(15, foo1);
|
||||
std::pair<stacktrace, stacktrace> res = function_from_library(15, function_from_main_translation_unit);
|
||||
|
||||
BOOST_TEST(!res.first);
|
||||
BOOST_TEST(res.first.empty());
|
||||
|
||||
71
test/test_num_conv.cpp
Normal file
71
test/test_num_conv.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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 <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
#include <boost/stacktrace/detail/try_dec_convert.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
void test_to_hex_array() {
|
||||
const void* ptr = 0;
|
||||
BOOST_TEST(std::string(boost::stacktrace::detail::to_hex_array(ptr).data()).find("0x0") != std::string::npos);
|
||||
|
||||
ptr = reinterpret_cast<const void*>(0x10);
|
||||
BOOST_TEST(std::string(boost::stacktrace::detail::to_hex_array(ptr).data()).find("10") != std::string::npos);
|
||||
|
||||
ptr = reinterpret_cast<void*>(0x19);
|
||||
BOOST_TEST(std::string(boost::stacktrace::detail::to_hex_array(ptr).data()).find("19") != std::string::npos);
|
||||
|
||||
ptr = reinterpret_cast<void*>(0x999999);
|
||||
BOOST_TEST(std::string(boost::stacktrace::detail::to_hex_array(ptr).data()).find("999999") != std::string::npos);
|
||||
}
|
||||
|
||||
void test_to_dec_array() {
|
||||
BOOST_TEST_EQ(std::string(boost::stacktrace::detail::to_dec_array(0).data()), std::string("0"));
|
||||
BOOST_TEST_EQ(std::string(boost::stacktrace::detail::to_dec_array(10).data()), std::string("10"));
|
||||
BOOST_TEST_EQ(std::string(boost::stacktrace::detail::to_dec_array(19).data()), std::string("19"));
|
||||
BOOST_TEST_EQ(std::string(boost::stacktrace::detail::to_dec_array(999999).data()), std::string("999999"));
|
||||
}
|
||||
|
||||
void test_try_dec_convert() {
|
||||
std::size_t res = 0;
|
||||
|
||||
BOOST_TEST(boost::stacktrace::detail::try_dec_convert("0", res));
|
||||
BOOST_TEST(res == 0);
|
||||
|
||||
BOOST_TEST(boost::stacktrace::detail::try_dec_convert("+0", res));
|
||||
BOOST_TEST(res == 0);
|
||||
|
||||
BOOST_TEST(boost::stacktrace::detail::try_dec_convert("10", res));
|
||||
BOOST_TEST(res == 10);
|
||||
|
||||
BOOST_TEST(boost::stacktrace::detail::try_dec_convert("19", res));
|
||||
BOOST_TEST(res == 19);
|
||||
|
||||
BOOST_TEST(boost::stacktrace::detail::try_dec_convert("+19", res));
|
||||
BOOST_TEST(res == 19);
|
||||
|
||||
BOOST_TEST(boost::stacktrace::detail::try_dec_convert("9999", res));
|
||||
BOOST_TEST(res == 9999);
|
||||
|
||||
BOOST_TEST(!boost::stacktrace::detail::try_dec_convert("q", res));
|
||||
BOOST_TEST(!boost::stacktrace::detail::try_dec_convert("0z", res));
|
||||
BOOST_TEST(!boost::stacktrace::detail::try_dec_convert("0u", res));
|
||||
BOOST_TEST(!boost::stacktrace::detail::try_dec_convert("+0u", res));
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
test_to_hex_array();
|
||||
test_to_dec_array();
|
||||
test_try_dec_convert();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright Antony Polukhin, 2016-2017.
|
||||
// Copyright Antony Polukhin, 2016-2020.
|
||||
//
|
||||
// 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 "test_impl.hpp"
|
||||
#include <boost/stacktrace/stacktrace_fwd.hpp>
|
||||
|
||||
#include <sstream>
|
||||
@@ -15,31 +16,8 @@
|
||||
|
||||
#include <boost/timer/timer.hpp>
|
||||
|
||||
#ifdef BOOST_STACKTRACE_DYN_LINK
|
||||
# define BOOST_ST_API BOOST_SYMBOL_IMPORT
|
||||
#else
|
||||
# define BOOST_ST_API
|
||||
#endif
|
||||
|
||||
using boost::stacktrace::stacktrace;
|
||||
|
||||
typedef std::pair<stacktrace, stacktrace> (*foo1_t)(int i);
|
||||
BOOST_ST_API std::pair<stacktrace, stacktrace> foo2(int i, foo1_t foo1);
|
||||
BOOST_ST_API stacktrace return_from_nested_namespaces();
|
||||
|
||||
BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo1(int i) {
|
||||
if (i) {
|
||||
return foo2(i - 1, foo1);
|
||||
}
|
||||
|
||||
std::pair<stacktrace, stacktrace> ret;
|
||||
try {
|
||||
throw std::logic_error("test");
|
||||
} catch (const std::logic_error& /*e*/) {
|
||||
ret.second = stacktrace();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
void main_test_loop() {
|
||||
std::size_t loops = 100;
|
||||
@@ -49,7 +27,7 @@ void main_test_loop() {
|
||||
std::stringstream ss_ethalon;
|
||||
|
||||
while (--loops) {
|
||||
std::pair<stacktrace, stacktrace> res = foo2(Depth, foo1);
|
||||
std::pair<stacktrace, stacktrace> res = function_from_library(Depth, function_from_main_translation_unit);
|
||||
if (ethalon) {
|
||||
BOOST_TEST(res == *ethalon);
|
||||
|
||||
|
||||
26
test/torture.cpp
Normal file
26
test/torture.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright Antony Polukhin, 2018.
|
||||
//
|
||||
// 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)
|
||||
|
||||
|
||||
// This file tests for memory leaks. Some of the backtrace implementations
|
||||
// consume memory for internal needs and incorrect usage of those implementations
|
||||
// could lead to segfaults. Sanitizers do not detect such misuse, but this
|
||||
// test and `top` does.
|
||||
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "test_impl.hpp"
|
||||
|
||||
int main() {
|
||||
int result = 0;
|
||||
for (unsigned i = 0; i < 10000000; ++i) {
|
||||
result += make_some_stacktrace1()[0].source_line();
|
||||
}
|
||||
|
||||
std::cerr << "OK\nLines count " << result;
|
||||
}
|
||||
Reference in New Issue
Block a user