diff mbox

[committed] MIPS: Factor out FPU type naming in `gdbarch' debug

Message ID alpine.DEB.2.00.1708021550330.17596@tp.orcam.me.uk
State Committed
Headers show

Commit Message

Maciej W. Rozycki Aug. 2, 2017, 3:41 p.m. UTC
Replace chains of conditional expressions used in target-dependent MIPS 
`gdbarch' debug output to get a textual name of the FPU type with calls 
to a helper decoder function, improving code readability.  No functional 
change.

	gdb/
	* mips-tdep.c (mips_fpu_type_str): New function.
	(mips_dump_tdep): Call it.
---
 gdb/mips-tdep.c |   28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

gdb-mips-dump-tdep-fpu-type.diff
diff mbox

Patch

Index: binutils/gdb/mips-tdep.c
===================================================================
--- binutils.orig/gdb/mips-tdep.c	2017-08-02 15:53:01.525265847 +0100
+++ binutils/gdb/mips-tdep.c	2017-08-02 16:32:59.908428854 +0100
@@ -8907,6 +8907,24 @@  show_mips_compression (struct ui_file *f
 		    value);
 }
 
+/* Return a textual name for MIPS FPU type FPU_TYPE.  */
+
+static const char *
+mips_fpu_type_str (enum mips_fpu_type fpu_type)
+{
+  switch (fpu_type)
+    {
+    case MIPS_FPU_NONE:
+      return "none";
+    case MIPS_FPU_SINGLE:
+      return "single";
+    case MIPS_FPU_DOUBLE:
+      return "double";
+    default:
+      return "???";
+    }
+}
+
 static void
 mips_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
@@ -8957,19 +8975,13 @@  mips_dump_tdep (struct gdbarch *gdbarch,
   fprintf_unfiltered (file,
 		      "mips_dump_tdep: MIPS_DEFAULT_FPU_TYPE = %d (%s)\n",
 		      MIPS_DEFAULT_FPU_TYPE,
-		      (MIPS_DEFAULT_FPU_TYPE == MIPS_FPU_NONE ? "none"
-		       : MIPS_DEFAULT_FPU_TYPE == MIPS_FPU_SINGLE ? "single"
-		       : MIPS_DEFAULT_FPU_TYPE == MIPS_FPU_DOUBLE ? "double"
-		       : "???"));
+		      mips_fpu_type_str (MIPS_DEFAULT_FPU_TYPE));
   fprintf_unfiltered (file, "mips_dump_tdep: MIPS_EABI = %d\n",
 		      MIPS_EABI (gdbarch));
   fprintf_unfiltered (file,
 		      "mips_dump_tdep: MIPS_FPU_TYPE = %d (%s)\n",
 		      MIPS_FPU_TYPE (gdbarch),
-		      (MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_NONE ? "none"
-		       : MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_SINGLE ? "single"
-		       : MIPS_FPU_TYPE (gdbarch) == MIPS_FPU_DOUBLE ? "double"
-		       : "???"));
+		      mips_fpu_type_str (MIPS_FPU_TYPE (gdbarch)));
 }
 
 extern initialize_file_ftype _initialize_mips_tdep; /* -Wmissing-prototypes */