This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] MIPS: Factor out FPU type naming in `gdbarch' debug
- From: Maciej W.Rozycki <macro at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 2 Aug 2017 15:41:08 -0000
- Subject: [binutils-gdb] MIPS: Factor out FPU type naming in `gdbarch' debug
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a4f320fd1b535bb80dc9a3ba7c50ee0061ec0c6f
commit a4f320fd1b535bb80dc9a3ba7c50ee0061ec0c6f
Author: Maciej W. Rozycki <macro@imgtec.com>
Date: Wed Aug 2 16:40:16 2017 +0100
MIPS: Factor out FPU type naming in `gdbarch' debug
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.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/mips-tdep.c | 28 ++++++++++++++++++++--------
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 90c6f5f..98f67e2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-02 Maciej W. Rozycki <macro@imgtec.com>
+
+ * mips-tdep.c (mips_fpu_type_str): New function.
+ (mips_dump_tdep): Call it.
+
2017-08-01 Maciej W. Rozycki <macro@imgtec.com>
* mips-tdep.c (mips_gdbarch_init): Use MIPS_FPU_TYPE to access
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 75d54d0..8bd11ee 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -8907,6 +8907,24 @@ show_mips_compression (struct ui_file *file, int from_tty,
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, struct ui_file *file)
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 */