public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Revert "[gdb] Fix warning in foreach_arch selftests"
Date: Fri,  3 Jun 2022 13:34:55 +0000 (GMT)	[thread overview]
Message-ID: <20220603133455.DC6EC385702E@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0e02119e65b566cad575cc57fe423dadab855a56

commit 0e02119e65b566cad575cc57fe423dadab855a56
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Jun 3 15:34:50 2022 +0200

    Revert "[gdb] Fix warning in foreach_arch selftests"
    
    This reverts commit fc18b1c5afd ("[gdb] Fix warning in foreach_arch
    selftests").
    
    The commit introduced regressions for an --enable-targets=all build:
    ...
    Running selftest print_one_insn::A6.^M
    Self test failed: Cannot access memory at address 0x0^M
    ...
    and while investigating those I realized that the commit fc18b1c5afd
    complicates things by trying to set the current osabi.
    
    So, revert the patch in preparation for a simpler solution.
    
    Tested on x86_64-linux.

Diff:
---
 gdb/osabi.c         | 50 ++++++++++++--------------------------------------
 gdb/osabi.h         | 13 -------------
 gdb/selftest-arch.c | 18 +-----------------
 3 files changed, 13 insertions(+), 68 deletions(-)

diff --git a/gdb/osabi.c b/gdb/osabi.c
index 776e62069e5..bbd7635532f 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -32,7 +32,7 @@
 #endif
 
 /* State for the "set osabi" command.  */
-static enum gdb_osabi_mode user_osabi_state;
+static enum { osabi_auto, osabi_default, osabi_user } user_osabi_state;
 static enum gdb_osabi user_selected_osabi;
 static const char *gdb_osabi_available_names[GDB_OSABI_INVALID + 3] = {
   "auto",
@@ -595,48 +595,15 @@ generic_elf_osabi_sniffer (bfd *abfd)
   return osabi;
 }
 \f
-/* See osabi.h.  */
-
-void
-set_osabi (enum gdb_osabi_mode mode, enum gdb_osabi osabi)
-{
-  if (mode == osabi_auto)
-    user_osabi_state = osabi_auto;
-  else if (mode == osabi_default)
-    {
-      user_selected_osabi = GDB_OSABI_DEFAULT;
-      user_osabi_state = osabi_user;
-    }
-  else
-    {
-      user_selected_osabi = osabi;
-      user_osabi_state = osabi_user;
-    }
-
-  /* NOTE: At some point (true multiple architectures) we'll need to be more
-     graceful here.  */
-  gdbarch_info info;
-  if (! gdbarch_update_p (info))
-    internal_error (__FILE__, __LINE__, _("Updating OS ABI failed."));
-}
-
-/* See osabi.h.  */
-
-void
-get_osabi (enum gdb_osabi_mode &mode, enum gdb_osabi &osabi)
-{
-  mode = user_osabi_state;
-  osabi = user_selected_osabi;
-}
-
 static void
 set_osabi (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (strcmp (set_osabi_string, "auto") == 0)
-    set_osabi (osabi_auto, GDB_OSABI_INVALID);
+    user_osabi_state = osabi_auto;
   else if (strcmp (set_osabi_string, "default") == 0)
     {
-      set_osabi (osabi_default, GDB_OSABI_INVALID);
+      user_selected_osabi = GDB_OSABI_DEFAULT;
+      user_osabi_state = osabi_user;
     }
   else
     {
@@ -648,7 +615,8 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c)
 
 	  if (strcmp (set_osabi_string, gdbarch_osabi_name (osabi)) == 0)
 	    {
-	      set_osabi (osabi_user, osabi);
+	      user_selected_osabi = osabi;
+	      user_osabi_state = osabi_user;
 	      break;
 	    }
 	}
@@ -657,6 +625,12 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c)
 			_("Invalid OS ABI \"%s\" passed to command handler."),
 			set_osabi_string);
     }
+
+  /* NOTE: At some point (true multiple architectures) we'll need to be more
+     graceful here.  */
+  gdbarch_info info;
+  if (! gdbarch_update_p (info))
+    internal_error (__FILE__, __LINE__, _("Updating OS ABI failed."));
 }
 
 static void
diff --git a/gdb/osabi.h b/gdb/osabi.h
index 3737a77d50e..be016732cbc 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -50,13 +50,6 @@ enum gdb_osabi
   GDB_OSABI_INVALID		/* keep this last */
 };
 
-enum gdb_osabi_mode
-{
-  osabi_auto,
-  osabi_default,
-  osabi_user
-};
-
 /* Register an OS ABI sniffer.  Each arch/flavour may have more than
    one sniffer.  This is used to e.g. differentiate one OS's a.out from
    another.  The first sniffer to return something other than
@@ -96,10 +89,4 @@ const char *osabi_triplet_regexp (enum gdb_osabi osabi);
 void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *,
 					       enum gdb_osabi *);
 
-/* Set osabi to MODE/OSABI.  */
-extern void set_osabi (enum gdb_osabi_mode mode, enum gdb_osabi osabi);
-
-/* Return current osabi setting in MODE/OSABI.  */
-extern void get_osabi (enum gdb_osabi_mode &mode, enum gdb_osabi &osabi);
-
 #endif /* OSABI_H */
diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c
index a4d9de5a74d..f434da718d5 100644
--- a/gdb/selftest-arch.c
+++ b/gdb/selftest-arch.c
@@ -66,28 +66,12 @@ foreach_arch_test_generator (const std::string &name,
       auto test_fn
 	= ([=] ()
 	   {
-	     /* Prevent warnings when setting architecture with current osabi
-		settings, like:
-		  A handler for the OS ABI "GNU/Linux" is not built into this
-		  configuration of GDB.  Attempting to continue with the
-		  default aarch64:ilp32 settings.  */
-	     enum gdb_osabi_mode mode;
-	     enum gdb_osabi osabi;
-	     get_osabi (mode, osabi);
-
-	     set_osabi (osabi_user, GDB_OSABI_NONE);
-	     SCOPE_EXIT
-	       {
-		 reset ();
-		 set_osabi (mode, osabi);
-	       };
-
 	     struct gdbarch_info info;
 	     info.bfd_arch_info = bfd_scan_arch (arch);
 	     struct gdbarch *gdbarch = gdbarch_find_by_info (info);
 	     SELF_CHECK (gdbarch != NULL);
-
 	     function (gdbarch);
+	     reset ();
 	   });
 
       tests.emplace_back (string_printf ("%s::%s", name.c_str (), arch),


                 reply	other threads:[~2022-06-03 13:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220603133455.DC6EC385702E@sourceware.org \
    --to=vries@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).