Commit Graph

72 Commits

Author SHA1 Message Date
Antony Polukhin
9e7a98a61a Update copyright years 2025-01-08 19:54:11 +03:00
Maciej Czarnecki
b170b28479 Use Relative Virtual Addresses to allow their decoding without knowing the base address (#200)
Instead of printing absolute addresses use relative ones so they can be used later to decode the stack trace.

## Motivation

It’s quite common to release apps without debug symbols while keeping them internally. Currently the lib prints absolute addresses which require the base address to decode them using symbols. With this change, the base address won’t be needed as values are relative to the beginning of the loaded module/binary.

The implementation for unix is **straightforward** as the existing code is used. For Windows, I’ve implemented similar logic using Windows API.

## Manual testing of Windows implementation

Here are 2 runs of `trivial_windbg_lib.exe` with .pdb and without .pdb file:

```jsx
>./trivial_windbg_lib.exe
 0# boost::stacktrace::basic_stacktrace<std::allocator<boost::stacktrace::frame> >::init at C:\Users\czarneckim\repositories\boost\boost\stacktrace\stacktrace.hpp:110
 1# main at C:\Users\czarneckim\repositories\boost\libs\stacktrace\test\test_trivial.cpp:14
 2# __scrt_common_main_seh at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
 3# BaseThreadInitThunk in C:\WINDOWS\System32\KERNEL32.DLL
 4# RtlUserThreadStart in C:\WINDOWS\SYSTEM32\ntdll.dll

> mv ./trivial_windbg_lib.pdb{,_} 
> ./trivial_windbg_lib.exe
 0# 0x0000000000001DE3 in C:\Users\czarneckim\repositories\boost\bin.v2\libs\stacktrace\test\trivial_windbg_lib.test\msvc-14.3\release\x86_64\asynch-exceptions-on\cxxstd-latest-iso\debug-symbols-on\threading-multi\trivial_windbg_lib.exe
 1# 0x0000000000001FEE in C:\Users\czarneckim\repositories\boost\bin.v2\libs\stacktrace\test\trivial_windbg_lib.test\msvc-14.3\release\x86_64\asynch-exceptions-on\cxxstd-latest-iso\debug-symbols-on\threading-multi\trivial_windbg_lib.exe
 2# 0x000000000000246C in C:\Users\czarneckim\repositories\boost\bin.v2\libs\stacktrace\test\trivial_windbg_lib.test\msvc-14.3\release\x86_64\asynch-exceptions-on\cxxstd-latest-iso\debug-symbols-on\threading-multi\trivial_windbg_lib.exe
 3# BaseThreadInitThunk in C:\WINDOWS\System32\KERNEL32.DLL
 4# RtlUserThreadStart in C:\WINDOWS\SYSTEM32\ntdll.dll

> mv ./trivial_windbg_lib.pdb{_,}
> winaddr2line.exe -f -e trivial_windbg_lib.pdb 0x0000000000001DE3
boost::stacktrace::basic_stacktrace<std::allocator<boost::stacktrace::frame> >::init
C:\Users\czarneckim\repositories\boost\boost\stacktrace\stacktrace.hpp:110
```

I’ve also decoded the returned address using x64dbg running `trivial_windbg_lib.exe+0x0000000000001DE3`:

![image](https://github.com/user-attachments/assets/a36d3306-488d-4610-9f04-7888b98c2b75)

## Control

As it was suggested in #180, the new logic is enabled by default, but can be disabled with `BOOST_STACKTRACE_DISABLE_OFFSET_ADDR_BASE` (With non header-only mode, it requires rebuilding the lib)
2025-01-07 23:59:16 +03:00
Peter Dimov
4352901d19 Move tests to their own function to ensure two stack frames 2024-06-21 21:42:05 +03:00
Antony Polukhin
0ec802df84 Update copyright years 2024-01-07 13:03:02 +03:00
Antony Polukhin
4cf47389c1 Update copyright years 2023-01-19 10:21:22 +03:00
Antony Polukhin
75b7986f97 update copyright years 2022-01-30 14:47:24 +03:00
Antony Polukhin
a00587f4d7 update copyright years 2021-01-03 19:24:15 +03:00
Antony Polukhin
ade7d54dc7 update copyright year 2020-01-18 14:11:02 +03:00
Antony Polukhin
2d810e294f Try to reproduce the error from #78 in tests 2019-06-28 22:38:49 +03:00
Antony Polukhin
324a303fb0 Better diagnostics for test 2019-06-27 13:17:08 +03:00
Antony Polukhin
d9d6512743 Update copyright years 2019-01-12 22:15:16 +03:00
Antony Polukhin
42bf318144 Make the traces comparison test more reliable 2018-10-05 10:58:36 +03:00
Antony Polukhin
9f232606cb make tests less verbose 2018-09-19 23:03:47 +03:00
Antony Polukhin
99da94f5bd Rework the tests, deal with visibility issues, make sure that libbacktrace implementation now uses export tables 2018-09-16 23:23:33 +03:00
Antony Polukhin
3f047cbfc4 Fix damn web ui artifacts 2018-09-13 20:25:59 +03:00
Antony Polukhin
e14dd6560a Fixes for tests run with hidden visibility
Related to the changes in https://github.com/boostorg/boost/pull/190
2018-09-13 19:58:55 +03:00
Antony Polukhin
819f2b1c86 bump copyright years 2018-08-07 22:41:22 +03:00
Antony Polukhin
55791ad90c Do not compare iterators from different containers 2017-04-21 00:26:31 +03:00
Antony Polukhin
5c0176904a Attempt to locate an issue on MSVC (2) 2017-04-21 00:11:38 +03:00
Antony Polukhin
75296819ea Attempt to locate an issue on MSVC 2017-04-20 22:44:31 +03:00
Antony Polukhin
269acd6929 Attempt to fox MSVC tests and fix coverage reports 2017-04-20 22:13:43 +03:00
Antony Polukhin
7342d0afd0 Fix test for GCC -O1, make the test faster 2017-04-16 11:21:51 +03:00
Antony Polukhin
3a49914d80 Moar fixes for MSVC tests (2) 2017-04-15 01:15:01 +03:00
Antony Polukhin
29da39c6a5 Moar fixes for MSVC tests 2017-04-15 00:22:06 +03:00
Antony Polukhin
de9b588d1d Many new tests, including naive thread safety test 2017-04-14 22:38:48 +03:00
Antony Polukhin
cc3c37a930 Fixed typos 2017-03-18 13:26:22 +03:00
Antony Polukhin
27ec669657 Make MSVC tests less strict 2017-03-18 13:10:07 +03:00
Antony Polukhin
4191419560 Fixing MinGW (3) 2017-02-25 23:24:48 +03:00
Antony Polukhin
7b6a8e84f7 MinGW fixes (2). Do not include unused headers 2017-02-25 23:09:36 +03:00
Antony Polukhin
116dd872b8 Allow users to easily skip frames (API change), add more tests and update docs 2017-02-07 22:58:22 +03:00
Antony Polukhin
c221f0c2dd Multiple minor fixes, improved docs, changed the example to use Boost.Exception 2017-01-13 22:36:25 +03:00
Antony Polukhin
bd616a7249 Make a basic usecase the default one, add tests and create a target library for that 2017-01-13 22:31:03 +03:00
Antony Polukhin
b7bf4b5932 Use libbacktrace, added more tests 2017-01-08 00:00:17 +03:00
Antony Polukhin
a2431640b9 Move around code in test to make Coveralls happy and produce more reliable coverage results 2017-01-03 16:09:02 +03:00
Antony Polukhin
34306df187 Added more tests with long stacktraces 2017-01-03 14:42:31 +03:00
Antony Polukhin
3f543731fa Added tests with long stacktraces 2017-01-03 14:36:01 +03:00
Antony Polukhin
d6c1350952 Improve backtrace formatting and output more information into the backtrace when source file info is unawailable 2017-01-03 12:58:28 +03:00
Antony Polukhin
898380d622 Relax one of the tests 2017-01-02 23:10:52 +03:00
Antony Polukhin
0b7fae6e48 Relax one of the tests: looks like ::backtrace() call sometimes outputs itself into the stacktrace 2016-12-26 22:47:11 +03:00
Antony Polukhin
16ef077fa4 Fix unsigned overflow in basic_stacktrace constructor, improve some tests, make sure that skipping 2 frames does not show internals to the user 2016-12-26 22:18:27 +03:00
Antony Polukhin
2893578446 detail::backend class does not own data any more 2016-12-26 22:15:53 +03:00
Antony Polukhin
99e4b53742 Started reimplementing stacktrace with Allocator 2016-12-26 22:12:29 +03:00
Antony Polukhin
7fd30ad905 Improve tests coverage 2016-12-10 02:44:09 +03:00
Antony Polukhin
c6bdf49f08 Better testing of examples, better tests coverage 2016-12-10 02:39:39 +03:00
Antony Polukhin
d8ff16f7a9 More tests 2016-12-10 01:39:04 +03:00
Antony Polukhin
dff9ba4074 Fix the test compilation (3) 2016-12-08 10:55:31 +03:00
Antony Polukhin
4f37ad05cd Fix the test compilation 2016-12-08 10:44:06 +03:00
Antony Polukhin
903a1dc081 Allow to setup max trace length, added more tests, added meta folder and updated the Jamfali for building docs 2016-12-08 10:02:28 +03:00
Antony Polukhin
4ce841ef65 Code deduplicated and simplified, added empty() functions and some explicit bool operators, speed-up and improved the output of the ostream operators, improved tests coverage 2016-12-01 09:55:17 +03:00
Antony Polukhin
fd513391ca Async signal safe backend implmented and notes about async-safety were added to the docs. 2016-11-30 10:47:58 +03:00