Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] Default gdb_bfd_open's fd parameter to -1
Date: Sun, 17 May 2020 19:04:48 +0100	[thread overview]
Message-ID: <20200517180450.14925-2-palves@redhat.com> (raw)
In-Reply-To: <20200517180450.14925-1-palves@redhat.com>

A following patch will add one more defaulted parameter.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* gdb_bfd.h: (gdb_bfd_open): Default to 'fd' parameter to -1.
	Adjust all callers.
---
 gdb/build-id.c                    | 2 +-
 gdb/compile/compile-object-load.c | 2 +-
 gdb/dwarf2/read.c                 | 4 ++--
 gdb/gdb_bfd.h                     | 3 ++-
 gdb/machoread.c                   | 4 ++--
 gdb/solib-darwin.c                | 2 +-
 gdb/symfile.c                     | 6 +++---
 gdb/windows-nat.c                 | 2 +-
 gdb/windows-tdep.c                | 2 +-
 9 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/gdb/build-id.c b/gdb/build-id.c
index 6e1f8b0f0cc..2f1afbd8e18 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -94,7 +94,7 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
     }
 
   /* We expect to be silent on the non-existing files.  */
-  gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1);
+  gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget);
 
   if (debug_bfd == NULL)
     {
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 55a46a31dba..76a9418dac0 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -604,7 +604,7 @@ compile_object_load (const compile_file_names &file_names,
   gdb::unique_xmalloc_ptr<char> filename
     (tilde_expand (file_names.object_file ()));
 
-  gdb_bfd_ref_ptr abfd (gdb_bfd_open (filename.get (), gnutarget, -1));
+  gdb_bfd_ref_ptr abfd (gdb_bfd_open (filename.get (), gnutarget));
   if (abfd == NULL)
     error (_("\"%s\": could not open as compiled module: %s"),
           filename.get (), bfd_errmsg (bfd_get_error ()));
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 719051bc5b2..0c6182bbf3b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2115,7 +2115,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
 
   /* First try the file name given in the section.  If that doesn't
      work, try to use the build-id instead.  */
-  gdb_bfd_ref_ptr dwz_bfd (gdb_bfd_open (filename, gnutarget, -1));
+  gdb_bfd_ref_ptr dwz_bfd (gdb_bfd_open (filename, gnutarget));
   if (dwz_bfd != NULL)
     {
       if (!build_id_verify (dwz_bfd.get (), buildid_len, buildid))
@@ -2138,7 +2138,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
       if (fd.get () >= 0)
 	{
 	  /* File successfully retrieved from server.  */
-	  dwz_bfd = gdb_bfd_open (alt_filename.get (), gnutarget, -1);
+	  dwz_bfd = gdb_bfd_open (alt_filename.get (), gnutarget);
 
 	  if (dwz_bfd == nullptr)
 	    warning (_("File \"%s\" from debuginfod cannot be opened as bfd"),
diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index ce72f78a23f..532520e0f7d 100644
--- a/gdb/gdb_bfd.h
+++ b/gdb/gdb_bfd.h
@@ -80,7 +80,8 @@ typedef gdb::ref_ptr<struct bfd, gdb_bfd_ref_policy> gdb_bfd_ref_ptr;
    bfd_get_filename will not be exactly NAME but rather NAME with
    TARGET_SYSROOT_PREFIX stripped.  */
 
-gdb_bfd_ref_ptr gdb_bfd_open (const char *name, const char *target, int fd);
+gdb_bfd_ref_ptr gdb_bfd_open (const char *name, const char *target,
+			      int fd = -1);
 
 /* Mark the CHILD BFD as being a member of PARENT.  Also, increment
    the reference count of CHILD.  Calling this function ensures that
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 4655b67f118..fb4e205088a 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -639,7 +639,7 @@ macho_symfile_read_all_oso (std::vector<oso_el> *oso_vector_ptr,
 
 	  /* Open the archive and check the format.  */
 	  gdb_bfd_ref_ptr archive_bfd (gdb_bfd_open (archive_name.c_str (),
-						     gnutarget, -1));
+						     gnutarget));
 	  if (archive_bfd == NULL)
 	    {
 	      warning (_("Could not open OSO archive file \"%s\""),
@@ -705,7 +705,7 @@ macho_symfile_read_all_oso (std::vector<oso_el> *oso_vector_ptr,
 	}
       else
 	{
-	  gdb_bfd_ref_ptr abfd (gdb_bfd_open (oso->name, gnutarget, -1));
+	  gdb_bfd_ref_ptr abfd (gdb_bfd_open (oso->name, gnutarget));
 	  if (abfd == NULL)
             warning (_("`%s': can't open to read symbols: %s."), oso->name,
                      bfd_errmsg (bfd_get_error ()));
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 03d91d1690a..e740a41fa4f 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -436,7 +436,7 @@ darwin_get_dyld_bfd ()
     return NULL;
 
   /* Create a bfd for the interpreter.  */
-  gdb_bfd_ref_ptr dyld_bfd (gdb_bfd_open (interp_name, gnutarget, -1));
+  gdb_bfd_ref_ptr dyld_bfd (gdb_bfd_open (interp_name, gnutarget));
   if (dyld_bfd != NULL)
     {
       gdb_bfd_ref_ptr sub
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 946443f07a8..fc984d81a1d 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1278,7 +1278,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
       gdb_flush (gdb_stdout);
     }
 
-  gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget, -1));
+  gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget));
 
   if (abfd == NULL)
     {
@@ -2042,7 +2042,7 @@ generic_load (const char *args, int from_tty)
     }
 
   /* Open the file for loading.  */
-  gdb_bfd_ref_ptr loadfile_bfd (gdb_bfd_open (filename.get (), gnutarget, -1));
+  gdb_bfd_ref_ptr loadfile_bfd (gdb_bfd_open (filename.get (), gnutarget));
   if (loadfile_bfd == NULL)
     perror_with_name (filename.get ());
 
@@ -2527,7 +2527,7 @@ reread_symbols (void)
 	    obfd_filename = bfd_get_filename (objfile->obfd);
 	    /* Open the new BFD before freeing the old one, so that
 	       the filename remains live.  */
-	    gdb_bfd_ref_ptr temp (gdb_bfd_open (obfd_filename, gnutarget, -1));
+	    gdb_bfd_ref_ptr temp (gdb_bfd_open (obfd_filename, gnutarget));
 	    objfile->obfd = temp.release ();
 	    if (objfile->obfd == NULL)
 	      error (_("Can't open %s to read symbols."), obfd_filename);
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index f52af9a1274..3452f6c827f 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -834,7 +834,7 @@ windows_make_so (const char *name, LPVOID load_addr)
     {
       asection *text = NULL;
 
-      gdb_bfd_ref_ptr abfd (gdb_bfd_open (so->so_name, "pei-i386", -1));
+      gdb_bfd_ref_ptr abfd (gdb_bfd_open (so->so_name, "pei-i386"));
 
       if (abfd == NULL)
 	return so;
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 086038af0d4..20a18e6b683 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -537,7 +537,7 @@ windows_xfer_shared_library (const char* so_name, CORE_ADDR load_addr,
 
   if (!text_offset)
     {
-      gdb_bfd_ref_ptr dll (gdb_bfd_open (so_name, gnutarget, -1));
+      gdb_bfd_ref_ptr dll (gdb_bfd_open (so_name, gnutarget));
       /* The following calls are OK even if dll is NULL.
 	 The default value 0x1000 is returned by pe_text_section_offset
 	 in that case.  */
-- 
2.14.5



  reply	other threads:[~2020-05-17 18:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 18:04 [PATCH 0/3] Make exec-file-mismatch compare build IDs Pedro Alves
2020-05-17 18:04 ` Pedro Alves [this message]
2020-05-17 18:04 ` [PATCH 2/3] Eliminate target_fileio_open_warn_if_slow Pedro Alves
2020-05-17 18:04 ` [PATCH 3/3] Make exec-file-mismatch compare build IDs Pedro Alves
2020-05-17 18:25   ` Eli Zaretskii
2020-05-18 13:52     ` Pedro Alves
2020-05-18 13:55   ` [PATCH v2 " Pedro Alves
2020-05-18 14:21     ` Philippe Waroquiers
2020-05-19 15:43       ` Pedro Alves
2020-05-19 16:04     ` Tom Tromey
2020-05-19 17:44       ` Pedro Alves
2020-05-21 13:32         ` Philippe Waroquiers
2020-05-21 14:02           ` Pedro Alves
2020-05-21 14:23             ` Philippe Waroquiers
2020-05-21 14:27               ` Pedro Alves

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=20200517180450.14925-2-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@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