This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GDB broken on MIPS targets with unmarked binaries


On Wed, Jun 05, 2002 at 05:41:42PM -0400, Andrew Cagney wrote:
> >The expansion appears to be:
> >>tdep->mips_fp_register_double = (((((38) >= 38 && (38) < 38 +32) ?
> >>	builtin_type_float : ((38) == 32 ) ?
> >>        builtin_type_uint32 : ((38) >= 70 && (38) <= 89) ?
> >>	builtin_type_uint32 :
> >>        builtin_type_int))->main_type->length == 8);
> >>
> >>I can't see any reason for it to crash; I haven't reproduced this
> >>locally yet, although I'm working on it.  The above expansion came from
> >>the second person to mention this to me.
> >
> >
> >I believe you're right about the patch at fault, though I don't know
> >what to do about it.  This makes builtin_type_int == NULL during
> >evaluation of that expression, along with all the others.
> 
> The patch isn't `at fault' - it is detecting a fault in mips_tdep.c :-) 
>  builtin_type_float would have contained a value from the previously 
> selected ISA.
> 
> That code is trying to reverse engineer the header files to figure out 
> what the default should be for the given target.
> 
> I think better would be to is set mips_fp_register_double=-1 and then 
> change FP_REGISTER_DOUBLE to a real function (gdb multi-arch can now be 
> assumed) that, when -1, apply the above logic (and even update the result).

How about setting something in each header that redefines
REGISTER_VIRTUAL_TYPE, instead?  I think that's much clearer, and when
we multi-arch the targets which do this it will transition more
naturally to setting it at gdbarch_init time.  gdbarch_data() is a very
nice tool, but this is the wrong kind of nail, IMO.

I'm testing this patch.  Yes, it's a little bit of a step backwards for
multi-arching, but I still think it's correct; rather than "reverse
engineer the header files to figure out the default", let's have the
header files tell us what it is.

It works fine in my testing; OK to commit, or would you prefer a
different way?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2002-06-06  Daniel Jacobowitz  <drow@mvista.com>

	* mips-tdep.c (FP_REGISTER_DOUBLE):  Delete obsolete definition.
	Define unconditionally.
	(mips_gdbarch_init): Use MIPS_FP_DOUBLE.
	* config/mips/tm-mips.h (MIPS_FP_DOUBLE): New macro.
	* config/mips/tm-irix5.h (MIPS_FP_DOUBLE): New macro.
	* config/mips/tm-irix6.h (MIPS_FP_DOUBLE): New macro.
	* config/mips/tm-mips64.h (MIPS_FP_DOUBLE): New macro.

Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.74
diff -u -p -u -r1.74 mips-tdep.c
--- mips-tdep.c	21 May 2002 15:36:03 -0000	1.74
+++ mips-tdep.c	6 Jun 2002 17:34:17 -0000
@@ -108,11 +108,6 @@ static int mips_fpu_type_auto = 1;
 static enum mips_fpu_type mips_fpu_type = MIPS_DEFAULT_FPU_TYPE;
 #define MIPS_FPU_TYPE mips_fpu_type
 
-/* Do not use "TARGET_IS_MIPS64" to test the size of floating point registers */
-#ifndef FP_REGISTER_DOUBLE
-#define FP_REGISTER_DOUBLE (REGISTER_VIRTUAL_SIZE(FP0_REGNUM) == 8)
-#endif
-
 static int mips_debug = 0;
 
 /* MIPS specific per-architecture information */
@@ -212,10 +207,7 @@ mips2_fp_compat (void)
    form double-precision values).  Do not use "TARGET_IS_MIPS64" to
    determine if the ABI is using double-precision registers.  See also
    MIPS_FPU_TYPE. */
-#if GDB_MULTI_ARCH
-#undef FP_REGISTER_DOUBLE
 #define FP_REGISTER_DOUBLE (gdbarch_tdep (current_gdbarch)->mips_fp_register_double)
-#endif
 
 /* Does the caller allocate a ``home'' for each register used in the
    function call?  The N32 ABI and MIPS_EABI do not, the others do. */
@@ -4332,7 +4324,7 @@ mips_gdbarch_init (struct gdbarch_info i
       tdep->mips_abi_string = "default";
       tdep->mips_default_saved_regsize = MIPS_REGSIZE;
       tdep->mips_default_stack_argsize = MIPS_REGSIZE;
-      tdep->mips_fp_register_double = (REGISTER_VIRTUAL_SIZE (FP0_REGNUM) == 8);
+      tdep->mips_fp_register_double = MIPS_FP_DOUBLE;
       tdep->mips_last_arg_regnum = A0_REGNUM + 8 - 1;
       tdep->mips_last_fp_arg_regnum = FPA0_REGNUM + 8 - 1;
       tdep->mips_regs_have_home_p = 1;
Index: config/mips/tm-irix5.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-irix5.h,v
retrieving revision 1.6
diff -u -p -u -r1.6 tm-irix5.h
--- config/mips/tm-irix5.h	6 Mar 2001 08:21:32 -0000	1.6
+++ config/mips/tm-irix5.h	6 Jun 2002 17:34:17 -0000
@@ -41,6 +41,9 @@
       ((N) - FP0_REGNUM) * sizeof(double) : \
       32 * sizeof(double) + ((N) - 32) * MIPS_REGSIZE)
 
+#undef MIPS_FP_DOUBLE
+#define MIPS_FP_DOUBLE 1
+
 #undef  REGISTER_VIRTUAL_TYPE
 #define REGISTER_VIRTUAL_TYPE(N) \
 	(((N) >= FP0_REGNUM && (N) < FP0_REGNUM+32) ? builtin_type_double \
Index: config/mips/tm-irix6.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-irix6.h,v
retrieving revision 1.1
diff -u -p -u -r1.1 tm-irix6.h
--- config/mips/tm-irix6.h	7 Jun 2001 15:57:57 -0000	1.1
+++ config/mips/tm-irix6.h	6 Jun 2002 17:34:17 -0000
@@ -88,6 +88,9 @@
       ((N) - FP0_REGNUM) * sizeof(double) : \
       32 * sizeof(double) + ((N) - 32) * MIPS_REGSIZE)
 
+#undef MIPS_FP_DOUBLE
+#define MIPS_FP_DOUBLE 1
+
 #undef  REGISTER_VIRTUAL_TYPE
 #define REGISTER_VIRTUAL_TYPE(N) \
 	(((N) >= FP0_REGNUM && (N) < FP0_REGNUM+32) ? builtin_type_double \
Index: config/mips/tm-mips.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-mips.h,v
retrieving revision 1.25
diff -u -p -u -r1.25 tm-mips.h
--- config/mips/tm-mips.h	10 Feb 2002 07:17:17 -0000	1.25
+++ config/mips/tm-mips.h	6 Jun 2002 17:34:19 -0000
@@ -89,6 +89,12 @@ extern int in_sigtramp (CORE_ADDR, char 
 #define MIPS_REGSIZE 4
 #endif
 
+/* Defined to 1 if this architecture uses double-precision floating point
+   registers.  */
+#ifndef MIPS_FP_DOUBLE
+#define MIPS_FP_DOUBLE 0
+#endif
+
 /* Number of machine registers */
 
 #ifndef NUM_REGS
Index: config/mips/tm-mips64.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-mips64.h,v
retrieving revision 1.5
diff -u -p -u -r1.5 tm-mips64.h
--- config/mips/tm-mips64.h	5 Jun 2002 19:18:25 -0000	1.5
+++ config/mips/tm-mips64.h	6 Jun 2002 17:34:19 -0000
@@ -22,6 +22,9 @@
 /* Use eight byte registers.  */
 #define MIPS_REGSIZE 8
 
+/* Use double-precision floating point registers.  */
+#define MIPS_FP_DOUBLE 1
+
 /* define 8 byte register type */
 #define REGISTER_VIRTUAL_TYPE(N) \
         (((N) >= FP0_REGNUM && (N) < FP0_REGNUM+32) ? builtin_type_double \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]