From 5e111c69df0a0b9e733a662ea7877b3cb73fc661 Mon Sep 17 00:00:00 2001 From: "hp.com!davidm" Date: Fri, 5 Dec 2003 00:45:03 +0000 Subject: [PATCH] (Logical change 1.137) --- tests/test-mem.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/test-mem.c 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 +#include +#include +#include + +#include + +#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; +}