A simple plain C wrapper for C++ Google Breakpad. What is Google Breakpad client library? Read about it here: Getting Started With Breakpad
Actually, you don't need this wrapper, you need Google Breakpad. But Google Breakpad is a c++ library with c++ headers. So, if you have a plain C project, that you want Google Breakpad to use with, you will need simple wrapper.
First, build and install breakpad library
git clone https://chromium.googlesource.com/breakpad/breakpad
cd breakpad
mkdir -p src/third_party/lss/
mkdir -p third_party/lss/ && cd third_party/lss/
git clone https://chromium.googlesource.com/linux-syscall-support
cp linux-syscall-support/*.h .
cp linux-syscall-support/*.h ../../src/third_party/lss/
cd -
./configure
make -j2
sudo make install
Now build this wrapper library:
git clone [email protected]:haiwen/bpwrapper.git
cd bpwrapper
./autogen.sh
./configure
make
sudo make install
Then:
- Modify the
main
function of your source code. See tests/test.c for example - Link your program with
-lbpwrapper -lstdc++
After that, each time the program crashes, a breakpad minidump file would be generated. See breadpad doc about how to get a full stacktrace and other info from this minidump file.
Here is example output of running the breakpad minidump_stackwalk
tool with a minidump. It provides useful information like the reason of crashing, strace trace of each thread, and OS information.