Commit Graph

414 Commits

Author SHA1 Message Date
Jeremy Rifkin
08306c12a5
Implement symbol table lookup for mach-o and fix mingw build 2025-01-27 23:12:30 -06:00
Jeremy Rifkin
68c9d33e94
Use tried_to_load_header 2025-01-26 23:22:03 -06:00
Jeremy Rifkin
8edb419342
Implement elf symbol table parsing and fall back to the elf symbol table during symbol resolution 2025-01-26 23:07:33 -06:00
Jeremy Rifkin
dc118dcb6d
Move monostate 2025-01-26 23:03:42 -06:00
Jeremy Rifkin
7a1eb4d5bf
Add a Result<T> converting constructor 2025-01-26 20:29:13 -06:00
Jeremy Rifkin
6a9d2c5bbd
Fixes for C++11 / older gcc 2025-01-26 19:31:20 -06:00
Jeremy Rifkin
c9826616b5
Sendit support optional<T&> and Result<T&, E> 2025-01-26 19:18:47 -06:00
Jeremy Rifkin
293f4d1593
Export should_absorb_trace_exceptions to fix tests 2025-01-26 18:15:21 -06:00
Jeremy Rifkin
06732add17
Try to fix tests on CI 2025-01-26 17:34:02 -06:00
Jeremy Rifkin
78086d0267
Some more unit tests for test cases 2025-01-26 17:29:38 -06:00
Jeremy Rifkin
906784284f
Add unit tests for optional and result helper types 2025-01-26 16:02:34 -06:00
Jeremy Rifkin
b705afba69
Templated lambdas aren't a thing in C++11 :( 2025-01-26 14:52:31 -06:00
Jeremy Rifkin
76a21d266a
Refactor out optional and result 2025-01-26 13:30:54 -06:00
firesgc
1bcfcff021
Incompatible with JNI on Windows: use unique handle for SymInitialize #204 (#206)
WinDbg: Duplicate the process handle before using it in SymInitialize,
because other libraries may have already called SymInitialize for the
process
(https://learn.microsoft.com/en-us/windows/win32/debug/initializing-the-symbol-handler)


Fixes https://github.com/jeremy-rifkin/cpptrace/issues/204

---------

Co-authored-by: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com>
2025-01-25 22:25:54 -06:00
Jeremy Rifkin
485d9a6f21
A little elf refactoring, separate out header loading 2025-01-24 20:16:46 -06:00
Jeremy Rifkin
d063784abc
Refactor elf_get_module_image_base, setup an elf class in preparation for more elf parsing 2025-01-23 00:12:31 -06:00
Jeremy Rifkin
f35ef65ed6
Merge branch 'dev' 2025-01-04 22:57:40 -06:00
Jeremy Rifkin
0c40839009
Specify __cdecl for the terminate handler on MSVC, fixes #197 2024-12-30 23:07:15 -06:00
Dominic Koepke
b127cfb176
Add missing typeinfo include (#202)
Hello,
as you know, I'm working on an integration of ``cpptrace`` into my own
mocking framework. I've an exhaustive build-workflow with various
compiler-configurations. One of these configs fails compiling due to
this error:
```src/platform/exception_type.hpp:19:39: error: member access into incomplete type 'const std::type_info'```

This happens to be the case, when ``clang-16`` with c++23 and `-stdlib=libc++` is used.
see: https://github.com/DNKpp/mimicpp/actions/runs/12549146490/job/34989686008 and
https://github.com/DNKpp/mimicpp/actions/runs/12549146490/job/34989688648

This fixes the issue.
2024-12-30 19:12:39 -06:00
Jeremy Rifkin
61d06d56d6
Oops 2024-12-03 23:56:10 -06:00
Jeremy Rifkin
4227fc4abe
Better microfmt implementation 2024-12-03 23:53:28 -06:00
Jeremy Rifkin
e10dbf431e
Add a color overload for stacktrace_frame::to_string, fixes #190 2024-11-14 23:54:52 -06:00
Jeremy Rifkin
90da0563f9
Recurse into DW_TAG_lexical_block DIEs while searching for inlining information 2024-11-10 16:09:55 -06:00
Jeremy Rifkin
f152788abd
Merge branch 'main' into dev 2024-10-29 22:23:28 -05:00
Pavol Gono
9269a72c54
Fixed compiler warnings and errors under MSYS2+MINGW64 platform. (#186)
Fixed compiler warnings and errors under MSYS2+MINGW64 platform.
2024-10-27 10:30:36 -05:00
Reimu NotMoe
557a4a6fab
Add missing #include <algorithm> in microfmt.hpp (#183)
This fixes building latest cpptrace in macOS
(https://github.com/jeremy-rifkin/microfmt/issues/1)
2024-10-20 23:52:29 -05:00
Jeremy Rifkin
a1fa0a1b81
Use forward declaration header in object.hpp 2024-10-06 16:50:39 -05:00
Jeremy Rifkin
757c0f87fe
Quick correction to get_cout 2024-10-06 14:06:52 -05:00
Jeremy Rifkin
4c59e73a01
Split up cpptrace.hpp 2024-10-05 18:01:12 -05:00
Patrick Quist
ae86a79f16
getpagesize() was removed from OSX (and posix) (#177) 2024-10-02 20:18:16 -05:00
Vittorio Romeo
0ddbbf43cb
Improve compilation times on Windows (#172)
Thank you for the very useful library!

Few improvements:
- Better header hygiene
- Isolate `windows.h` to `.cpp` whenever possible
- Use `WIN32_LEAN_AND_MEAN`
- Remove unused headers

Tested on Windows with 
```
cmake .. -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 
  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-ftime-trace -Wall -Wextra -Wpedantic 
  -Wno-ignored-attributes" -DCMAKE_COLOR_DIAGNOSTICS=1 -DCPPTRACE_BUILD_TESTING=1 
  -DCPPTRACE_BUILD_BENCHMARKING=0
```

There's a lot more that can be improved if you are interested.

---------

Co-authored-by: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com>
2024-10-02 10:55:13 -05:00
Jeremy Rifkin
142e0b9ea4
Per 0blu's suggestion, use the SymGetLineFromAddr macro instead of SymGetLineFromAddr64 2024-09-13 00:06:05 -05:00
Jeremy Rifkin
f9ab949a9e
Bump hard_max_frames to 400 2024-09-12 23:12:11 -05:00
Jeremy Rifkin
4e9f0da95f
Nest microfmt in the cpptrace namespace due to conditionally-enabled C++17 behavior causing ODR issues, related to https://github.com/jeremy-rifkin/libassert/issues/103 2024-09-12 21:06:12 -05:00
Jeremy Rifkin
4f94f20d41
Fix computation of object address for safe object frames. I forgot to do this as part of a528aa8e0b, also related to #104 2024-09-07 12:02:52 -05:00
_BLU
0d89be4fbe
VS2015 fixes (#165)
Fixes the compilation on VS14 / 2015.
2024-09-04 22:32:00 -05:00
Jeremy Rifkin
7fdbbfdf67
Fix compilation on ios (#167)
This aims to address #163
2024-09-04 17:22:32 -05:00
Pavol Gono
26093d5791
MSYS2+MINGW64 platform with libbacktrace (#166)
I've updated cmake conditions, to allow libbacktrace usage under
mingw64. And fixed one compilation issue.
Tested with package
https://packages.msys2.org/package/mingw-w64-x86_64-libbacktrace
with this setup:
```
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE=On
```
2024-09-03 19:58:39 -05:00
Jeremy Rifkin
3b0eb54797
Implement a system for preventing redundant tracing during search, and other various improvements for the from_current system (#159) 2024-08-20 23:10:17 -05:00
Jeremy Rifkin
b364d37f78
Implement better dwarf rangelist base address logic (#157)
Related to https://github.com/davea42/libdwarf-code/issues/255, allows
re-enabling the clang+sanitizer+rel+dsym tests.
2024-08-18 16:51:40 -05:00
Jeremy Rifkin
64e0210449
Better handle resolution of safe object frames with empty object paths 2024-08-18 13:38:06 -05:00
Jeremy Rifkin
0e2c3a130d
Fix windows build 2024-08-18 12:11:20 -05:00
Jeremy Rifkin
973309cb22
Some more platform refactoring/cleanup, also add a note to readme 2024-08-18 12:07:34 -05:00
Jeremy Rifkin
164cc75681
A little refactoring and reorganization. Remove relative includes. 2024-08-18 11:58:49 -05:00
Jeremy Rifkin
7621f2b277
A couple notes/comments/documentation tweaks 2024-08-18 11:20:59 -05:00
Jeremy Rifkin
26e009c688
Add cpptrace::from_current (#155) 2024-08-18 11:11:47 -05:00
Jeremy
cc2b3fce40
Add another try/catch to prevent any potential TCO 2024-07-13 19:07:58 -05:00
Jeremy
dcf89743f6
Block TCO on wrapper functions 2024-07-13 19:06:33 -05:00
Jeremy
c35ad6887a
Fix issue with incorrect reported object addresses on macos when using debug maps 2024-07-13 19:06:13 -05:00
Jeremy
e1fb3527a4
Fix an issue with split dwarf on clang 2024-07-11 19:10:16 -05:00
Jeremy
611660de5b
Fix use after free during cleanup of split dwarf information, fixes #141 2024-07-02 21:56:35 -06:00
Jeremy
1f19c31e02
Fix bug with dladdr1 not being used, silly typo 2024-06-19 15:15:51 -05:00
Jeremy Rifkin
2fb0a6fd2e
Fix trace generation for cpptrace exception objects on armv7hf (#138)
noexcept on get_raw_trace_and_absorb seems to somehow interfere with
unwinding on armv7hf, possibly due to unwind tables not being generated
for the function. Fixes #134.
2024-06-13 11:17:44 -05:00
Jeremy
bb83fa922c
Merge branch 'dev' 2024-06-11 22:30:27 -05:00
Jeremy
8d7a85c447
Update flatten_inlines to properly move inline frames instead of copying them and also clarify a comment 2024-06-04 23:21:14 -05:00
Infko
72b0e467d7
fix compile error in gcc 4.8.5. (#133) 2024-06-04 23:16:34 -05:00
Jeremy
b8a6e8446a
Quick microfmt fix for an old msvc bug 2024-06-02 12:47:53 -05:00
Jeremy
44ddc1b72f
Merge branch 'main' into dev 2024-06-02 11:35:01 -05:00
Jeremy
59ef49f1a3
Update microfmt 2024-06-02 11:31:43 -05:00
Jeremy
70634cb6f4
Undo temporary change printing object addresses in stack traces 2024-05-28 21:44:13 -05:00
Jeremy
9d1c592f0c
Remove CPPTRACE_CONDA_LIBDWARF_WEIRDNESS bodge and better support libdwarf via pkgconfig, resolves #131 2024-05-28 21:32:54 -05:00
Jeremy Rifkin
b2bff57d81
Debug Fission (#132)
Implement support for debug fission, closes #129
2024-05-28 20:39:34 -05:00
Jeremy
5556aedddb
Refactor cu lookup out of pc resolution 2024-05-25 16:20:41 -05:00
Jeremy
8bff5dc9fe
Quick fix 2024-05-25 14:32:34 -05:00
Jeremy
810b74ecaa
Refactor symbols_with_libdwarf indo separate files 2024-05-25 14:29:55 -05:00
Jeremy
5171e87a51
Refactor logic in the libdwarf resolver's resolve_frames, pull out trace flattening 2024-05-25 13:38:06 -05:00
Jeremy
a9f72c6f67
Refactor logic in the libdwarf resolver's resolve_frames, pull out resolver management 2024-05-25 13:02:25 -05:00
Jeremy
dcd9a31ce4
Refactor collate_frames 2024-05-25 12:38:34 -05:00
Jeremy
dad3bd1843
Some comments regarding dlfcn logistics and comment cleanup 2024-05-25 00:40:08 -05:00
Jeremy
7916f10278
Attempt to fallback to dladdr if dladdr1 is not available 2024-05-24 23:04:20 -05:00
Jeremy
f8d28a6469
Fix incorrect handling of lazy_trace_holder's union, I can't believe I wrote such egregious code 2024-05-23 22:33:56 -05:00
Jeremy
6307700710
Fix ASSERT macro under -Wpedantic 2024-05-23 22:33:33 -05:00
Jeremy Rifkin
b3836e9318
Support -Wpedantic if someone sets the flag globally while using FetchContent (#127)
Closes #107
2024-05-23 21:18:11 -05:00
Jeremy
7c9b24ca72
Fix dwarf_ranges handling of lowpc == pc, it's not correct to jump the gun and not check the high-pc. I think I erroneously added this in c94b03ae6e. Discovered as part of #123. 2024-05-19 17:00:44 -05:00
Jeremy
4884c4e99b
Fix frame pointer calculation for symbol frames under libunwind, #123 2024-05-19 16:36:07 -05:00
Jeremy
b2fe396d70
Fix address formatting, somehow it was left-aligned 2024-05-19 16:28:41 -05:00
Jeremy
323ab5814e
Merge branch 'main' into dev 2024-05-12 22:00:45 -05:00
Ben Dunkin
a70cf7935a
Fix missing cxxabi.h include on Windows when using libc++ (#122)
Make operator precedence explicit so the
`CPPTRACE_HAS_CXX_EXCEPTION_TYPE` define is a dominant switch to use
cxxabi.h, rather than one that only applies when `__GLIBCXX__` is
defined.

Fixes https://github.com/jeremy-rifkin/cpptrace/issues/121
2024-05-12 21:56:38 -05:00
Jeremy
74ed6afc0a
Add cpptrace::system_error 2024-05-06 23:01:11 -05:00
Jeremy
da0aa4d5c0
Split a bunch of internal headers into .cpp/.hpp 2024-05-05 17:44:27 -05:00
Jeremy
d7c19a5544
Updates for conda 2024-05-03 20:07:09 -05:00
Jeremy
abbc77dcea
Clean up logic a bit 2024-05-02 11:17:41 -05:00
Jeremy
d3c7e7351c
Remove guard for resolve_l_name 2024-05-02 11:09:37 -05:00
Jeremy
ce19421bb5
Update for macos 2024-05-02 11:05:22 -05:00
Jeremy
b125248b32
Update dladdr path to not use dli_fname as it's unreliable in the case of a non-standard argv[0] 2024-05-02 10:47:31 -05:00
Jeremy
0527cea39f
For the libbacktrace back-end don't treat missing debug info in ELFs as a critical error; fixes #114 2024-04-28 19:51:52 -05:00
Jeremy
c871c2a43c
Grab new microfmt changes and fix #113 2024-04-27 01:29:39 -05:00
Jeremy
599d6abd6c
Workaround bug for old msvc 2024-03-31 23:51:41 -05:00
Jeremy
0dd71cebb7
Mac fixes 2024-03-31 22:01:14 -05:00
Jeremy
06372b772f
Fix another warning 2024-03-31 16:42:51 -05:00
Jeremy
40696e8d02
Handle MSVC warning treated as error 2024-03-31 16:37:29 -05:00
Jeremy
ffb1b8ed68
A little more error handling cleanup 2024-03-31 16:02:39 -05:00
Jeremy
dc9cee98fb
Move error when returning 2024-03-31 15:52:45 -05:00
Jeremy
124607e7bf
Resolve some TODOs with error handling for mach-o stuff 2024-03-31 15:24:01 -05:00
Jeremy
b04fc09682
Update internal error messages 2024-03-31 14:18:21 -05:00
Jeremy
8007413ff6
Print Result(E) if not absorbing trace exceptions 2024-03-31 14:15:19 -05:00
Jeremy
4db73b1856
Fix assertion failure format string 2024-03-30 23:19:13 -05:00
Jeremy
50483783cb
Fix bug with non-recursive inline walking 2024-03-30 23:18:55 -05:00
Jeremy
ab63c34827
Replace most stream use with new formatting system 2024-03-30 20:25:06 -05:00
Jeremy Rifkin
acaa4f42e6
Add a Result type and replace some exceptions with it (#109) 2024-03-30 13:35:52 -05:00