From ccfcac6e20c515205936972e64b0abe40d40705d Mon Sep 17 00:00:00 2001 From: "mostang.com!davidm" Date: Thu, 19 Dec 2002 07:16:50 +0000 Subject: [PATCH] Make it compile cleanly on x86. (Logical change 1.32) --- tests/bt.c | 32 +++++++++++++++++++++++++------- tests/exc.c | 21 ++++++++++++++++----- tests/test-dyn1.c | 6 ++++-- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/tests/bt.c b/tests/bt.c index f5d5fa7e..926e23d9 100644 --- a/tests/bt.c +++ b/tests/bt.c @@ -39,6 +39,7 @@ static void do_backtrace (void) { unw_cursor_t cursor; + unw_proc_info_t pi; unw_word_t ip, sp; unw_context_t uc; char buf[512]; @@ -53,22 +54,29 @@ do_backtrace (void) unw_get_reg (&cursor, UNW_REG_IP, &ip); unw_get_reg (&cursor, UNW_REG_SP, &sp); unw_get_proc_name (&cursor, buf, sizeof (buf)); - printf ("%016lx %-32s (sp=%016lx)\n", ip, buf, sp); + printf ("%016lx %-32s (sp=%016lx)\n", (long) ip, buf, (long) sp); + unw_get_proc_info (&cursor, &pi); + printf ("\tproc=%016lx-%016lx\n\thandler=%lx lsda=%lx", + (long) pi.start_ip, (long) pi.end_ip, + (long) pi.handler, (long) pi.lsda); + +#if UNW_TARGET_IA64 { - unw_proc_info_t pi; unw_word_t bsp; - unw_get_proc_info (&cursor, &pi); unw_get_reg (&cursor, UNW_IA64_BSP, &bsp); - printf ("\tproc=%016lx-%016lx\n\thandler=%lx lsda=%lx bsp=%lx\n", - pi.start_ip, pi.end_ip, pi.handler, pi.lsda, bsp); + printf (" bsp=%lx", bsp); } +#endif + printf ("\n"); + ret = unw_step (&cursor); if (ret < 0) { unw_get_reg (&cursor, UNW_REG_IP, &ip); - printf ("FAILURE: unw_step() returned %d for ip=%lx\n", ret, ip); + printf ("FAILURE: unw_step() returned %d for ip=%lx\n", + ret, (long) ip); } } while (ret > 0); @@ -88,9 +96,19 @@ foo (void) } void +#ifdef UNW_TARGET_X86 +sighandler (int signal, struct sigcontext sc) +#else sighandler (int signal, void *siginfo, struct sigcontext *sc) +#endif { - printf ("sighandler: got signal %d @ %lx\n", signal, sc->sc_ip); + printf ("sighandler: got signal %d", signal); +#if UNW_TARGET_IA64 + printf (" @ %lx", sc->sc_ip); +#elif UNW_TARGET_X86 + printf (" @ %lx", sc.eip); +#endif + printf ("\n"); do_backtrace(); } diff --git a/tests/exc.c b/tests/exc.c index 70bba155..b59ffede 100644 --- a/tests/exc.c +++ b/tests/exc.c @@ -55,7 +55,7 @@ raise_exception (void *addr) panic ("unw_step() failed!\n"); unw_get_reg (&cursor, UNW_REG_IP, &ip); - printf ("ip = %lx\n", ip); + printf ("ip = %lx\n", (long) ip); if (unw_set_reg (&cursor, UNW_REG_IP, (unw_word_t) addr) < 0) panic ("unw_set_reg() failed!\n"); @@ -71,11 +71,22 @@ b (void *addr) printf ("b(): back from raise_exception!!\n"); } +#ifndef __ia64__ + +void * +__builtin_ia64_bsp (void) +{ + return NULL; +} + +#endif + static int a (void) { - register long sp asm ("r12"); - printf("a: sp=%lx bsp=%p\n", sp, __builtin_ia64_bsp ()); + long stack; + + printf ("a: sp=%p bsp=%p\n", &stack, __builtin_ia64_bsp ()); b (&&handler); printf ("unexpected return from func()!\n"); @@ -83,8 +94,8 @@ a (void) return -1; handler: - printf ("exception handler: here we go (sp=%lx, bsp=%p)...\n", - sp, __builtin_ia64_bsp ()); + printf ("exception handler: here we go (sp=%p, bsp=%p)...\n", + &stack, __builtin_ia64_bsp ()); return 0; } diff --git a/tests/test-dyn1.c b/tests/test-dyn1.c index d6814f31..6075883a 100644 --- a/tests/test-dyn1.c +++ b/tests/test-dyn1.c @@ -27,6 +27,7 @@ struct fdesc }; # define get_fdesc(fdesc,func) (fdesc = *(struct fdesc *) &(func)) # define get_funcp(fdesc) ((template_t) &(fdesc)) +# define get_gp(fdesc) ((fdesc).gp) #else struct fdesc { @@ -34,14 +35,15 @@ struct fdesc }; # define get_fdesc(fdesc,func) (fdesc.code = (long) &(func)) # define get_funcp(fdesc) ((template_t) (fdesc).code) +# define get_gp(fdesc) (0) #endif static void flush_cache (void *addr, unsigned long len) { +#ifdef __ia64__ void *end = (char *) addr + len; -#ifdef __ia64__ while (addr < end) { asm volatile ("fc %0" :: "r"(addr)); @@ -126,7 +128,7 @@ main (int argc, char *argv[]) memset (&di, 0, sizeof (di)); di.start_ip = (long) mem; di.end_ip = (long) mem + 256; - di.gp = fdesc.gp; + di.gp = get_gp (fdesc); di.format = UNW_INFO_FORMAT_DYNAMIC; di.u.pi.name_ptr = (unw_word_t) "copy_of_template"; di.u.pi.regions = region;