From a9bcc81f821d7c66f623779fa5147e728eb3c388 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 03:24:41 +0200 Subject: Adding upstream version 3.3.0+dfsg1. Signed-off-by: Daniel Baumann --- winpr/libwinpr/utils/test/TestBacktrace.c | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 winpr/libwinpr/utils/test/TestBacktrace.c (limited to 'winpr/libwinpr/utils/test/TestBacktrace.c') diff --git a/winpr/libwinpr/utils/test/TestBacktrace.c b/winpr/libwinpr/utils/test/TestBacktrace.c new file mode 100644 index 0000000..5fea333 --- /dev/null +++ b/winpr/libwinpr/utils/test/TestBacktrace.c @@ -0,0 +1,34 @@ +#include +#include + +int TestBacktrace(int argc, char* argv[]) +{ + int rc = -1; + size_t used = 0; + char** msg = NULL; + void* stack = winpr_backtrace(20); + + WINPR_UNUSED(argc); + WINPR_UNUSED(argv); + + if (!stack) + { + fprintf(stderr, "winpr_backtrace failed!\n"); + return -1; + } + + msg = winpr_backtrace_symbols(stack, &used); + + if (msg) + { + for (size_t x = 0; x < used; x++) + printf("%" PRIuz ": %s\n", x, msg[x]); + + rc = 0; + } + + winpr_backtrace_symbols_fd(stack, fileno(stdout)); + winpr_backtrace_free(stack); + free(msg); + return rc; +} -- cgit v1.2.3