diff options
author | hp.com!davidm <hp.com!davidm> | 2003-12-05 00:45:03 +0000 |
---|---|---|
committer | hp.com!davidm <hp.com!davidm> | 2003-12-05 00:45:03 +0000 |
commit | 5e111c69df0a0b9e733a662ea7877b3cb73fc661 (patch) | |
tree | 8153f89fea9b1afea4b38bbcf576963a36d5f8c8 /tests/test-mem.c | |
parent | e71e68a15e7c9d9565cf2142a91e1741801e2156 (diff) | |
download | libunwind-5e111c69df0a0b9e733a662ea7877b3cb73fc661.tar.gz |
(Logical change 1.137)
Diffstat (limited to 'tests/test-mem.c')
-rw-r--r-- | tests/test-mem.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/test-mem.c b/tests/test-mem.c new file mode 100644 index 00000000..89b2d906 --- /dev/null +++ b/tests/test-mem.c @@ -0,0 +1,58 @@ +#include <libunwind.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <sys/resource.h> + +#define panic(args...) \ + { fprintf (stderr, args); exit (-1); } + +int verbose; + +static void +do_backtrace (void) +{ + unw_cursor_t cursor; + unw_word_t ip, sp; + unw_context_t uc; + int ret; + + unw_getcontext (&uc); + if (unw_init_local (&cursor, &uc) < 0) + panic ("unw_init_local failed!\n"); + + do + { + unw_get_reg (&cursor, UNW_REG_IP, &ip); + unw_get_reg (&cursor, UNW_REG_SP, &sp); + + if (verbose) + printf ("%016lx (sp=%016lx)\n", (long) ip, (long) sp); + + ret = unw_step (&cursor); + if (ret < 0) + { + unw_get_reg (&cursor, UNW_REG_IP, &ip); + panic ("FAILURE: unw_step() returned %d for ip=%lx\n", + ret, (long) ip); + } + } + while (ret > 0); +} + +int +main (int argc, char **argv) +{ + struct rlimit rlim; + + verbose = argc > 1; + + rlim.rlim_cur = 0; + rlim.rlim_max = RLIM_INFINITY; + setrlimit (RLIMIT_DATA, &rlim); + setrlimit (RLIMIT_AS, &rlim); + + do_backtrace (); + return 0; +} |