aboutsummaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorJohn Gilmore <gnu@cygnus>1991-04-05 09:02:10 +0000
committerJohn Gilmore <gnu@cygnus>1991-04-05 09:02:10 +0000
commit3f2e006b77f217bbf4a4cb9299cf248058a44ed3 (patch)
tree60b9a78e945e02698d856ea5b82982fe549b26f2 /gdb/values.c
parent07d021a6ae8d3ed9da9f55c8623739e7a716308e (diff)
downloadfsf-binutils-gdb-3f2e006b77f217bbf4a4cb9299cf248058a44ed3.zip
fsf-binutils-gdb-3f2e006b77f217bbf4a4cb9299cf248058a44ed3.tar.gz
fsf-binutils-gdb-3f2e006b77f217bbf4a4cb9299cf248058a44ed3.tar.bz2
*** empty log message ***
Diffstat (limited to 'gdb/values.c')
-rw-r--r--gdb/values.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gdb/values.c b/gdb/values.c
index 39ec8ea..5d40882 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -1111,6 +1111,11 @@ unpack_field_as_long (type, valaddr, fieldno)
return val;
}
+/* Modify the value of a bitfield. ADDR points to a block of memory in
+ target byte order; the bitfield starts in the byte pointed to. FIELDVAL
+ is the desired value of the field, in host byte order. BITPOS and BITSIZE
+ indicate which bits (in target bit order) comprise the bitfield. */
+
void
modify_field (addr, fieldval, bitpos, bitsize)
char *addr;
@@ -1125,14 +1130,17 @@ modify_field (addr, fieldval, bitpos, bitsize)
error ("Value %d does not fit in %d bits.", fieldval, bitsize);
bcopy (addr, &oword, sizeof oword);
+ SWAP_TARGET_AND_HOST (&oword, sizeof oword); /* To host format */
- /* Shifting for bit field depends on endianness of the machine. */
+ /* Shifting for bit field depends on endianness of the target machine. */
#ifdef BITS_BIG_ENDIAN
bitpos = sizeof (oword) * 8 - bitpos - bitsize;
#endif
oword &= ~(((1 << bitsize) - 1) << bitpos);
oword |= fieldval << bitpos;
+
+ SWAP_TARGET_AND_HOST (&oword, sizeof oword); /* To target format */
bcopy (&oword, addr, sizeof oword);
}