mirror of
https://github.com/boostorg/stacktrace.git
synced 2026-01-28 19:52:08 +00:00
Compare commits
14 Commits
boost-1.87
...
boost-1.88
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6499f26d4 | ||
|
|
d408cf4468 | ||
|
|
9d314b2b47 | ||
|
|
54934a386a | ||
|
|
ea282324b8 | ||
|
|
9e7a98a61a | ||
|
|
b170b28479 | ||
|
|
5ec45912da | ||
|
|
679bd845aa | ||
|
|
0bcc382ab5 | ||
|
|
a64b8b7985 | ||
|
|
92b1c794b3 | ||
|
|
8c4e50324c | ||
|
|
22982db3f6 |
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -170,7 +170,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, macos-14 ]
|
||||
os: [ ubuntu-20.04, ubuntu-22.04, macos-13, macos-14 ]
|
||||
shared: [ OFF, ON ]
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
@@ -214,7 +214,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, macos-14 ]
|
||||
os: [ ubuntu-20.04, ubuntu-22.04, macos-13, macos-14 ]
|
||||
shared: [ OFF, ON ]
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
@@ -274,7 +274,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, macos-14 ]
|
||||
os: [ ubuntu-20.04, ubuntu-22.04, macos-13, macos-14 ]
|
||||
shared: [ OFF, ON ]
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -115,6 +115,10 @@ if(BOOST_STACKTRACE_ENABLE_WINDBG)
|
||||
|
||||
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_windbg)
|
||||
|
||||
elseif(BOOST_STACKTRACE_ENABLE_WINDBG_CACHED)
|
||||
|
||||
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_windbg)
|
||||
|
||||
elseif(BOOST_STACKTRACE_ENABLE_BACKTRACE)
|
||||
|
||||
target_link_libraries(boost_stacktrace INTERFACE Boost::stacktrace_backtrace)
|
||||
|
||||
15
boost-stacktrace-features.jam
Normal file
15
boost-stacktrace-features.jam
Normal file
@@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2016-2024, 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 feature ;
|
||||
|
||||
feature.feature boost.stacktrace.noop : on off : optional propagated ;
|
||||
feature.feature boost.stacktrace.backtrace : on off : optional propagated ;
|
||||
feature.feature boost.stacktrace.addr2line : on off : optional propagated ;
|
||||
feature.feature boost.stacktrace.basic : on off : optional propagated ;
|
||||
feature.feature boost.stacktrace.windbg : on off : optional propagated ;
|
||||
feature.feature boost.stacktrace.windbg_cached : on off : optional propagated ;
|
||||
feature.feature boost.stacktrace.from_exception : on off : optional propagated ;
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
import boost-stacktrace-features ;
|
||||
|
||||
constant boost_dependencies :
|
||||
<library>/boost/config//boost_config
|
||||
<library>/boost/container_hash//boost_container_hash
|
||||
|
||||
113
build/Jamfile.v2
113
build/Jamfile.v2
@@ -7,8 +7,9 @@
|
||||
|
||||
require-b2 5.0.1 ;
|
||||
import-search /boost/config/checks ;
|
||||
import boost-stacktrace-features ;
|
||||
import config : requires ;
|
||||
import feature ;
|
||||
import configure ;
|
||||
import property ;
|
||||
|
||||
constant boost_dependencies_private :
|
||||
@@ -29,8 +30,6 @@ lib gcc_s ;
|
||||
lib Dbgeng ;
|
||||
lib ole32 ;
|
||||
|
||||
feature.feature boost.stacktrace.from_exception : on off : optional propagated ;
|
||||
|
||||
local LIBBACKTRACE_PATH = [ modules.peek : LIBBACKTRACE_PATH ] ;
|
||||
lib backtrace
|
||||
:
|
||||
@@ -65,18 +64,44 @@ explicit WinDbg ;
|
||||
mp-run-simple has_windbg_cached.cpp : : : <library>Dbgeng <library>ole32 : WinDbgCached ;
|
||||
explicit WinDbgCached ;
|
||||
|
||||
rule build-stacktrace-noop ( props * )
|
||||
{
|
||||
local enabled = [ property.select <boost.stacktrace.noop> : $(props) ] ;
|
||||
switch $(enabled:G=)
|
||||
{
|
||||
case "on" : return ;
|
||||
case "off" : return <build>no ;
|
||||
}
|
||||
}
|
||||
|
||||
lib boost_stacktrace_noop
|
||||
: # sources
|
||||
../src/noop.cpp
|
||||
: # requirements
|
||||
<warnings>all
|
||||
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
<conditional>@build-stacktrace-noop
|
||||
: # default build
|
||||
: # usage-requirements
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
<define>BOOST_STACKTRACE_NO_LIB=1
|
||||
;
|
||||
|
||||
rule build-stacktrace-backtrace ( props * )
|
||||
{
|
||||
local enabled = [ property.select <boost.stacktrace.backtrace> : $(props) ] ;
|
||||
switch $(enabled:G=)
|
||||
{
|
||||
case "on" : return ;
|
||||
case "off" : return <build>no ;
|
||||
}
|
||||
|
||||
if ! [ configure.builds libbacktrace : $(props) : "boost.stacktrace.backtrace" ]
|
||||
{
|
||||
return <build>no ;
|
||||
}
|
||||
}
|
||||
|
||||
lib boost_stacktrace_backtrace
|
||||
: # sources
|
||||
../src/backtrace.cpp
|
||||
@@ -85,13 +110,35 @@ lib boost_stacktrace_backtrace
|
||||
<target-os>linux:<library>dl
|
||||
<library>backtrace
|
||||
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
[ check-target-builds libbacktrace : : <build>no ]
|
||||
<conditional>@build-stacktrace-backtrace
|
||||
: # default build
|
||||
: # usage-requirements
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
<define>BOOST_STACKTRACE_NO_LIB=1
|
||||
;
|
||||
|
||||
rule build-stacktrace-addr2line ( props * )
|
||||
{
|
||||
local enabled = [ property.select <boost.stacktrace.addr2line> : $(props) ] ;
|
||||
switch $(enabled:G=)
|
||||
{
|
||||
case "on" : return ;
|
||||
case "off" : return <build>no ;
|
||||
}
|
||||
|
||||
# Disable by default on Windows when not using Cygwin
|
||||
if <target-os>windows in $(props) && ! ( <target-os>cygwin in $(props) )
|
||||
{
|
||||
configure.log-library-search-result "boost.stacktrace.addr2line" : "no" ;
|
||||
return <build>no ;
|
||||
}
|
||||
|
||||
if ! [ configure.builds addr2line : $(props) : "boost.stacktrace.addr2line" ]
|
||||
{
|
||||
return <build>no ;
|
||||
}
|
||||
}
|
||||
|
||||
lib boost_stacktrace_addr2line
|
||||
: # sources
|
||||
../src/addr2line.cpp
|
||||
@@ -99,13 +146,28 @@ lib boost_stacktrace_addr2line
|
||||
<warnings>all
|
||||
<target-os>linux:<library>dl
|
||||
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
[ check-target-builds addr2line : : <build>no ]
|
||||
<conditional>@build-stacktrace-addr2line
|
||||
: # default build
|
||||
: # usage-requirements
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
<define>BOOST_STACKTRACE_NO_LIB=1
|
||||
;
|
||||
|
||||
rule build-stacktrace-basic ( props * )
|
||||
{
|
||||
local enabled = [ property.select <boost.stacktrace.basic> : $(props) ] ;
|
||||
switch $(enabled:G=)
|
||||
{
|
||||
case "on" : return ;
|
||||
case "off" : return <build>no ;
|
||||
}
|
||||
|
||||
if [ configure.builds WinDbg : $(props) : "boost.stacktrace.basic" ]
|
||||
{
|
||||
return <build>no ;
|
||||
}
|
||||
}
|
||||
|
||||
lib boost_stacktrace_basic
|
||||
: # sources
|
||||
../src/basic.cpp
|
||||
@@ -113,13 +175,28 @@ lib boost_stacktrace_basic
|
||||
<warnings>all
|
||||
<target-os>linux:<library>dl
|
||||
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
[ check-target-builds WinDbg : <build>no ]
|
||||
<conditional>@build-stacktrace-basic
|
||||
: # default build
|
||||
: # usage-requirements
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
<define>BOOST_STACKTRACE_NO_LIB=1
|
||||
;
|
||||
|
||||
rule build-stacktrace-windbg ( props * )
|
||||
{
|
||||
local enabled = [ property.select <boost.stacktrace.windbg> : $(props) ] ;
|
||||
switch $(enabled:G=)
|
||||
{
|
||||
case "on" : return ;
|
||||
case "off" : return <build>no ;
|
||||
}
|
||||
|
||||
if ! [ configure.builds WinDbg : $(props) : "boost.stacktrace.windbg" ]
|
||||
{
|
||||
return <build>no ;
|
||||
}
|
||||
}
|
||||
|
||||
lib boost_stacktrace_windbg
|
||||
: # sources
|
||||
../src/windbg.cpp
|
||||
@@ -127,13 +204,28 @@ lib boost_stacktrace_windbg
|
||||
<warnings>all
|
||||
<library>Dbgeng <library>ole32
|
||||
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
[ check-target-builds WinDbg : : <build>no ]
|
||||
<conditional>@build-stacktrace-windbg
|
||||
: # default build
|
||||
: # usage-requirements
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
<define>BOOST_STACKTRACE_NO_LIB=1
|
||||
;
|
||||
|
||||
rule build-stacktrace-windbg-cached ( props * )
|
||||
{
|
||||
local enabled = [ property.select <boost.stacktrace.windbg_cached> : $(props) ] ;
|
||||
switch $(enabled:G=)
|
||||
{
|
||||
case "on" : return ;
|
||||
case "off" : return <build>no ;
|
||||
}
|
||||
|
||||
if ! [ configure.builds WinDbgCached : $(props) : "boost.stacktrace.windbg_cached" ]
|
||||
{
|
||||
return <build>no ;
|
||||
}
|
||||
}
|
||||
|
||||
lib boost_stacktrace_windbg_cached
|
||||
: # sources
|
||||
../src/windbg_cached.cpp
|
||||
@@ -141,7 +233,7 @@ lib boost_stacktrace_windbg_cached
|
||||
<warnings>all
|
||||
<library>Dbgeng <library>ole32
|
||||
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
[ check-target-builds WinDbgCached : : <build>no ]
|
||||
<conditional>@build-stacktrace-windbg-cached
|
||||
: # default build
|
||||
: # usage-requirements
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
@@ -160,8 +252,10 @@ rule build-stacktrace-from-exception ( props * )
|
||||
local arch = [ property.select <architecture> : $(props) ] ;
|
||||
if $(arch) && ( $(arch:G=) != x86 )
|
||||
{
|
||||
configure.log-library-search-result "boost.stacktrace.from_exception" : "no" ;
|
||||
return <build>no ;
|
||||
}
|
||||
configure.log-library-search-result "boost.stacktrace.from_exception" : "yes" ;
|
||||
}
|
||||
|
||||
lib boost_stacktrace_from_exception
|
||||
@@ -173,9 +267,6 @@ lib boost_stacktrace_from_exception
|
||||
|
||||
# Enable build when explicitly requested, or by default, when on x86
|
||||
<conditional>@build-stacktrace-from-exception
|
||||
|
||||
# Require usable libbacktrace on other platforms
|
||||
# [ check-target-builds libbacktrace : : <build>no ]
|
||||
: # default build
|
||||
: # usage-requirements
|
||||
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
# Copyright Antony Polukhin, 2016-2025.
|
||||
# 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-2024 Antony Polukhin]
|
||||
[copyright 2016-2025 Antony Polukhin]
|
||||
[category Language Features Emulation]
|
||||
[license
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -68,7 +68,7 @@ Pretty often assertions provide not enough information to locate the problem. Fo
|
||||
Aborted (core dumped)
|
||||
```
|
||||
|
||||
That's not enough to locate the problem without debugger. There may be thousand code lines in real world examples and hundred places where that assertion could happen. Let's try to improve the assertions, and make them more informative:
|
||||
That's not enough to locate the problem without debugger. There may be thousand code lines in real world examples and hundred places where that assertion can happen. Let's try to improve the assertions, and make them more informative:
|
||||
|
||||
[getting_started_assert_handlers]
|
||||
|
||||
@@ -236,7 +236,7 @@ Code from above will output:
|
||||
|
||||
[section Enabling and disabling stacktraces]
|
||||
|
||||
At some point arises a requirement to easily enable/disable stacktraces for a whole project. That could be easily achieved.
|
||||
At some point arises a requirement to easily enable/disable stacktraces for a whole project. That can be easily achieved.
|
||||
|
||||
Just define *BOOST_STACKTRACE_LINK* for a whole project. Now you can enable/disable stacktraces by just linking with different libraries:
|
||||
|
||||
@@ -251,7 +251,7 @@ See [link stacktrace.configuration_and_build section "Configuration and Build"]
|
||||
[section Saving stacktraces by specified format]
|
||||
|
||||
[classref boost::stacktrace::stacktrace] provides access to individual [classref boost::stacktrace::frame frames] of the stacktrace,
|
||||
so that you could save stacktrace information in your own format. Consider the example, that saves only function addresses of each frame:
|
||||
so that you can save stacktrace information in your own format. Consider the example, that saves only function addresses of each frame:
|
||||
|
||||
[getting_started_trace_addresses]
|
||||
|
||||
@@ -304,7 +304,63 @@ Terminate called:
|
||||
|
||||
[section Configuration and Build]
|
||||
|
||||
By default Boost.Stacktrace is a header-only library, but you may change that and use the following macros to improve build times or to be able to tune library without recompiling your project:
|
||||
[section Usage from CMake]
|
||||
|
||||
CMake library `Boost::stacktrace` provides the best available implementation:
|
||||
|
||||
```
|
||||
target_link_libraries(${PROJECT}
|
||||
PUBLIC
|
||||
Boost::stacktrace
|
||||
)
|
||||
```
|
||||
|
||||
There are also CMake libraries for fine grained selection of implementation:
|
||||
|
||||
* `Boost::stacktrace_windbg`
|
||||
* `Boost::stacktrace_windbg_cached`
|
||||
* `Boost::stacktrace_backtrace`
|
||||
* `Boost::stacktrace_addr2line`
|
||||
* `Boost::stacktrace_basic`
|
||||
* `Boost::stacktrace_noop`
|
||||
|
||||
Note that `Boost::stacktrace_from_exception` is not used by default, so add it explicitly if its functionality is required:
|
||||
|
||||
```
|
||||
target_link_libraries(${PROJECT} # your project
|
||||
PUBLIC
|
||||
Boost::stacktrace
|
||||
Boost::stacktrace_from_exception
|
||||
)
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section CMake build notes]
|
||||
|
||||
When building the Boost.Stacktrace libraries using `CMake` the `BOOST_STACKTRACE_ENABLE_*` options control the build. For example:
|
||||
|
||||
* `cmake -DBOOST_STACKTRACE_ENABLE_NOOP=0 -DBOOST_STACKTRACE_ENABLE_BACKTRACE=1 -DBOOST_STACKTRACE_ENABLE_FROM_EXCEPTION=1` - do not build the `noop` implementation and force the builds of `backtrace` and `from_exception`.
|
||||
* `cmake -DBOOST_STACKTRACE_ENABLE_NOOP=1 -DBOOST_STACKTRACE_ENABLE_WINDBG=1 -DBOOST_STACKTRACE_ENABLE_WINDBG_CACHED=0` - build the `noop` and `windbg` implementations and disable the build of `windbg_cached`.
|
||||
|
||||
If options are not provided they are auto-detected and the result of detection is printed and implicitly used during build.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section B2 build notes]
|
||||
|
||||
When building the Boost.Stacktrace libraries using `b2` the `boost.stacktrace.*` options can be used to control the build. For example:
|
||||
|
||||
* `b2 boost.stacktrace.noop=off boost.stacktrace.backtrace=on boost.stacktrace.from_exception=on` - do not build the `noop` implementation and force the builds of `backtrace` and `from_exception`.
|
||||
* `b2 boost.stacktrace.noop=on boost.stacktrace.windbg=on boost.stacktrace.windbg_cached=off` - build the `noop` and `windbg` implementations and disable the build of `windbg_cached`.
|
||||
|
||||
If options are not provided they are auto-detected and the result of detection is printed and implicitly used during build.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Header only options]
|
||||
|
||||
If CMake is not used then the Boost.Stacktrace is a header-only library by default. To change that (to improve build times or to be able to tune library without recompiling your project) use the following macros:
|
||||
[table:linkmacro Link macros
|
||||
[[Macro name] [Effect]]
|
||||
[[*BOOST_STACKTRACE_LINK*] [Disable header-only build and require linking with shared or static library that contains the tracing implementation. If *BOOST_ALL_DYN_LINK* is defined, then link with shared library.]]
|
||||
@@ -312,13 +368,13 @@ By default Boost.Stacktrace is a header-only library, but you may change that an
|
||||
]
|
||||
|
||||
|
||||
In header only mode library could be tuned by macro. If one of the link macro from above is defined, you have to manually link with one of the libraries:
|
||||
In header only mode library can be tuned by macro. If one of the link macro from above is defined, you have to manually link with one of the libraries:
|
||||
[table:libconfig Config
|
||||
[[Macro name or default] [Library] [Effect] [Platforms] [Uses debug information [footnote This will provide more readable backtraces with *source code locations* if the binary is built with debug information.]] [Uses dynamic exports information [footnote This will provide readable function names in backtrace for functions that are exported by the binary. Compiling with `-rdynamic` flag, without `-fvisibility=hidden` or marking functions as exported produce a better stacktraces.]] ]
|
||||
[[['default for MSVC, Intel on Windows, MinGW-w64] / *BOOST_STACKTRACE_USE_WINDBG*] [*boost_stacktrace_windbg*] [ Uses `dbgeng.h` to show debug info, stores the implementation internals in a static varaible protected with mutex. May require linking with *ole32* and *dbgeng*. ] [MSVC, MinGW-w64, Intel on Windows] [yes] [no]]
|
||||
[[['default for MSVC, Intel on Windows, MinGW-w64] / *BOOST_STACKTRACE_USE_WINDBG*] [*boost_stacktrace_windbg*] [ Uses `dbgeng.h` to show debug info, stores the implementation internals in a static variable protected with mutex. 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 `dbgeng.h` to show debug info and caches implementation internals in TLS for better performance. Useful only for cases when traces are gathered very often. May require linking with *ole32* and *dbgeng*. ] [MSVC, Intel on Windows] [yes] [no]]
|
||||
[[*BOOST_STACKTRACE_USE_BACKTRACE*] [*boost_stacktrace_backtrace*] [Requires linking with *libdl* on POSIX and *libbacktrace* libraries[footnote Some *libbacktrace* packages SEGFAULT if there's a concurrent work with the same `backtrace_state` instance. To avoid that issue the Boost.Stacktrace library uses `thread_local` states, unfortunately this may consume a lot of memory if you often create and destroy execution threads in your application. Define *BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC* to force single instance, but make sure that [@https://github.com/boostorg/stacktrace/blob/develop/test/thread_safety_checking.cpp thread_safety_checking.cpp] works well in your setup. ]. *libbacktrace* is probably already installed in your system[footnote If you are using Clang with libstdc++ you could get into troubles of including `<backtrace.h>`, because on some platforms Clang does not search for headers in the GCC's include paths and any attempt to add GCC's include path leads to linker errors. To explicitly specify a path to the `<backtrace.h>` header you could define the *BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE* to a full path to the header. For example on Ubuntu Xenial use the command line option *-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=</usr/lib/gcc/x86_64-linux-gnu/5/include/backtrace.h>* while building with Clang. ], or built into your compiler.
|
||||
[[*BOOST_STACKTRACE_USE_BACKTRACE*] [*boost_stacktrace_backtrace*] [Requires linking with *libdl* on POSIX and *libbacktrace* libraries[footnote Some *libbacktrace* packages SEGFAULT if there's a concurrent work with the same `backtrace_state` instance. To avoid that issue the Boost.Stacktrace library uses `thread_local` states, unfortunately this may consume a lot of memory if you often create and destroy execution threads in your application. Define *BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC* to force single instance, but make sure that [@https://github.com/boostorg/stacktrace/blob/develop/test/thread_safety_checking.cpp thread_safety_checking.cpp] works well in your setup. ]. *libbacktrace* is probably already installed in your system[footnote If you are using Clang with libstdc++ you can 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 can 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]]
|
||||
@@ -331,6 +387,8 @@ In header only mode library could be tuned by macro. If one of the link macro fr
|
||||
* 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
|
||||
|
||||
[endsect]
|
||||
|
||||
[section MinGW and MinGW-w64 specific notes]
|
||||
|
||||
MinGW-w64 and MinGW (without -w64) users have to install libbacktrace for getting better stacktraces. Follow the instruction:
|
||||
@@ -370,11 +428,11 @@ In theory, walking the stack without decoding and demangling should be async sig
|
||||
In practice, it is not:
|
||||
|
||||
* Looks like a page fault while dumping the trace on a containerized/virtualized
|
||||
Windows system has a chance to deadlock. Page fault could happen easily
|
||||
Windows system has a chance to deadlock. Page fault can happen easily
|
||||
as we have to write the dump either to memory or to a file.
|
||||
* On POSIX systems a deadlock could happen if a signal is received when throwing
|
||||
* On POSIX systems a deadlock can happen if a signal is received when throwing
|
||||
an exception [@https://github.com/boostorg/stacktrace/issues/131 #131].
|
||||
Theoretically this could be worked around by bypassing the mutex locking
|
||||
Theoretically this can be worked around by bypassing the mutex locking
|
||||
in C++-runtime at exception throw
|
||||
([@https://github.com/userver-framework/userver/blob/4246909c99506d3ab34bd130a5154b4acc8e87de/core/src/engine/task/exception_hacks.cpp#L241-L244 sample implementation]
|
||||
in the 🐙 userver framework), or by using a very modern runtime
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
72
include/boost/stacktrace/detail/addr_base_msvc.hpp
Normal file
72
include/boost/stacktrace/detail/addr_base_msvc.hpp
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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_ADDR_BASE_MSVC_HPP
|
||||
#define BOOST_STACKTRACE_DETAIL_ADDR_BASE_MSVC_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
|
||||
#ifdef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
#else
|
||||
// Prevent inclusion of extra Windows SDK headers which can cause conflict
|
||||
// with other code using Windows SDK
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
namespace boost { namespace stacktrace { namespace detail {
|
||||
inline std::uintptr_t get_own_proc_addr_base(const void* addr) {
|
||||
// Try to avoid allocating memory for the modules array if possible.
|
||||
// The stack buffer should be large enough for most processes.
|
||||
HMODULE modules_stack[1024];
|
||||
std::unique_ptr<HMODULE[]> modules_allocated;
|
||||
HMODULE* modules = modules_stack;
|
||||
|
||||
DWORD needed_bytes = 0;
|
||||
std::uintptr_t addr_base = 0;
|
||||
|
||||
HANDLE process_handle = GetCurrentProcess();
|
||||
auto enum_process_is_ok = EnumProcessModules(process_handle, modules, sizeof(modules), &needed_bytes);
|
||||
|
||||
// Check if the error is because the buffer is too small.
|
||||
if (!enum_process_is_ok && GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
modules_allocated.reset(new HMODULE[needed_bytes / sizeof(HMODULE)]);
|
||||
modules = modules_allocated.get();
|
||||
enum_process_is_ok = EnumProcessModules(process_handle, modules, needed_bytes, &needed_bytes);
|
||||
}
|
||||
|
||||
if (enum_process_is_ok) {
|
||||
for (std::size_t i = 0; i < (needed_bytes / sizeof(HMODULE)); ++i) {
|
||||
MODULEINFO module_info;
|
||||
|
||||
// Get the module name
|
||||
if (GetModuleInformation(process_handle, modules[i], &module_info, sizeof(module_info))
|
||||
&& module_info.lpBaseOfDll <= addr && addr < LPBYTE(module_info.lpBaseOfDll) + module_info.SizeOfImage) {
|
||||
// Module contains the address
|
||||
addr_base = reinterpret_cast<std::uintptr_t>(module_info.lpBaseOfDll);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(process_handle);
|
||||
|
||||
return addr_base;
|
||||
}
|
||||
|
||||
}}} // namespace boost::stacktrace::detail
|
||||
|
||||
#endif // BOOST_STACKTRACE_DETAIL_ADDR_BASE_MSVC_HPP
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -19,6 +19,10 @@
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
|
||||
#ifndef BOOST_STACKTRACE_DISABLE_OFFSET_ADDR_BASE
|
||||
#include <boost/stacktrace/detail/addr_base_msvc.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#else
|
||||
@@ -247,6 +251,57 @@ public:
|
||||
const std::size_t delimiter = result.find_first_of('!');
|
||||
if (module_name) {
|
||||
*module_name = result.substr(0, delimiter);
|
||||
if (!module_name->empty()) {
|
||||
ULONG64 base = 0;
|
||||
res = (S_OK == idebug_->GetModuleByOffset(
|
||||
offset,
|
||||
0,
|
||||
nullptr,
|
||||
&base
|
||||
));
|
||||
|
||||
if (res) {
|
||||
name[0] = '\0';
|
||||
size = 0;
|
||||
res = (S_OK == idebug_->GetModuleNames(
|
||||
DEBUG_ANY_ID,
|
||||
base,
|
||||
name,
|
||||
sizeof(name),
|
||||
&size,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr
|
||||
));
|
||||
}
|
||||
|
||||
if (!res && size != 0)
|
||||
{
|
||||
std::string module_path(size, char());
|
||||
res = (S_OK == idebug_->GetModuleNames(
|
||||
DEBUG_ANY_ID,
|
||||
base,
|
||||
&module_path[0],
|
||||
static_cast<ULONG>(module_path.size()),
|
||||
&size,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr
|
||||
));
|
||||
if (res && size > 1) {
|
||||
module_name->assign(module_path, size - 1);
|
||||
}
|
||||
}
|
||||
else if (res && size > 1) {
|
||||
module_name->assign(name, size - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delimiter == std::string::npos) {
|
||||
@@ -340,7 +395,13 @@ public:
|
||||
if (!name.empty()) {
|
||||
res += name;
|
||||
} else {
|
||||
#ifdef BOOST_STACKTRACE_DISABLE_OFFSET_ADDR_BASE
|
||||
res += to_hex_array(addr).data();
|
||||
#else
|
||||
// Get own base address
|
||||
const uintptr_t base_addr = get_own_proc_addr_base(addr);
|
||||
res += to_hex_array(reinterpret_cast<uintptr_t>(addr) - base_addr).data();
|
||||
#endif
|
||||
}
|
||||
|
||||
std::pair<std::string, std::size_t> source_line = this->get_source_file_line_impl(addr);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <boost/stacktrace/detail/to_hex_array.hpp>
|
||||
#include <boost/stacktrace/detail/location_from_symbol.hpp>
|
||||
#include <boost/stacktrace/detail/to_dec_array.hpp>
|
||||
#include <boost/stacktrace/detail/addr_base.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
@@ -40,7 +41,12 @@ public:
|
||||
if (!Base::res.empty()) {
|
||||
Base::res = boost::core::demangle(Base::res.c_str());
|
||||
} else {
|
||||
#ifdef BOOST_STACKTRACE_DISABLE_OFFSET_ADDR_BASE
|
||||
Base::res = to_hex_array(addr).data();
|
||||
#else
|
||||
const auto addr_base = boost::stacktrace::detail::get_own_proc_addr_base(addr);
|
||||
Base::res = to_hex_array(reinterpret_cast<uintptr_t>(addr) - addr_base).data();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Base::prepare_source_location(addr)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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 Antony Polukhin, 2015-2024.
|
||||
// Copyright Antony Polukhin, 2015-2025.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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, 2023-2024.
|
||||
// Copyright Antony Polukhin, 2023-2025.
|
||||
//
|
||||
// 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, 2023-2024.
|
||||
// Copyright Antony Polukhin, 2023-2025.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright Antony Polukhin, 2023-2024.
|
||||
// Copyright Antony Polukhin, 2023-2025.
|
||||
//
|
||||
// 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)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
|
||||
#include <boost/stacktrace/safe_dump_to.hpp>
|
||||
#include <windows.h>
|
||||
|
||||
@@ -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-2024.
|
||||
# Copyright Antony Polukhin, 2016-2025.
|
||||
|
||||
#
|
||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
||||
@@ -21,7 +21,7 @@ init:
|
||||
# From this point and below code is same for all the Boost libs
|
||||
###############################################################################################################
|
||||
|
||||
version: 1.84.{build}-{branch}
|
||||
version: 1.88.{build}-{branch}
|
||||
|
||||
# branches to build
|
||||
branches:
|
||||
@@ -63,14 +63,10 @@ before_build:
|
||||
- git clone -b %BOOST_BRANCH% --depth 10 https://github.com/boostorg/boost.git %BOOST%
|
||||
- cd %BOOST%
|
||||
- git submodule update --init --depth 10 tools/build tools/boostdep
|
||||
libs/filesystem libs/atomic libs/system libs/interprocess libs/array
|
||||
libs/iterator libs/detail libs/exception libs/smart_ptr libs/mpl
|
||||
libs/align libs/container libs/tuple libs/intrusive libs/scope
|
||||
libs/variant2 libs/preprocessor libs/io
|
||||
|
||||
- rm -rf %BOOST%/libs/%BOOST_LIBS_FOLDER%
|
||||
- mv -f %APPVEYOR_BUILD_FOLDER% %BOOST%/libs/%BOOST_LIBS_FOLDER%
|
||||
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" %BOOST_LIBS_FOLDER%
|
||||
- python tools/boostdep/depinst/depinst.py --include example --git_args "--depth 10 --jobs 2" %BOOST_LIBS_FOLDER%
|
||||
|
||||
build_script:
|
||||
- cmd /c bootstrap
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2019 Peter Dimov
|
||||
// Copyright 2022-2024 Antony Polukhin
|
||||
// Copyright 2022-2025 Antony Polukhin
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2019 Peter Dimov
|
||||
// Copyright 2022-2024 Antony Polukhin
|
||||
// Copyright 2022-2025 Antony Polukhin
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2016-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <boost/stacktrace.hpp>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
@@ -263,7 +264,51 @@ void test_stacktrace_limits()
|
||||
BOOST_TEST_EQ(boost::stacktrace::stacktrace(1, 1).size(), 1);
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::size_t get_file_size(const char* file_name) {
|
||||
std::ifstream file(file_name, std::ios::binary | std::ios::ate);
|
||||
const auto file_size = file.tellg();
|
||||
BOOST_TEST(file_size > 0);
|
||||
return static_cast<std::size_t>(file_size);
|
||||
}
|
||||
|
||||
uintptr_t get_address_from_frame(const std::string& frame) {
|
||||
std::size_t address = 0;
|
||||
std::string hex_address;
|
||||
std::size_t pos = frame.find("0x");
|
||||
|
||||
if (pos != std::string::npos) {
|
||||
// Extract the hex address substring
|
||||
hex_address = frame.substr(pos + 2); // Skip "0x"
|
||||
|
||||
// Convert hex string to std::size_t
|
||||
std::stringstream ss;
|
||||
ss << std::hex << hex_address;
|
||||
ss >> address;
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
void test_relative_virtual_address(const char* file_path)
|
||||
{
|
||||
const auto frame = to_string(boost::stacktrace::stacktrace(0, 1).as_vector().front());
|
||||
|
||||
// Skip the test if the frame does not contain an address
|
||||
if (frame.find("0x") == std::string::npos) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto file_size = get_file_size(file_path);
|
||||
BOOST_TEST(file_size > 0);
|
||||
|
||||
const auto address = get_address_from_frame(frame);
|
||||
BOOST_TEST(address > 0);
|
||||
|
||||
// Verify that the address is within the binary
|
||||
BOOST_TEST(address <= file_size);
|
||||
}
|
||||
|
||||
int main(const int, const char* argv[]) {
|
||||
test_deeply_nested_namespaces();
|
||||
test_frames_string_data_validity();
|
||||
test_nested<15>();
|
||||
@@ -283,6 +328,7 @@ int main() {
|
||||
test_nested<260>(false);
|
||||
|
||||
test_stacktrace_limits();
|
||||
test_relative_virtual_address(argv[0]);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2023-2024.
|
||||
// Copyright Antony Polukhin, 2023-2025.
|
||||
//
|
||||
// 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, 2023-2024.
|
||||
// Copyright Antony Polukhin, 2023-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// 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, 2022-2024.
|
||||
// Copyright Antony Polukhin, 2022-2025.
|
||||
//
|
||||
// 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-2024.
|
||||
// Copyright Antony Polukhin, 2016-2025.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
Reference in New Issue
Block a user