Skip to content

Instantly share code, notes, and snippets.

@Musinux
Created May 15, 2020 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Musinux/6c8a7d1ca50c31309a9d6745b842ad3b to your computer and use it in GitHub Desktop.
Save Musinux/6c8a7d1ca50c31309a9d6745b842ad3b to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <execinfo.h>
void print_backtrace () {
void *array[10];
size_t size;
// get void*'s for all entries on the stack
size = backtrace(array, 10);
// print out all the frames to stderr
backtrace_symbols_fd(array, size, STDERR_FILENO);
}
#ifndef UTILS_H
#define UTILS_H
void print_backtrace ();
#endif /* ifndef UTILS_H */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment