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;
|
2017-11-15 11:11:12 +03:00
|
|
|
char** msg;
|
|
|
|
void* stack = winpr_backtrace(20);
|
|
|
|
|
2021-07-29 11:18:52 +03:00
|
|
|
WINPR_UNUSED(argc);
|
|
|
|
WINPR_UNUSED(argv);
|
|
|
|
|
2014-09-17 19:30:04 +04:00
|
|
|
if (!stack)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "winpr_backtrace failed!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = winpr_backtrace_symbols(stack, &used);
|
2017-11-15 11:11:12 +03:00
|
|
|
|
2014-09-17 19:30:04 +04:00
|
|
|
if (msg)
|
|
|
|
{
|
2017-11-15 11:11:12 +03:00
|
|
|
for (x = 0; x < used; x++)
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("%" PRIuz ": %s\n", x, msg[x]);
|
2017-11-15 11:11:12 +03:00
|
|
|
|
2014-09-17 19:30:04 +04:00
|
|
|
rc = 0;
|
|
|
|
}
|
2017-11-15 11:11:12 +03:00
|
|
|
|
2015-01-16 02:41:57 +03:00
|
|
|
winpr_backtrace_symbols_fd(stack, fileno(stdout));
|
2014-09-17 19:30:04 +04:00
|
|
|
winpr_backtrace_free(stack);
|
2017-11-15 11:11:12 +03:00
|
|
|
free(msg);
|
2014-09-17 19:30:04 +04:00
|
|
|
return rc;
|
|
|
|
}
|