diff options
author | Mark Kettenis <kettenis@gnu.org> | 2003-06-15 11:01:46 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2003-06-15 11:01:46 +0000 |
commit | d532c08fb0172968305f4ebda8e128593e27dba0 (patch) | |
tree | dfe581b954dc279fc97a665e9b84d1554888c2f7 | |
parent | f63f176ed65dc87e1ff44ee63ebcdc808f9226e0 (diff) | |
download | gdb-d532c08fb0172968305f4ebda8e128593e27dba0.zip gdb-d532c08fb0172968305f4ebda8e128593e27dba0.tar.gz gdb-d532c08fb0172968305f4ebda8e128593e27dba0.tar.bz2 |
* i386-tdep.c (i386_register_to_value, i386_value_to_register):
Move floating-point code to new function in i387-tdep.c.
* i387-tdep.c (i387_register_to_value, i387_value_to_register):
New functions containing code moved here from i386-tdep.c.
* i387-tdep.h: Add opaque declaration for `struct type'.
(i387_register_to_value, i387_value_to_register): New prototypes.
* x86-64-tdep.c (x86_64_convert_register_p): New function.
(x86_64_init_abi): Set convert_register_p, register_to_value and
value_to_register here.
-rw-r--r-- | gdb/ChangeLog | 12 | ||||
-rw-r--r-- | gdb/i386-tdep.c | 80 | ||||
-rw-r--r-- | gdb/i387-tdep.c | 52 | ||||
-rw-r--r-- | gdb/i387-tdep.h | 13 | ||||
-rw-r--r-- | gdb/x86-64-tdep.c | 13 |
5 files changed, 115 insertions, 55 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 04d406e..c76c524 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2003-06-15 Mark Kettenis <kettenis@gnu.org> + + * i386-tdep.c (i386_register_to_value, i386_value_to_register): + Move floating-point code to new function in i387-tdep.c. + * i387-tdep.c (i387_register_to_value, i387_value_to_register): + New functions containing code moved here from i386-tdep.c. + * i387-tdep.h: Add opaque declaration for `struct type'. + (i387_register_to_value, i387_value_to_register): New prototypes. + * x86-64-tdep.c (x86_64_convert_register_p): New function. + (x86_64_init_abi): Set convert_register_p, register_to_value and + value_to_register here. + 2003-06-14 Andrew Cagney <cagney@redhat.com> * mips-tdep.c (mips_register_to_value): Make static. diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 4a814c1..350a93c 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1392,36 +1392,21 @@ i386_register_to_value (struct frame_info *frame, int regnum, if (i386_fp_regnum_p (regnum)) { - char from[I386_MAX_REGISTER_SIZE]; - - /* We only support floating-point values. */ - if (TYPE_CODE (type) != TYPE_CODE_FLT) - { - warning ("Cannot convert floating-point register value " - "to non-floating-point type."); - return; - } - - /* Convert to TYPE. This should be a no-op if TYPE is - equivalent to the extended floating-point format used by the - FPU. */ - frame_read_register (frame, regnum, from); - convert_typed_floating (from, builtin_type_i387_ext, to, type); + i387_register_to_value (frame, regnum, type, to); + return; } - else - { - gdb_assert (TYPE_LENGTH (type) == 8); - /* Read the first part. */ - gdb_assert (register_size (current_gdbarch, regnum) == 4); - frame_read_register (frame, regnum, (char *) to + 0); + gdb_assert (TYPE_LENGTH (type) == 8); - /* Read the second part. */ - regnum = i386_next_regnum (regnum); - gdb_assert (regnum != -1); - gdb_assert (register_size (current_gdbarch, regnum)); - frame_read_register (frame, regnum, (char *) to + 4); - } + /* Read the first part. */ + gdb_assert (register_size (current_gdbarch, regnum) == 4); + frame_read_register (frame, regnum, (char *) to + 0); + + /* Read the second part. */ + regnum = i386_next_regnum (regnum); + gdb_assert (regnum != -1); + gdb_assert (register_size (current_gdbarch, regnum)); + frame_read_register (frame, regnum, (char *) to + 4); } /* Write the contents FROM of a value of type TYPE into register @@ -1433,36 +1418,21 @@ i386_value_to_register (struct frame_info *frame, int regnum, { if (i386_fp_regnum_p (regnum)) { - char to[I386_MAX_REGISTER_SIZE]; + i387_value_to_register (frame, regnum, type, from); + return; + } - /* We only support floating-point values. */ - if (TYPE_CODE (type) != TYPE_CODE_FLT) - { - warning ("Cannot convert non-floating-point type " - "to floating-point register value."); - return; - } + gdb_assert (TYPE_LENGTH (type) == 8); - /* Convert from TYPE. This should be a no-op if TYPE is - equivalent to the extended floating-point format used by the - FPU. */ - convert_typed_floating (from, type, to, builtin_type_i387_ext); - put_frame_register (frame, regnum, to); - } - else - { - gdb_assert (TYPE_LENGTH (type) == 8); - - /* Write the first part. */ - gdb_assert (register_size (current_gdbarch, regnum) == 4); - put_frame_register (frame, regnum, (const char *) from + 0); - - /* Write the second part. */ - regnum = i386_next_regnum (regnum); - gdb_assert (regnum != -1); - gdb_assert (register_size (current_gdbarch, regnum) == 4); - put_frame_register (frame, regnum, (const char *) from + 4); - } + /* Write the first part. */ + gdb_assert (register_size (current_gdbarch, regnum) == 4); + put_frame_register (frame, regnum, (const char *) from + 0); + + /* Write the second part. */ + regnum = i386_next_regnum (regnum); + gdb_assert (regnum != -1); + gdb_assert (register_size (current_gdbarch, regnum) == 4); + put_frame_register (frame, regnum, (const char *) from + 4); } diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index c284207..ee550c6 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -282,6 +282,58 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, fprintf_filtered (file, "Opcode: %s\n", local_hex_string_custom (fop ? (fop | 0xd800) : 0, "04")); } + + +/* Read a value of type TYPE from register REGNUM in frame FRAME, and + return its contents in TO. */ + +void +i387_register_to_value (struct frame_info *frame, int regnum, + struct type *type, void *to) +{ + char from[I386_MAX_REGISTER_SIZE]; + + gdb_assert (i386_fp_regnum_p (regnum)); + + /* We only support floating-point values. */ + if (TYPE_CODE (type) != TYPE_CODE_FLT) + { + warning ("Cannot convert floating-point register value " + "to non-floating-point type."); + return; + } + + /* Convert to TYPE. This should be a no-op if TYPE is equivalent to + the extended floating-point format used by the FPU. */ + frame_read_register (frame, regnum, from); + convert_typed_floating (from, builtin_type_i387_ext, to, type); +} + +/* Write the contents FROM of a value of type TYPE into register + REGNUM in frame FRAME. */ + +void +i387_value_to_register (struct frame_info *frame, int regnum, + struct type *type, const void *from) +{ + char to[I386_MAX_REGISTER_SIZE]; + + gdb_assert (i386_fp_regnum_p (regnum)); + + /* We only support floating-point values. */ + if (TYPE_CODE (type) != TYPE_CODE_FLT) + { + warning ("Cannot convert non-floating-point type " + "to floating-point register value."); + return; + } + + /* Convert from TYPE. This should be a no-op if TYPE is equivalent + to the extended floating-point format used by the FPU. */ + convert_typed_floating (from, type, to, builtin_type_i387_ext); + put_frame_register (frame, regnum, to); +} + /* FIXME: kettenis/2000-05-21: Right now more than a few i386 targets define their own routines to manage the floating-point registers in diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h index 7079310..df5c77b 100644 --- a/gdb/i387-tdep.h +++ b/gdb/i387-tdep.h @@ -24,6 +24,7 @@ struct gdbarch; struct ui_file; struct frame_info; +struct type; /* Print out the i387 floating point state. */ @@ -32,6 +33,18 @@ extern void i387_print_float_info (struct gdbarch *gdbarch, struct frame_info *frame, const char *args); +/* Read a value of type TYPE from register REGNUM in frame FRAME, and + return its contents in TO. */ + +extern void i387_register_to_value (struct frame_info *frame, int regnum, + struct type *type, void *to); + +/* Write the contents FROM of a value of type TYPE into register + REGNUM in frame FRAME. */ + +extern void i387_value_to_register (struct frame_info *frame, int regnum, + struct type *type, const void *from); + /* Fill register REGNUM in GDB's register array with the appropriate value from *FSAVE. This function masks off any of the reserved bits in *FSAVE. */ diff --git a/gdb/x86-64-tdep.c b/gdb/x86-64-tdep.c index 6c38f8d..906ebd9 100644 --- a/gdb/x86-64-tdep.c +++ b/gdb/x86-64-tdep.c @@ -208,6 +208,15 @@ x86_64_dwarf_reg_to_regnum (int reg) return regnum; } + +/* Return nonzero if a value of type TYPE stored in register REGNUM + needs any special handling. */ + +static int +x86_64_convert_register_p (int regnum, struct type *type) +{ + return i386_fp_regnum_p (regnum); +} /* The returning of values is done according to the special algorithm. @@ -1178,6 +1187,10 @@ x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) /* Call dummy code. */ set_gdbarch_push_dummy_call (gdbarch, x86_64_push_dummy_call); + set_gdbarch_convert_register_p (gdbarch, x86_64_convert_register_p); + set_gdbarch_register_to_value (gdbarch, i387_register_to_value); + set_gdbarch_value_to_register (gdbarch, i387_value_to_register); + set_gdbarch_extract_return_value (gdbarch, x86_64_extract_return_value); set_gdbarch_store_return_value (gdbarch, x86_64_store_return_value); /* Override, since this is handled by x86_64_extract_return_value. */ |