diff options
author | Michael Meissner <gnu@the-meissners.org> | 1995-10-26 16:43:00 +0000 |
---|---|---|
committer | Michael Meissner <gnu@the-meissners.org> | 1995-10-26 16:43:00 +0000 |
commit | 22ddef466ef2afd6b2ce7b51046628d926cd0253 (patch) | |
tree | 0c0685c6fa0dfbfc6692f1a8cec31e2623db503b /sim/ppc | |
parent | 65f1be0633e19288837b77453ab879a1f5d7d7f8 (diff) | |
download | fsf-binutils-gdb-22ddef466ef2afd6b2ce7b51046628d926cd0253.zip fsf-binutils-gdb-22ddef466ef2afd6b2ce7b51046628d926cd0253.tar.gz fsf-binutils-gdb-22ddef466ef2afd6b2ce7b51046628d926cd0253.tar.bz2 |
Fix SWAP_8 and optimize it; print out the failing address if a signal is issued for non-gdb runs
Diffstat (limited to 'sim/ppc')
-rw-r--r-- | sim/ppc/ChangeLog | 11 | ||||
-rw-r--r-- | sim/ppc/main.c | 30 | ||||
-rw-r--r-- | sim/ppc/ppc-endian.c | 61 |
3 files changed, 42 insertions, 60 deletions
diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog index aee2640..0c99b15 100644 --- a/sim/ppc/ChangeLog +++ b/sim/ppc/ChangeLog @@ -1,3 +1,14 @@ +Thu Oct 26 10:42:28 1995 Michael Meissner <meissner@tiktok.cygnus.com> + + * ppc-endian.c (SWAP_n): Add SET argument to allow use of SWAP + macros for either assignment or return. Fix SWAP_8 to use a + union, and two SWAP_4's. Delete SWAP_N, since nobody uses it now. + (ENDIAN_N): Add SET argument to SWAP_n calls. Delete macro defs + that hardwired swapping on/off, let optimizer delete dead code. + + * main.c (main): Add printf that we caught a signal and print out + the failing address. + Thu Oct 19 21:43:39 1995 Fred Fish <fnf@fishfood.amigalib.com> * Makefile.in: Remove tabs from otherwise empty line. diff --git a/sim/ppc/main.c b/sim/ppc/main.c index 90ccfa8..1227940 100644 --- a/sim/ppc/main.c +++ b/sim/ppc/main.c @@ -38,6 +38,7 @@ printf_filtered(const char *msg, ...) va_list ap; va_start(ap, msg); vprintf(msg, ap); + va_end(ap); } void @@ -46,6 +47,7 @@ error (char *msg, ...) va_list ap; va_start(ap, msg); vprintf(msg, ap); + va_end(ap); exit (1); } @@ -68,7 +70,7 @@ zfree(void *chunk) static void usage(void) { - error ("Usage: psim [ -a -p -c -C -s -i -I -t ] <image> [ <image-args> ... ]\n"); + error ("Usage: psim [ -a -p -c -C -s -i -I -t -g ] <image> [ <image-args> ... ]\n"); } int @@ -85,39 +87,41 @@ main(int argc, char **argv) /* check for arguments -- note sim_calls.c also contains argument processing code for the simulator linked within gdb. */ - while ((letter = getopt (argc, argv, "acCiIpst")) != EOF) + while ((letter = getopt (argc, argv, "acCiIpstg")) != EOF) { switch (letter) { case 'a': for (i = 0; i < nr_trace; i++) - trace[i] = 1; + ppc_trace[i] = 1; break; case 'p': - trace[trace_cpu] = trace[trace_semantics] = 1; + ppc_trace[trace_cpu] = ppc_trace[trace_semantics] = 1; break; case 'c': - trace[trace_core] = 1; + ppc_trace[trace_core] = 1; break; case 'C': - trace[trace_console_device] = 1; + ppc_trace[trace_console_device] = 1; break; case 's': - trace[trace_create_stack] = 1; + ppc_trace[trace_create_stack] = 1; break; case 'i': - trace[trace_icu_device] = 1; + ppc_trace[trace_icu_device] = 1; break; case 'I': print_info = 1; break; case 't': - trace[trace_device_tree] = 1; + ppc_trace[trace_device_tree] = 1; + break; + case 'g': + ppc_trace[trace_gdb] = 1; break; default: usage(); } } - if (optind >= argc) usage(); name_of_file = argv[optind]; @@ -132,11 +136,12 @@ main(int argc, char **argv) putenv(arg_); /* initialize it */ - psim_load(system); + psim_init(system); psim_stack(system, &argv[optind], environ); psim_run(system); + /* any final clean up */ if (print_info) psim_print_info (system, 1); @@ -152,6 +157,9 @@ main(int argc, char **argv) case was_exited: return status.signal; case was_signalled: + printf ("%s: Caught signal %d at address 0x%lx\n", + name_of_file, (int)status.signal, + (long)status.program_counter); return status.signal; default: error("unknown halt condition\n"); diff --git a/sim/ppc/ppc-endian.c b/sim/ppc/ppc-endian.c index daa749c..1e51bdf 100644 --- a/sim/ppc/ppc-endian.c +++ b/sim/ppc/ppc-endian.c @@ -33,78 +33,41 @@ #include "ppc-endian.h" #include "sim_callbacks.h" - -typedef union { - unsigned_1 val_1[8]; - unsigned_2 val_2[4]; - unsigned_4 val_4[2]; - unsigned_8 val_8[1]; -} endian_map; - -#define SWAP_N(RAW,BYTE_SIZE) \ - endian_map in; \ - endian_map out; \ - int byte_nr; \ - in.val_##BYTE_SIZE[0] = RAW; \ - for (byte_nr = 0; byte_nr < BYTE_SIZE; byte_nr++) { \ - out.val_1[BYTE_SIZE-1-byte_nr] = in.val_1[byte_nr]; \ - } \ - return out.val_##BYTE_SIZE[0]; \ - #if (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && WITH_NTOH -#define SWAP_2(RAW) return htons (RAW) +#define SWAP_2(SET,RAW) SET htons (RAW) #endif #ifndef SWAP_2 -#define SWAP_2(RAW) return (((RAW) >> 8) | ((RAW) << 8)) +#define SWAP_2(SET,RAW) SET (((RAW) >> 8) | ((RAW) << 8)) #endif #if !defined(SWAP_4) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && WITH_NTOH -#define SWAP_4(RAW) return htonl (RAW) +#define SWAP_4(SET,RAW) SET htonl (RAW) #endif #ifndef SWAP_4 -#define SWAP_4(RAW) return (((RAW) << 24) | (((RAW) & 0xff00) << 8) | (((RAW) & 0xff0000) >> 8) | ((RAW) >> 24)) +#define SWAP_4(SET,RAW) SET (((RAW) << 24) | (((RAW) & 0xff00) << 8) | (((RAW) & 0xff0000) >> 8) | ((RAW) >> 24)) #endif #ifndef SWAP_8 -#define SWAP_8(RAW) SWAP_N(RAW,4) -#endif - -/* no need to swap */ -#if (WITH_HOST_BYTE_ORDER \ - && WITH_TARGET_BYTE_ORDER \ - && WITH_HOST_BYTE_ORDER == WITH_TARGET_BYTE_ORDER ) -#define ENDIAN_N(NAME,BYTE_SIZE) \ -unsigned_##BYTE_SIZE \ -endian_##NAME##_##BYTE_SIZE(unsigned_##BYTE_SIZE raw_in) \ -{ \ - return raw_in; \ -} -#endif - -/* always need to swap */ -#if (WITH_HOST_BYTE_ORDER \ - && WITH_TARGET_BYTE_ORDER \ - && WITH_HOST_BYTE_ORDER != WITH_TARGET_BYTE_ORDER ) -#define ENDIAN_N(NAME,BYTE_SIZE) \ -unsigned_##BYTE_SIZE \ -endian_##NAME##_##BYTE_SIZE(unsigned_##BYTE_SIZE raw_in) \ -{ \ - SWAP_##BYTE_SIZE(raw_in); \ -} +#define SWAP_8(SET,RAW) \ + union { unsigned_8 dword; unsigned_4 words[2]; } in, out; \ + in.dword = RAW; \ + SWAP_4 (out.words[0] =, in.words[1]); \ + SWAP_4 (out.words[1] =, in.words[0]); \ + SET out.dword; #endif #ifndef ENDIAN_N #define ENDIAN_N(NAME,BYTE_SIZE) \ -unsigned_##BYTE_SIZE \ +INLINE unsigned_##BYTE_SIZE \ endian_##NAME##_##BYTE_SIZE(unsigned_##BYTE_SIZE raw_in) \ { \ if (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER) { \ return raw_in; \ } \ else { \ - SWAP_##BYTE_SIZE(raw_in); \ + SWAP_##BYTE_SIZE(return, raw_in); \ } \ } #endif |