From 4d50f90ab81c6861aaafb77672573726636a9330 Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Fri, 9 Jul 1993 18:33:23 +0000 Subject: [PATCH] * a29k-tdep.c, findvar.c (get_saved_register): Fix byteswapping sins. --- gdb/ChangeLog | 4 ++++ gdb/a29k-tdep.c | 37 +++++++++++++++++++++++++++---------- gdb/findvar.c | 17 +++++++++++------ 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 138d5feed07..8b42909f99b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +Fri Jul 9 12:36:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * a29k-tdep.c, findvar.c (get_saved_register): Fix byteswapping sins. + Fri Jul 9 09:47:02 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) * defs.h, remote-eb.c (TM_FILE_OVERRIDE): Remove it. diff --git a/gdb/a29k-tdep.c b/gdb/a29k-tdep.c index fd90a2b54a4..e07148f9d99 100644 --- a/gdb/a29k-tdep.c +++ b/gdb/a29k-tdep.c @@ -504,7 +504,8 @@ frame_locals_address (fi) if actual_mem_addr is non-NULL, store there the address that it was fetched from (or if from a register the offset within registers). Set *LVAL to lval_memory or lval_register, depending - on where it came from. */ + on where it came from. The contents written into MYADDR are in + target format. */ void read_register_stack (memaddr, myaddr, actual_mem_addr, lval) CORE_ADDR memaddr; @@ -518,12 +519,16 @@ read_register_stack (memaddr, myaddr, actual_mem_addr, lval) /* If we don't do this 'info register' stops in the middle. */ if (memaddr >= rstack_high_address) { - int val = -1; /* a bogus value */ + /* a bogus value */ + char val[] = {~0, ~0, ~0, ~0}; /* It's in a local register, but off the end of the stack. */ int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; if (myaddr != NULL) - *(int*)myaddr = val; /* Provide bogusness */ - supply_register(regnum, (char *)&val); /* More bogusness */ + { + /* Provide bogusness */ + memcpy (myaddr, val, 4); + } + supply_register(regnum, val); /* More bogusness */ if (lval != NULL) *lval = lval_register; if (actual_mem_addr != NULL) @@ -550,7 +555,7 @@ read_register_stack (memaddr, myaddr, actual_mem_addr, lval) { /* It's in the memory portion of the register stack. */ if (myaddr != NULL) - read_memory (memaddr, myaddr, 4); + read_memory (memaddr, myaddr, 4); if (lval != NULL) *lval = lval_memory; if (actual_mem_addr != NULL) @@ -641,7 +646,11 @@ get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lvalp) if (regnum == RSP_REGNUM) { if (raw_buffer != NULL) - *(CORE_ADDR *)raw_buffer = fi->frame; + { + *(CORE_ADDR *)raw_buffer = fi->frame; + /* Put it back in target byte order. */ + SWAP_TARGET_AND_HOST (raw_buffer, sizeof (CORE_ADDR)); + } if (lvalp != NULL) *lvalp = not_lval; return; @@ -649,7 +658,11 @@ get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lvalp) else if (regnum == PC_REGNUM) { if (raw_buffer != NULL) - *(CORE_ADDR *)raw_buffer = fi->pc; + { + *(CORE_ADDR *)raw_buffer = fi->pc; + /* Put it back in target byte order. */ + SWAP_TARGET_AND_HOST (raw_buffer, sizeof (CORE_ADDR)); + } /* Not sure we have to do this. */ if (lvalp != NULL) @@ -662,9 +675,13 @@ get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lvalp) if (raw_buffer != NULL) { if (fi->next != NULL) - *(CORE_ADDR *)raw_buffer = fi->next->saved_msp; + { + *(CORE_ADDR *)raw_buffer = fi->next->saved_msp; + /* Put it back in target byte order. */ + SWAP_TARGET_AND_HOST (raw_buffer, sizeof (CORE_ADDR)); + } else - *(CORE_ADDR *)raw_buffer = read_register (MSP_REGNUM); + read_register_gen (MSP_REGNUM, raw_buffer); } /* The value may have been computed, not fetched. */ if (lvalp != NULL) @@ -676,7 +693,7 @@ get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lvalp) /* These registers are not saved over procedure calls, so just print out the current values. */ if (raw_buffer != NULL) - *(CORE_ADDR *)raw_buffer = read_register (regnum); + read_register_gen (regnum, raw_buffer); if (lvalp != NULL) *lvalp = lval_register; if (addrp != NULL) diff --git a/gdb/findvar.c b/gdb/findvar.c index e38240521eb..a8ac396bcab 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -101,11 +101,11 @@ find_saved_register (frame, regnum) return addr; } -/* Find register number REGNUM relative to FRAME and put its - (raw) contents in *RAW_BUFFER. Set *OPTIMIZED if the variable - was optimized out (and thus can't be fetched). Set *LVAL to - lval_memory, lval_register, or not_lval, depending on whether the - value was fetched from memory, from a register, or in a strange +/* Find register number REGNUM relative to FRAME and put its (raw, + target format) contents in *RAW_BUFFER. Set *OPTIMIZED if the + variable was optimized out (and thus can't be fetched). Set *LVAL + to lval_memory, lval_register, or not_lval, depending on whether + the value was fetched from memory, from a register, or in a strange and non-modifiable way (e.g. a frame pointer which was calculated rather than fetched). Set *ADDRP to the address, either in memory on as a REGISTER_BYTE offset into the registers array. @@ -115,6 +115,7 @@ find_saved_register (frame, regnum) your own. The argument RAW_BUFFER must point to aligned memory. */ + void get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) char *raw_buffer; @@ -136,7 +137,11 @@ get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) if (regnum == SP_REGNUM) { if (raw_buffer != NULL) - *(CORE_ADDR *)raw_buffer = addr; + { + *(CORE_ADDR *)raw_buffer = addr; + /* Put it back in target byte order. */ + SWAP_TARGET_AND_HOST (raw_buffer, sizeof (CORE_ADDR)); + } if (addrp != NULL) *addrp = 0; return; -- 2.30.2