aboutsummaryrefslogtreecommitdiff
path: root/libsframe/testsuite/libsframe.stacktrace/solib-lib2.c
diff options
context:
space:
mode:
Diffstat (limited to 'libsframe/testsuite/libsframe.stacktrace/solib-lib2.c')
-rw-r--r--libsframe/testsuite/libsframe.stacktrace/solib-lib2.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/libsframe/testsuite/libsframe.stacktrace/solib-lib2.c b/libsframe/testsuite/libsframe.stacktrace/solib-lib2.c
new file mode 100644
index 0000000..ba590fd
--- /dev/null
+++ b/libsframe/testsuite/libsframe.stacktrace/solib-lib2.c
@@ -0,0 +1,55 @@
+#include <execinfo.h>
+#include <stdlib.h>
+#include <string.h>
+#include "sframe-stacktrace-api.h"
+#include "solib-lib2.h"
+
+#define BT_BUF_SIZE 100
+
+/* funclist for running "ttest.x 3". */
+static const char *const bt_list[] =
+{
+ "adder2",
+ "bar",
+ "adder",
+ "main"
+};
+
+unsigned int
+adder2 (unsigned int a, unsigned int b, int (*call)(int))
+{
+ void *buffer[BT_BUF_SIZE];
+ int i, nptrs, err;
+ char **strings;
+
+ nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err);
+ if (err)
+ {
+ printf ("SFrame error: %s\n", sframe_bt_errmsg (err));
+ return (-1);
+ }
+ if (nptrs != 4)
+ {
+ printf ("sframe_stacktrace failed: %d %d\n", nptrs, err);
+ return (-1);
+ }
+
+ strings = backtrace_symbols (buffer, nptrs);
+ if (strings == NULL)
+ {
+ printf ("Error in backtrace_symbols");
+ return (-1);
+ }
+
+ /* Verify the results. */
+ for (i = 0; i < nptrs; i++)
+ if (!strstr (strings[i], bt_list[i]))
+ break;
+
+ free (strings);
+
+ printf ("%s: unwind solib test\n", i == nptrs ? "PASS" : "FAIL");
+
+ (void)(*call) (a+b);
+ return (a+b);
+}