Re: [rfc] [0/9] Multi-target support: Fix show_mipsfpu_command crash

Ulrich Weigand
2007-10-30T21:31:58Z

> I'm aware of one bug that still needs to be fixed: "info set"
> crashes as show_mipsfpu_command unconditionally refers to
> gdbarch_tdep (current_gdbarch), and assumes it to be formatted
> as defined in mips-tdep.c. This is of course no longer guaranteed
> to be the case ... It is certainly possible that other problems
> of that sort still lurk.

This adds a simple fix for the mips problem. The show_mips_abi routine
already contains a check to recognize if called while the current architecture
is not mips. This patch adds the same check to show_mipsfpu_command.

With this patch in addition to the other patches in the series, I'm able
to run the testsuite on s390x-ibm-linux using an --enable-targets=all
build with no regressions.

Bye,
Ulrich

ChangeLog:

* mips-tdep.c (show_mipsfpu_command): Do not crash if called when
current architecture is not MIPS.

diff -urNp gdb-orig/gdb/mips-tdep.c gdb-head/gdb/mips-tdep.c
--- gdb-orig/gdb/mips-tdep.c 2007-10-23 23:32:16.000000000 +0200
+++ gdb-head/gdb/mips-tdep.c 2007-10-30 20:16:56.403345116 +0100
@@ -4643,6 +4643,15 @@ static void
show_mipsfpu_command (char *args, int from_tty)
{
char *fpu;
+
+ if (gdbarch_bfd_arch_info (current_gdbarch)->arch != bfd_arch_mips)
+ {
+ printf_unfiltered
+ ("The MIPS floating-point coprocessor is unknown "
+ "because the current architecture is not MIPS.\n");
+ return;
+ }
+
switch (MIPS_FPU_TYPE)
{