aboutsummaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
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);
}