diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-10-28 14:27:39 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-10-28 14:27:39 +0000 |
commit | 4d52ec86232dc86ecb96d883d975d5711e49ee17 (patch) | |
tree | 685e2dea994938732e5f6678be32712627cba8ef /gdb | |
parent | 2487f88fdcf0b71aae73f919fc222475dab4ec1b (diff) | |
download | gdb-4d52ec86232dc86ecb96d883d975d5711e49ee17.zip gdb-4d52ec86232dc86ecb96d883d975d5711e49ee17.tar.gz gdb-4d52ec86232dc86ecb96d883d975d5711e49ee17.tar.bz2 |
* valops.c (value_assign): Change bitfield code to use a buffer of
the correct size, rather than an int.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 14 | ||||
-rw-r--r-- | gdb/valops.c | 42 |
2 files changed, 40 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 993cb98..d21c611 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,8 +1,16 @@ +Thu Oct 28 09:14:42 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * valops.c (value_assign): Change bitfield code to use a buffer of + the correct size, rather than an int. + Wed Oct 27 13:43:07 1993 Jim Kingdon (kingdon@lioth.cygnus.com) - * config/i386/{i386m3.mt,i386m3.mh}: Use correct names for TM_FILE - and XM_FILE. Replace host file i386mach3-xdep.o with native file - i386m3-nat.o. + * config/i386/{i386m3.mt,i386m3.mh}, + config/mips/{mipsm3.mt,mipsm3.mh}, + config/ns32k/{ns32km3.mt,ns32km3.mh}: Use correct names for TM_FILE + and XM_FILE. Replace host files *mach3-xdep.o with native + files *m3-nat.o. Replace host file os-mach3.o with native + file m3-nat.o. * remote-udi.c: Remove LOG_FILE stuff; superceded by "set remotedebug". * remote-mon.c: Remove commented out "set remotedebug" command. diff --git a/gdb/valops.c b/gdb/valops.c index fd2441b..7697266 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -329,13 +329,24 @@ value_assign (toval, fromval) case lval_memory: if (VALUE_BITSIZE (toval)) { - int v; /* FIXME, this won't work for large bitfields */ + char buffer[sizeof (LONGEST)]; + /* We assume that the argument to read_memory is in units of + host chars. FIXME: Is that correct? */ + int len = (VALUE_BITPOS (toval) + + VALUE_BITSIZE (toval) + + HOST_CHAR_BIT - 1) + / HOST_CHAR_BIT; + /* If bigger than a LONGEST, we don't handle it correctly, + but at least avoid corrupting memory. */ + if (len > sizeof (LONGEST)) + len = sizeof (LONGEST); + read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - (char *) &v, sizeof v); - modify_field ((char *) &v, value_as_long (fromval), + buffer, len); + modify_field (buffer, value_as_long (fromval), VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - (char *)&v, sizeof v); + buffer, len); } else if (use_buffer) write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), @@ -348,14 +359,14 @@ value_assign (toval, fromval) case lval_register: if (VALUE_BITSIZE (toval)) { - int v; - - read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - (char *) &v, sizeof v); - modify_field ((char *) &v, value_as_long (fromval), - VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); - write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - (char *) &v, sizeof v); + char buffer[MAX_REGISTER_RAW_SIZE]; + int len = REGISTER_RAW_SIZE (VALUE_REGNO (toval)); + read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), + buffer, len); + modify_field (buffer, value_as_long (fromval), + VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); + write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), + buffer, len); } else if (use_buffer) write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), @@ -392,7 +403,12 @@ value_assign (toval, fromval) int byte_offset = VALUE_OFFSET (toval) % reg_size; int reg_offset = VALUE_OFFSET (toval) / reg_size; int amount_copied; - char *buffer = (char *) alloca (amount_to_copy); + + /* Make the buffer large enough in all cases. */ + char *buffer = (char *) alloca (amount_to_copy + + sizeof (LONGEST) + + MAX_REGISTER_RAW_SIZE); + int regno; FRAME frame; |