Created
May 15, 2020 08:31
-
-
Save Musinux/6c8a7d1ca50c31309a9d6745b842ad3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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