This is the mail archive of the gdb-patches@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: [RFA] mips-tdep.c: Make ``show mips abi'' more useful


On Feb 26,  4:31pm, Andrew Cagney wrote:

> [...] Can you just change the messages to 
> something more like that before committing?

Sure.  I've just committed the patch below.

Here's an example of it in use:

    (gdb) show mips abi
    The MIPS ABI is set automatically (currently "o32").
    (gdb) file hello-n64-shared 
    Reading symbols from hello-n64-shared...done.
    (gdb) show mips abi
    The MIPS ABI is set automatically (currently "n64").
    (gdb) set mips abi n32
    (gdb) show mips abi
    The MIPS ABI is assumed to be "n32" (due to user setting).
    (gdb) set mips abi auto
    (gdb) show mips abi
    The MIPS ABI is set automatically (currently "n64").
    (gdb) file hello-n32-shared  
    Load new symbol table from "hello-n32-shared"? (y or n) y

    Reading symbols from hello-n32-shared...done.
    (gdb) show mips abi
    The MIPS ABI is set automatically (currently "n32").

Note that this example only shows 2 of the 4 possible messages.  I
think it's unlikely that we'll see the other 2 messages displayed,
but they're there just in case...

Kevin

	* mips-tdep.c (show_mips_abi): New function.
	(_initialize_mips_tdep): Use show_mips_abi() to implement the
	command ``show mips abi''.

Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.163
diff -u -p -r1.163 mips-tdep.c
--- mips-tdep.c	20 Feb 2003 16:35:51 -0000	1.163
+++ mips-tdep.c	27 Feb 2003 01:10:07 -0000
@@ -6066,6 +6066,38 @@ mips_abi_update (char *ignore_args, int 
   gdbarch_update_p (info);
 }
 
+/* Print out which MIPS ABI is in use.  */
+
+static void
+show_mips_abi (char *ignore_args, int from_tty)
+{
+  if (gdbarch_bfd_arch_info (current_gdbarch)->arch != bfd_arch_mips)
+    printf_filtered (
+      "The MIPS ABI is unknown because the current architecture is not MIPS.\n");
+  else
+    {
+      enum mips_abi global_abi = global_mips_abi ();
+      enum mips_abi actual_abi = mips_abi (current_gdbarch);
+      const char *actual_abi_str = mips_abi_strings[actual_abi];
+
+      if (global_abi == MIPS_ABI_UNKNOWN)
+	printf_filtered ("The MIPS ABI is set automatically (currently \"%s\").\n",
+	                 actual_abi_str);
+      else if (global_abi == actual_abi)
+	printf_filtered (
+	  "The MIPS ABI is assumed to be \"%s\" (due to user setting).\n",
+	  actual_abi_str);
+      else
+	{
+	  /* Probably shouldn't happen...  */
+	  printf_filtered (
+	    "The (auto detected) MIPS ABI \"%s\" is in use even though the user setting was \"%s\".\n",
+	    actual_abi_str,
+	    mips_abi_strings[global_abi]);
+	}
+    }
+}
+
 static void
 mips_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
 {
@@ -6513,8 +6545,9 @@ This option can be set to one of:\n\
      "  eabi32\n"
      "  eabi64",
      &setmipscmdlist);
-  add_show_from_set (c, &showmipscmdlist);
   set_cmd_sfunc (c, mips_abi_update);
+  add_cmd ("abi", class_obscure, show_mips_abi,
+           "Show ABI in use by MIPS target", &showmipscmdlist);
 
   /* Let the user turn off floating point and set the fence post for
      heuristic_proc_start.  */


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