summaryrefslogtreecommitdiffstats
path: root/winpr/libwinpr/utils/test/TestBacktrace.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
commita9bcc81f821d7c66f623779fa5147e728eb3c388 (patch)
tree98676963bcdd537ae5908a067a8eb110b93486a6 /winpr/libwinpr/utils/test/TestBacktrace.c
parentInitial commit. (diff)
downloadfreerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.tar.xz
freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.zip
Adding upstream version 3.3.0+dfsg1.upstream/3.3.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'winpr/libwinpr/utils/test/TestBacktrace.c')
-rw-r--r--winpr/libwinpr/utils/test/TestBacktrace.c34
1 files changed, 34 insertions, 0 deletions
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 <stdio.h>
+#include <winpr/debug.h>
+
+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;
+}