FreeRDP/winpr/libwinpr/utils/test/TestBacktrace.c

29 lines
474 B
C
Raw Normal View History

2014-09-17 20:04:47 +04:00
#include <stdio.h>
2014-09-17 19:30:04 +04:00
#include <winpr/debug.h>
int TestBacktrace(int argc, char* argv[])
{
int rc = -1;
size_t used, x;
char **msg;
void *stack = winpr_backtrace(20);
if (!stack)
{
fprintf(stderr, "winpr_backtrace failed!\n");
return -1;
}
msg = winpr_backtrace_symbols(stack, &used);
if (msg)
{
for (x=0; x<used; x++)
printf("%zd: %s\n", x, msg[x]);
rc = 0;
}
winpr_backtrace_symbols_fd(stack, stdout);
winpr_backtrace_free(stack);
return rc;
}