diff options
author | Mark Kettenis <kettenis@gnu.org> | 2001-07-28 16:48:59 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2001-07-28 16:48:59 +0000 |
commit | 3d2615808faf9c93f0fe8a20133fa80e12163a82 (patch) | |
tree | 2066c9306b6e077a2439d67dd803076b66f60e0a /gdb | |
parent | d708bcbabb043a0e95555e8e44fc7d6da92795fa (diff) | |
download | gdb-3d2615808faf9c93f0fe8a20133fa80e12163a82.zip gdb-3d2615808faf9c93f0fe8a20133fa80e12163a82.tar.gz gdb-3d2615808faf9c93f0fe8a20133fa80e12163a82.tar.bz2 |
* i386-tdep.c: Include "gdb_assert.h"
(i386_register_convert_to_virtual): Fix such that it can handle
conversion to any floating-point type. Assert that we are dealing
with a floating-point first.
(i386_register_convert_to_raw): Assert that TYPE is a
floating-point type with length 12.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/i386-tdep.c | 30 |
2 files changed, 31 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0f1b56c..51c7727 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2001-07-28 Mark Kettenis <kettenis@gnu.org> + + * i386-tdep.c: Include "gdb_assert.h" + (i386_register_convert_to_virtual): Fix such that it can handle + conversion to any floating-point type. Assert that we are dealing + with a floating-point first. + (i386_register_convert_to_raw): Assert that TYPE is a + floating-point type with length 12. + 2001-07-27 John R. Moore <jmoore@redhat.com> * configure.in: Added dependency of gdb on tcl/tk libraries. diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 57a2bd3..60ca84e 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -33,6 +33,8 @@ #include "arch-utils.h" #include "regcache.h" +#include "gdb_assert.h" + /* i386_register_byte[i] is the offset into the register file of the start of register number i. We initialize this from i386_register_raw_size. */ @@ -972,27 +974,39 @@ i386_register_convertible (int regnum) } /* Convert data from raw format for register REGNUM in buffer FROM to - virtual format with type TYPE in buffer TO. In principle both - formats are identical except that the virtual format has two extra - bytes appended that aren't used. We set these to zero. */ + virtual format with type TYPE in buffer TO. */ void i386_register_convert_to_virtual (int regnum, struct type *type, char *from, char *to) { - /* Copy straight over, but take care of the padding. */ - memcpy (to, from, FPU_REG_RAW_SIZE); - memset (to + FPU_REG_RAW_SIZE, 0, TYPE_LENGTH (type) - FPU_REG_RAW_SIZE); + char buf[12]; + DOUBLEST d; + + /* We only support floating-point values. */ + gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT); + + /* First add the necessary padding. */ + memcpy (buf, from, FPU_REG_RAW_SIZE); + memset (buf + FPU_REG_RAW_SIZE, 0, sizeof buf - FPU_REG_RAW_SIZE); + + /* Convert to TYPE. This should be a no-op, if TYPE is equivalent + to the extended floating-point format used by the FPU. */ + d = extract_floating (buf, sizeof buf); + store_floating (to, TYPE_LENGTH (type), d); } /* Convert data from virtual format with type TYPE in buffer FROM to - raw format for register REGNUM in buffer TO. Simply omit the two - unused bytes. */ + raw format for register REGNUM in buffer TO. */ void i386_register_convert_to_raw (struct type *type, int regnum, char *from, char *to) { + gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT + && TYPE_LENGTH (type) == 12); + + /* Simply omit the two unused bytes. */ memcpy (to, from, FPU_REG_RAW_SIZE); } |