Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH RFC 5/6] Call ext_lang_find_objfile_from_buildid from solib_bfd_fopen
Date: Thu, 22 Oct 2026 12:28:15 -0600	[thread overview]
Message-ID: <20261022-android-apk-file-v1-5-8444bb5f832a@adacore.com> (raw)
In-Reply-To: <20261022-android-apk-file-v1-0-8444bb5f832a@adacore.com>

Change solib_bfd_fopen to call ext_lang_find_objfile_from_buildid.
This way, if the solib is not found directly, Python is given a chance
to find the file.
---
 gdb/solib.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/gdb/solib.c b/gdb/solib.c
index 7ea3084bf48..96f2597d120 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -386,7 +386,23 @@ solib_find (const char *in_pathname, int *fd)
 gdb_bfd_ref_ptr
 solib_bfd_fopen (const char *pathname, int fd)
 {
-  gdb_bfd_ref_ptr abfd (gdb_bfd_open (pathname, gnutarget, fd));
+  gdb_bfd_ref_ptr abfd = gdb_bfd_open (pathname, gnutarget, fd);
+  if (abfd != nullptr)
+    return abfd;
+
+  if (fd == -1)
+    {
+      if (is_target_filename (pathname))
+	pathname += strlen (TARGET_SYSROOT_PREFIX);
+
+      ext_lang_missing_file_result ext_result
+	= ext_lang_find_objfile_from_buildid (current_program_space, nullptr,
+					      pathname);
+      if (ext_result.bfd () != nullptr)
+	abfd = ext_result.bfd ();
+      else if (!ext_result.filename ().empty ())
+	abfd = gdb_bfd_open (ext_result.filename ().c_str (), gnutarget);
+    }
 
   if (abfd == NULL)
     error (_("Could not open `%ps' as an executable file: %s"),

-- 
2.56.0


  parent reply	other threads:[~2026-10-22 18:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 18:28 [PATCH RFC 0/6] Handle Android APK files Tom Tromey
2026-10-22 18:28 ` [PATCH RFC 1/6] Add py-file.c Tom Tromey
2026-10-22 18:28 ` [PATCH RFC 2/6] Add py-iovec.c Tom Tromey
2026-10-22 18:28 ` [PATCH RFC 3/6] Allow missing build-id when finding an objfile Tom Tromey
2026-10-22 18:28 ` [PATCH RFC 4/6] Allow missing objfile handler to return a file Tom Tromey
2026-10-22 18:28 ` Tom Tromey [this message]
2026-10-22 18:28 ` [PATCH RFC 6/6] Add gdb.handler.android module Tom Tromey

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=20261022-android-apk-file-v1-5-8444bb5f832a@adacore.com \
    --to=tromey@adacore.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