(STACK_SIZE): SIGSTKSZ is also ridiculously small on x86-64 (at least
for SuSE LES 9) so use 128KB instead.
(do_backtrace): Also print backtrace obtained via backtrace().
(foo): Remove backtrace() call---now done in do_backtrace().
(Logical change 1.290)
diff --git a/tests/Gtest-bt.c b/tests/Gtest-bt.c
index c844779..1256512 100644
--- a/tests/Gtest-bt.c
+++ b/tests/Gtest-bt.c
@@ -38,8 +38,8 @@
#include <unistd.h>
#include <libunwind.h>
-#if UNW_TARGET_X86
-# define STACK_SIZE (128*1024) /* On x86, SIGSTKSZ is too small */
+#if UNW_TARGET_X86 || UNW_TARGET_X86_64
+# define STACK_SIZE (128*1024) /* On x86/-64, SIGSTKSZ is too small */
#else
# define STACK_SIZE SIGSTKSZ
#endif
@@ -64,6 +64,9 @@
unw_context_t uc;
int ret;
+ if (verbose)
+ printf ("\texplicit backtrace:\n");
+
unw_getcontext (&uc);
if (unw_init_local (&cursor, &uc) < 0)
panic ("unw_init_local failed!\n");
@@ -110,24 +113,24 @@
}
}
while (ret > 0);
+
+ {
+ void *buffer[20];
+ int i, n;
+
+ if (verbose)
+ printf ("\n\tvia backtrace():\n");
+ n = backtrace (buffer, 20);
+ if (verbose)
+ for (i = 0; i < n; ++i)
+ printf ("[%d] ip=%p\n", i, buffer[i]);
+ }
}
void
foo (long val)
{
- void *buffer[20];
- int i, n;
-
- if (verbose)
- printf ("\texplicit backtrace:\n");
do_backtrace ();
-
- if (verbose)
- printf ("\n\tvia backtrace():\n");
- n = backtrace (buffer, 20);
- if (verbose)
- for (i = 0; i < n; ++i)
- printf ("[%d] ip=%p\n", i, buffer[i]);
}
void