]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: query inferior's filesystem for build-id debug files
authorFabian Kilger <kilger@sec.in.tum.de>
Wed, 11 Jun 2025 20:52:17 +0000 (22:52 +0200)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 17 Jun 2025 20:37:11 +0000 (21:37 +0100)
This fixes a bug related to build-id files with linux namespaces.
Specifically, we expect the debug files to be present inside the container,
thus the container filesystem should be queried if the program is running
inside one.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32956
Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/build-id.c

index f1375626f1b5250908381bfc8693d153d51ecaf7..0ecd79fb869b7675d3c7753db1087e50431bb269 100644 (file)
@@ -29,6 +29,7 @@
 #include "gdbsupport/scoped_fd.h"
 #include "debuginfod-support.h"
 #include "extension.h"
+#include "inferior.h"
 
 /* See build-id.h.  */
 
@@ -128,7 +129,8 @@ build_id_to_debug_bfd_1 (const std::string &original_link,
          if (supports_target_stat != TRIBOOL_FALSE)
            {
              struct stat sb;
-             int res = target_fileio_lstat (nullptr, link_on_target, &sb,
+             int res = target_fileio_lstat (current_inferior (),
+                                            link_on_target, &sb,
                                             &target_errno);
 
              if (res != 0 && target_errno != FILEIO_ENOSYS)
@@ -157,7 +159,7 @@ build_id_to_debug_bfd_1 (const std::string &original_link,
                 the path doesn't exist, but we just assume that anything
                 other than EINVAL indicates the path doesn't exist.  */
              std::optional<std::string> link_target
-               = target_fileio_readlink (nullptr, link_on_target,
+               = target_fileio_readlink (current_inferior (), link_on_target,
                                          &target_errno);
              if (link_target.has_value ()
                  || target_errno == FILEIO_EINVAL)