From 83acabca138ee4ef3dcb7072dd1ed797fdfae4e4 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Wed, 24 Oct 2007 20:29:14 +0000 Subject: [PATCH] * amd64-tdep.c (amd64_convert_register_p): Delete. (amd64_init_abi): Use i387_convert_register_p. * alpha-tdep.c (alpha_convert_register_p): Return zero for eight byte types. (alpha_register_to_value, alpha_value_to_register): Do not handle eight byte types. * i386-tdep.c (i386_convert_register_p): Use i387_convert_register_p. * i387-tdep.c (i387_convert_register_p): New. (i387_register_to_value, i387_value_to_register): Update comments. * i387-tdep.h (i387_convert_register_p): Declare. * ia64-tdep.c (ia64_convert_register_p): Return zero for builtin_type_ia64_ext. (ia64_gdbarch_init): Do not initialize builtin_type_ia64_ext here. (_initialize_ia64_tdep): Initialize builtin_type_ia64_ext here. * m68k-tdep.c (m68k_convert_register_p): Return zero for builtin_type_m68881_ext. (m68k_register_to_value, m68k_value_to_register): Update comments. * gdbint.texinfo (Register and Memory Data, Target Conditionals): Document that gdbarch_convert_register_p should return zero for no-op conversions. --- gdb/ChangeLog | 20 ++++++++++++++++++++ gdb/alpha-tdep.c | 9 ++------- gdb/amd64-tdep.c | 10 +--------- gdb/doc/ChangeLog | 10 ++++++++-- gdb/doc/gdbint.texinfo | 7 +++++-- gdb/i386-tdep.c | 2 +- gdb/i387-tdep.c | 25 +++++++++++++++++++++---- gdb/i387-tdep.h | 5 +++++ gdb/ia64-tdep.c | 15 ++++++++------- gdb/m68k-tdep.c | 9 ++++----- 10 files changed, 75 insertions(+), 37 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fd634e5f12..f00ede0859 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,23 @@ +2007-10-24 Daniel Jacobowitz + + * amd64-tdep.c (amd64_convert_register_p): Delete. + (amd64_init_abi): Use i387_convert_register_p. + * alpha-tdep.c (alpha_convert_register_p): Return zero for + eight byte types. + (alpha_register_to_value, alpha_value_to_register): Do not handle + eight byte types. + * i386-tdep.c (i386_convert_register_p): Use i387_convert_register_p. + * i387-tdep.c (i387_convert_register_p): New. + (i387_register_to_value, i387_value_to_register): Update comments. + * i387-tdep.h (i387_convert_register_p): Declare. + * ia64-tdep.c (ia64_convert_register_p): Return zero for + builtin_type_ia64_ext. + (ia64_gdbarch_init): Do not initialize builtin_type_ia64_ext here. + (_initialize_ia64_tdep): Initialize builtin_type_ia64_ext here. + * m68k-tdep.c (m68k_convert_register_p): Return zero for + builtin_type_m68881_ext. + (m68k_register_to_value, m68k_value_to_register): Update comments. + 2007-10-24 Nathan Sidwell * target-memory.c (claim_memory): Propagate baton for split memory diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 623d1bea2c..4b175d015b 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -200,7 +200,8 @@ alpha_sts (void *out, const void *in) static int alpha_convert_register_p (int regno, struct type *type) { - return (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31); + return (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31 + && TYPE_LENGTH (type) != 8); } static void @@ -215,9 +216,6 @@ alpha_register_to_value (struct frame_info *frame, int regnum, case 4: alpha_sts (out, in); break; - case 8: - memcpy (out, in, 8); - break; default: error (_("Cannot retrieve value from floating point register")); } @@ -234,9 +232,6 @@ alpha_value_to_register (struct frame_info *frame, int regnum, case 4: alpha_lds (out, in); break; - case 8: - memcpy (out, in, 8); - break; default: error (_("Cannot store value in floating point register")); } diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 3ca8dde7af..ff5272ba5c 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -200,14 +200,6 @@ amd64_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 -amd64_convert_register_p (int regnum, struct type *type) -{ - return i386_fp_regnum_p (regnum); -} /* Register classes as defined in the psABI. */ @@ -1155,7 +1147,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_frame_align (gdbarch, amd64_frame_align); set_gdbarch_frame_red_zone_size (gdbarch, 128); - set_gdbarch_convert_register_p (gdbarch, amd64_convert_register_p); + set_gdbarch_convert_register_p (gdbarch, i387_convert_register_p); set_gdbarch_register_to_value (gdbarch, i387_register_to_value); set_gdbarch_value_to_register (gdbarch, i387_value_to_register); diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index ed8ae707e7..321f79ed83 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,12 +1,18 @@ +2007-10-24 Daniel Jacobowitz + + * gdbint.texinfo (Register and Memory Data, Target Conditionals): + Document that gdbarch_convert_register_p should return zero for no-op + conversions. + 2007-10-22 Ulrich Weigand - * gdbarch.texi (Compiler Characteristics): Move documentation + * gdbint.texi (Compiler Characteristics): Move documentation of set_gdbarch_sofun_address_maybe_missing back to ... (Target Conditionals): ... here to fix build break. 2007-10-19 Ulrich Weigand - * gdbarch.texi (Target Conditionals): Remove documentation of + * gdbint.texi (Target Conditionals): Remove documentation of SOFUN_ADDRESS_MAYBE_MISSING, replaced by ... (Compiler Characteristics): ... documentation of set_gdbarch_sofun_address_maybe_missing. diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index 0854f919e4..e40dd4ed52 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -3226,6 +3226,9 @@ when stored in memory. When non-zero, the macros @code{gdbarch_register_to_value} and @code{value_to_register} are used to perform any necessary conversion. + +This function should return zero for the register's native type, when +no conversion is necessary. @end deftypefun @deftypefun void gdbarch_register_to_value (struct gdbarch *@var{gdbarch}, int @var{reg}, struct type *@var{type}, char *@var{from}, char *@var{to}) @@ -3462,8 +3465,8 @@ default so that @value{GDBN} will assume that all registers may be written. @item int gdbarch_convert_register_p (@var{gdbarch}, @var{regnum}, struct type *@var{type}) @findex gdbarch_convert_register_p -Return non-zero if register @var{regnum} can represent data values in a -non-standard form. +Return non-zero if register @var{regnum} represents data values of type +@var{type} in a non-standard form. @xref{Target Architecture Definition, , Using Different Register and Memory Data Representations}. @item CORE_ADDR gdbarch_decr_pc_after_break (@var{gdbarch}) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 58e1cf22df..1fda5b13b5 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1880,7 +1880,7 @@ i386_convert_register_p (int regnum, struct type *type) return 1; } - return i386_fp_regnum_p (regnum); + return i387_convert_register_p (regnum, type); } /* Read a value of type TYPE from register REGNUM in frame FRAME, and diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index 73a7797b0a..e665989e04 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -285,6 +285,25 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, } +/* Return nonzero if a value of type TYPE stored in register REGNUM + needs any special handling. */ + +int +i387_convert_register_p (int regnum, struct type *type) +{ + if (i386_fp_regnum_p (regnum)) + { + /* Floating point registers must be converted unless we are + accessing them in their hardware type. */ + if (type == builtin_type_i387_ext) + return 0; + else + return 1; + } + + return 0; +} + /* Read a value of type TYPE from register REGNUM in frame FRAME, and return its contents in TO. */ @@ -304,8 +323,7 @@ i387_register_to_value (struct frame_info *frame, int regnum, return; } - /* Convert to TYPE. This should be a no-op if TYPE is equivalent to - the extended floating-point format used by the FPU. */ + /* Convert to TYPE. */ get_frame_register (frame, regnum, from); convert_typed_floating (from, builtin_type_i387_ext, to, type); } @@ -329,8 +347,7 @@ i387_value_to_register (struct frame_info *frame, int regnum, 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 from TYPE. */ convert_typed_floating (from, type, to, builtin_type_i387_ext); put_frame_register (frame, regnum, to); } diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h index a6bd0c5086..a94b27ae13 100644 --- a/gdb/i387-tdep.h +++ b/gdb/i387-tdep.h @@ -55,6 +55,11 @@ extern void i387_print_float_info (struct gdbarch *gdbarch, struct frame_info *frame, const char *args); +/* Return nonzero if a value of type TYPE stored in register REGNUM + needs any special handling. */ + +extern int i387_convert_register_p (int regnum, struct type *type); + /* Read a value of type TYPE from register REGNUM in frame FRAME, and return its contents in TO. */ diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index ea030a763e..d5bea78955 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -920,7 +920,8 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, static int ia64_convert_register_p (int regno, struct type *type) { - return (regno >= IA64_FR0_REGNUM && regno <= IA64_FR127_REGNUM); + return (regno >= IA64_FR0_REGNUM && regno <= IA64_FR127_REGNUM + && type != builtin_type_ia64_ext); } static void @@ -3564,12 +3565,6 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->sigcontext_register_address = 0; tdep->pc_in_sigtramp = 0; - /* Define the ia64 floating-point format to gdb. */ - builtin_type_ia64_ext = - init_type (TYPE_CODE_FLT, 128 / 8, - 0, "builtin_type_ia64_ext", NULL); - TYPE_FLOATFORMAT (builtin_type_ia64_ext) = floatformats_ia64_ext; - /* According to the ia64 specs, instructions that store long double floats in memory use a long-double format different than that used in the floating registers. The memory format matches the @@ -3652,5 +3647,11 @@ extern initialize_file_ftype _initialize_ia64_tdep; /* -Wmissing-prototypes */ void _initialize_ia64_tdep (void) { + /* Define the ia64 floating-point format to gdb. */ + builtin_type_ia64_ext = + init_type (TYPE_CODE_FLT, 128 / 8, + 0, "builtin_type_ia64_ext", NULL); + TYPE_FLOATFORMAT (builtin_type_ia64_ext) = floatformats_ia64_ext; + gdbarch_register (bfd_arch_ia64, ia64_gdbarch_init, NULL); } diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 87e8c1d9d6..b75a952e83 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -171,7 +171,8 @@ m68k_convert_register_p (int regnum, struct type *type) { if (!gdbarch_tdep (current_gdbarch)->fpregs_present) return 0; - return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7); + return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7 + && type != builtin_type_m68881_ext); } /* Read a value of type TYPE from register REGNUM in frame FRAME, and @@ -193,8 +194,7 @@ m68k_register_to_value (struct frame_info *frame, int regnum, return; } - /* Convert to TYPE. This should be a no-op if TYPE is equivalent to - the extended floating-point format used by the FPU. */ + /* Convert to TYPE. */ get_frame_register (frame, regnum, from); convert_typed_floating (from, fpreg_type, to, type); } @@ -218,8 +218,7 @@ m68k_value_to_register (struct frame_info *frame, int regnum, 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 from TYPE. */ convert_typed_floating (from, type, to, fpreg_type); put_frame_register (frame, regnum, to); } -- 2.34.1