be sure that you link with -rdynamic flag
#include (execinfo.h)
void print_trace()
{
const size_t max_depth = 200;
size_t stack_depth;
void *stack_addrs[max_depth];
char **stack_strings;
int i;
stack_depth = backtrace(stack_addrs, max_depth);
stack_strings = backtrace_symbols(stack_addrs, stack_depth);
for (i = 1; i < stack_depth; i++) {
printf("%s\n", stack_strings[i]);
}
free(stack_strings);
}
For more info. visit http://www.gnu.org/s/hello/manual/libc/Backtraces.html
simple examples of how to
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment