| 1 |
// Example source from breakpad's linux tutorial |
| 2 |
// https://chromium.googlesource.com/breakpad/breakpad/+/main/docs/linux_starter_guide.md |
| 3 |
|
| 4 |
#include <stdio.h> |
| 5 |
#include <sys/types.h> |
| 6 |
#include <unistd.h> |
| 7 |
|
| 8 |
#include "client/linux/handler/exception_handler.h" |
| 9 |
|
| 10 |
static bool dumpCallback(const google_breakpad::MinidumpDescriptor &descriptor, |
| 11 |
void *context, bool succeeded) { |
| 12 |
printf("Dump path: %s\n", descriptor.path()); |
| 13 |
return succeeded; |
| 14 |
} |
| 15 |
|
| 16 |
void crash() { |
| 17 |
volatile int *a = (int *)(NULL); |
| 18 |
*a = 1; |
| 19 |
} |
| 20 |
|
| 21 |
int main(int argc, char *argv[]) { |
| 22 |
google_breakpad::MinidumpDescriptor descriptor("/tmp"); |
| 23 |
google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, |
| 24 |
true, -1); |
| 25 |
printf("pid: %d\n", getpid()); |
| 26 |
crash(); |
| 27 |
return 0; |
| 28 |
} |