From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26479 invoked by alias); 17 Oct 2007 14:03:17 -0000 Received: (qmail 26276 invoked by uid 22791); 17 Oct 2007 14:03:15 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 17 Oct 2007 14:03:11 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 49A08981F1 for ; Wed, 17 Oct 2007 14:03:09 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 08866980A5 for ; Wed, 17 Oct 2007 14:03:09 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.68) (envelope-from ) id 1Ii9UK-00047J-AZ for gdb-patches@sourceware.org; Wed, 17 Oct 2007 10:03:08 -0400 Date: Wed, 17 Oct 2007 18:32:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: [rfc] Tighten meaning of gdbarch_convert_register_p Message-ID: <20071017140308.GA15513@caradoc.them.org> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-10/txt/msg00439.txt.bz2 This patch tightens the definition of gdbarch_convert_register_p so that a non-zero result means that a conversion is necessary for the supplied TYPE, not just that one might be necessary for some type. This let me add an assertion that gdbarch_register_convert_p was zero for any unwound register values in the new value-based unwinding that I wrote yesterday. It doesn't affect anything besides the assertion, since all definitions do no-op conversions to the register's own type anyway. We could document that requirement on gdbarch_register_to_value and gdbarch_value_to_register instead and drop the assertion if you don't think this patch is appropriate. It seems abstractly right, though - if we do not need a conversion, don't call the conversion functions. What do you think? Tested on x86_64-linux. -- Daniel Jacobowitz CodeSourcery 2007-10-17 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. * gdbint.texinfo (Register and Memory Data, Target Conditionals): Document that gdbarch_convert_register_p should return zero for no-op conversions. --- gdb/alpha-tdep.c | 9 ++------- gdb/amd64-tdep.c | 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 ++++----- 8 files changed, 47 insertions(+), 35 deletions(-) Index: src/gdb/amd64-tdep.c =================================================================== --- src.orig/gdb/amd64-tdep.c 2007-10-17 09:24:11.000000000 -0400 +++ src/gdb/amd64-tdep.c 2007-10-17 09:43:53.000000000 -0400 @@ -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 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); Index: src/gdb/alpha-tdep.c =================================================================== --- src.orig/gdb/alpha-tdep.c 2007-10-17 09:44:48.000000000 -0400 +++ src/gdb/alpha-tdep.c 2007-10-17 09:45:39.000000000 -0400 @@ -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_in 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_in case 4: alpha_lds (out, in); break; - case 8: - memcpy (out, in, 8); - break; default: error (_("Cannot store value in floating point register")); } Index: src/gdb/i386-tdep.c =================================================================== --- src.orig/gdb/i386-tdep.c 2007-10-17 09:42:50.000000000 -0400 +++ src/gdb/i386-tdep.c 2007-10-17 09:43:23.000000000 -0400 @@ -1880,7 +1880,7 @@ i386_convert_register_p (int regnum, str 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 Index: src/gdb/i387-tdep.c =================================================================== --- src.orig/gdb/i387-tdep.c 2007-10-17 09:39:14.000000000 -0400 +++ src/gdb/i387-tdep.c 2007-10-17 09:42:16.000000000 -0400 @@ -285,6 +285,25 @@ i387_print_float_info (struct gdbarch *g } +/* 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_inf 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_inf 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); } Index: src/gdb/i387-tdep.h =================================================================== --- src.orig/gdb/i387-tdep.h 2007-10-17 09:41:49.000000000 -0400 +++ src/gdb/i387-tdep.h 2007-10-17 09:41:55.000000000 -0400 @@ -55,6 +55,11 @@ extern void i387_print_float_info (struc 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. */ Index: src/gdb/ia64-tdep.c =================================================================== --- src.orig/gdb/ia64-tdep.c 2007-10-17 09:46:44.000000000 -0400 +++ src/gdb/ia64-tdep.c 2007-10-17 09:48:16.000000000 -0400 @@ -920,7 +920,8 @@ ia64_pseudo_register_write (struct gdbar 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 i 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 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); } Index: src/gdb/m68k-tdep.c =================================================================== --- src.orig/gdb/m68k-tdep.c 2007-10-17 09:49:27.000000000 -0400 +++ src/gdb/m68k-tdep.c 2007-10-17 09:50:04.000000000 -0400 @@ -171,7 +171,8 @@ m68k_convert_register_p (int regnum, str { 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_inf 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_inf 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); } Index: src/gdb/doc/gdbint.texinfo =================================================================== --- src.orig/gdb/doc/gdbint.texinfo 2007-10-17 09:51:43.000000000 -0400 +++ src/gdb/doc/gdbint.texinfo 2007-10-17 09:53:30.000000000 -0400 @@ -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 @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})