https://github.com/jhurliman/callstackpp
Stack trace pretty printing in C++
https://github.com/jhurliman/callstackpp
backtrace cpp-library segfault stacktrace
Last synced: 3 months ago
JSON representation
Stack trace pretty printing in C++
- Host: GitHub
- URL: https://github.com/jhurliman/callstackpp
- Owner: jhurliman
- License: mit
- Created: 2021-02-02T02:12:16.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-03T20:37:50.000Z (over 4 years ago)
- Last Synced: 2025-01-28T22:19:47.142Z (4 months ago)
- Topics: backtrace, cpp-library, segfault, stacktrace
- Language: C++
- Homepage:
- Size: 85.9 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# callstackpp
### A C++ stack trace pretty printer
[](https://travis-ci.com/jhurliman/callstackpp)
[](https://codecov.io/gh/jhurliman/callstackpp)## Usage
### Install a signal handler that will pretty print a stack trace on segfault
```cpp
#include#include "callstackpp.hpp"
static callstackpp::SignalHandler sh;
int invalid_read() {
char *ptr = reinterpret_cast(42);
int v = *ptr;
return v;
}void invalid_write() {
char *ptr = reinterpret_cast(42);
*ptr = 42;
}void call_abort() {
std::cout << "Aborting!\n";
abort();
}int main() {
// Try commenting and uncommenting different lines in this method to test
std::cout << invalid_read() << '\n';
// invalid_write();
// call_abort();
}
```## Test
```shell
# build test binaries
make# run tests
make test
```The default test binaries will be built in release mode (with debug info). You
can make Debug test binaries as well:```shell
make clean
make debug
make test
```Enable additional sanitizers to catch hard-to-find bugs, for example:
```shell
export LDFLAGS="-fsanitize=address,undefined"
export CXXFLAGS="-fsanitize=address,undefined"make
```# License
callstackpp is licensed under [MIT](https://opensource.org/licenses/MIT).