[binutils-gdb] Remove 'fd' argument from exec_file_find

Tom Tromey via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24a9b21b889188a9db08be3701490d54559114a8

commit 24a9b21b889188a9db08be3701490d54559114a8
Author: Tom Tromey <[email protected]>
Date:   Mon Feb 23 12:39:34 2026 -0700

    Remove 'fd' argument from exec_file_find
    
    All callers of exec_file_find pass nullptr as the 'fd' argument, so
    this can be removed.
    
    Reviewed-By: Keith Seitz <[email protected]>

Diff:
---
 gdb/corelow.c |  2 +-
 gdb/exec.c    |  2 +-
 gdb/infrun.c  |  2 +-
 gdb/solib.c   | 11 ++++-------
 gdb/solib.h   |  3 +--
 5 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/gdb/corelow.c b/gdb/corelow.c
index 79b902118fa..954607134f4 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -421,7 +421,7 @@ core_target::build_file_mappings ()
 	 there is no sysroot, an equivalent (possibly more
 	 canonical) pathname will be provided.  */
       gdb::unique_xmalloc_ptr<char> expanded_fname
-	= exec_file_find (file_data.filename.c_str (), nullptr);
+	= exec_file_find (file_data.filename.c_str ());
 
       bool build_id_mismatch = false;
       if (expanded_fname != nullptr && file_data.build_id != nullptr)
diff --git a/gdb/exec.c b/gdb/exec.c
index 7aecdee16ee..0ad3944004d 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -335,7 +335,7 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
     }
 
   gdb::unique_xmalloc_ptr<char> exec_file_host
-    = exec_file_find (exec_file_target, NULL);
+    = exec_file_find (exec_file_target);
   if (exec_file_host == nullptr)
     {
       warning (_("No executable has been specified, and target executable "
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 592f9197cd5..9864b5bbdec 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1306,7 +1306,7 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
   breakpoint_init_inferior (current_inferior (), inf_execd);
 
   gdb::unique_xmalloc_ptr<char> exec_file_host
-    = exec_file_find (exec_file_target, nullptr);
+    = exec_file_find (exec_file_target);
 
   /* If we were unable to map the executable target pathname onto a host
      pathname, tell the user that.  Otherwise GDB's subsequent behavior
diff --git a/gdb/solib.c b/gdb/solib.c
index 22937c0fc06..2cf9e17738d 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -319,11 +319,10 @@ solib_find_1 (const char *in_pathname, int *fd, bool is_solib)
 }
 
 /* Return the full pathname of the main executable, or NULL if not
-   found.  If FD is non-NULL, *FD is set to either -1 or an open file
-   handle for the main executable.  */
+   found.  */
 
 gdb::unique_xmalloc_ptr<char>
-exec_file_find (const char *in_pathname, int *fd)
+exec_file_find (const char *in_pathname)
 {
   gdb::unique_xmalloc_ptr<char> result;
   const char *fskind = effective_target_file_system_kind ();
@@ -333,7 +332,7 @@ exec_file_find (const char *in_pathname, int *fd)
 
   if (!gdb_sysroot.empty () && IS_TARGET_ABSOLUTE_PATH (fskind, in_pathname))
     {
-      result = solib_find_1 (in_pathname, fd, false);
+      result = solib_find_1 (in_pathname, nullptr, false);
 
       if (result == NULL && fskind == file_system_kind_dos_based)
 	{
@@ -343,7 +342,7 @@ exec_file_find (const char *in_pathname, int *fd)
 	  strcpy (new_pathname, in_pathname);
 	  strcat (new_pathname, ".exe");
 
-	  result = solib_find_1 (new_pathname, fd, false);
+	  result = solib_find_1 (new_pathname, nullptr, false);
 	}
     }
   else
@@ -358,8 +357,6 @@ exec_file_find (const char *in_pathname, int *fd)
 
       if (!source_full_path_of (in_pathname, &result))
 	result = make_unique_xstrdup (in_pathname);
-      if (fd != NULL)
-	*fd = -1;
     }
 
   return result;
diff --git a/gdb/solib.h b/gdb/solib.h
index 4709669c54e..564655c4a57 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -297,8 +297,7 @@ protected:
 using solib_ops_up = std::unique_ptr<solib_ops>;
 
 /* Find main executable binary file.  */
-extern gdb::unique_xmalloc_ptr<char> exec_file_find (const char *in_pathname,
-						     int *fd);
+extern gdb::unique_xmalloc_ptr<char> exec_file_find (const char *in_pathname);
 
 /* Find shared library binary file.  */
 extern gdb::unique_xmalloc_ptr<char> solib_find (const char *in_pathname,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.