This is the mail archive of the gdb-patches@sourceware.org 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]

[commit] Fix ARM FPU detection


A bunch of ARM OSABI handlers have this:

  if (tdep->fp_model == ARM_FLOAT_AUTO)
    tdep->fp_model = SOMETHING_ELSE;

But right now we pick a default in the ARM_FLOAT_AUTO case long before
we call the OSABI handlers so this is never reached.  To see, build an
arm-linux gdb and load a hard float (thus, untagged) binary.  "show
arm fpu" will report softfpa, from the code I'm deleting below, rather
than the expected fpa, from arm-linux-tdep.c.

This patch adjusts the initialization sequence so that if no fp model
markings are found, we use the default from any architecture returned
by gdbarch_list_lookup_by_info.  That will only return architectures
with the same OSABI, unlike the current code.

Tested manually on fpa, softfpa, vfp, and softvfp old-ABI binaries.
I also ran the testsuite on arm-none-linux-gnueabi for good measure.
Checked in.

-- 
Daniel Jacobowitz
CodeSourcery

2007-08-14  Daniel Jacobowitz  <dan@codesourcery.com>

	* arm-tdep.c (arm_gdbarch_init): Allow unknown ABI and FPU settings
	to match any gdbarch with matching OSABI.  Set default ABI and FPU
	after running the OSABI handler.

Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.239
diff -u -p -r1.239 arm-tdep.c
--- arm-tdep.c	19 Jun 2007 22:44:13 -0000	1.239
+++ arm-tdep.c	14 Aug 2007 13:44:25 -0000
@@ -2835,39 +2835,17 @@ arm_gdbarch_init (struct gdbarch_info in
 	}
     }
 
-  /* Now that we have inferred any architecture settings that we
-     can, try to inherit from the last ARM ABI.  */
-  if (arches != NULL)
-    {
-      if (arm_abi == ARM_ABI_AUTO)
-	arm_abi = gdbarch_tdep (arches->gdbarch)->arm_abi;
-
-      if (fp_model == ARM_FLOAT_AUTO)
-	fp_model = gdbarch_tdep (arches->gdbarch)->fp_model;
-    }
-  else
-    {
-      /* There was no prior ARM architecture; fill in default values.  */
-
-      if (arm_abi == ARM_ABI_AUTO)
-	arm_abi = ARM_ABI_APCS;
-
-      /* We used to default to FPA for generic ARM, but almost nobody
-	 uses that now, and we now provide a way for the user to force
-	 the model.  So default to the most useful variant.  */
-      if (fp_model == ARM_FLOAT_AUTO)
-	fp_model = ARM_FLOAT_SOFT_FPA;
-    }
-
   /* If there is already a candidate, use it.  */
   for (best_arch = gdbarch_list_lookup_by_info (arches, &info);
        best_arch != NULL;
        best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
     {
-      if (arm_abi != gdbarch_tdep (best_arch->gdbarch)->arm_abi)
+      if (arm_abi != ARM_ABI_AUTO
+	  && arm_abi != gdbarch_tdep (best_arch->gdbarch)->arm_abi)
 	continue;
 
-      if (fp_model != gdbarch_tdep (best_arch->gdbarch)->fp_model)
+      if (fp_model != ARM_FLOAT_AUTO
+	  && fp_model != gdbarch_tdep (best_arch->gdbarch)->fp_model)
 	continue;
 
       /* Found a match.  */
@@ -2997,12 +2975,23 @@ arm_gdbarch_init (struct gdbarch_info in
   /* Now we have tuned the configuration, set a few final things,
      based on what the OS ABI has told us.  */
 
+  /* If the ABI is not otherwise marked, assume the old GNU APCS.  EABI
+     binaries are always marked.  */
+  if (tdep->arm_abi == ARM_ABI_AUTO)
+    tdep->arm_abi = ARM_ABI_APCS;
+
+  /* We used to default to FPA for generic ARM, but almost nobody
+     uses that now, and we now provide a way for the user to force
+     the model.  So default to the most useful variant.  */
+  if (tdep->fp_model == ARM_FLOAT_AUTO)
+    tdep->fp_model = ARM_FLOAT_SOFT_FPA;
+
   if (tdep->jb_pc >= 0)
     set_gdbarch_get_longjmp_target (gdbarch, arm_get_longjmp_target);
 
   /* Floating point sizes and format.  */
   set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
-  if (fp_model == ARM_FLOAT_SOFT_FPA || fp_model == ARM_FLOAT_FPA)
+  if (tdep->fp_model == ARM_FLOAT_SOFT_FPA || tdep->fp_model == ARM_FLOAT_FPA)
     {
       set_gdbarch_double_format
 	(gdbarch, floatformats_ieee_double_littlebyte_bigword);


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