Add C backtrace on Linux.

This commit is contained in:
giomba 2023-05-15 17:21:29 +02:00
parent b92ecc211b
commit 53d7de55bd
1 changed files with 15 additions and 0 deletions

15
backtrace.c Normal file
View 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);
}