Add C backtrace on Linux.
This commit is contained in:
parent
b92ecc211b
commit
53d7de55bd
15
backtrace.c
Normal file
15
backtrace.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <execinfo.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int nptrs;
|
||||
#define BACKTRACE_SIZE 128
|
||||
void *buffer[BACKTRACE_SIZE];
|
||||
nptrs = backtrace(buffer, BACKTRACE_SIZE);
|
||||
printf("backtrace() returned %d addresses\n", nptrs);
|
||||
backtrace_symbols_fd(buffer, nptrs, 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user