diff options
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r-- | gdb/linux-nat.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 1727a06..f317927 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1,6 +1,6 @@ /* GNU/Linux native-dependent code common to multiple platforms. - Copyright (C) 2001-2024 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -51,17 +51,13 @@ #include <pwd.h> #include <sys/types.h> #include <dirent.h> -#include "xml-support.h" #include <sys/vfs.h> -#include "solib.h" #include "nat/linux-osdata.h" #include "linux-tdep.h" -#include "symfile.h" #include "gdbsupport/agent.h" #include "tracepoint.h" #include "target-descriptions.h" #include "gdbsupport/filestuff.h" -#include "objfiles.h" #include "nat/linux-namespaces.h" #include "gdbsupport/block-signals.h" #include "gdbsupport/fileio.h" @@ -133,7 +129,7 @@ process things as in sync mode, except that the we never block in sigsuspend. While processing an event, we may end up momentarily blocked in -waitpid calls. Those waitpid calls, while blocking, are guarantied to +waitpid calls. Those waitpid calls, while blocking, are guaranteed to return quickly. E.g., in all-stop mode, before reporting to the core that an LWP hit a breakpoint, all LWPs are stopped by sending them SIGSTOP, and synchronously waiting for the SIGSTOP to be reported. @@ -702,7 +698,7 @@ lwp_lwpid_htab_add_lwp (struct lwp_info *lp) /* Head of doubly-linked list of known LWPs. Sorted by reverse creation order. This order is assumed in some cases. E.g., - reaping status after killing alls lwps of a process: the leader LWP + reaping status after killing all lwps of a process: the leader LWP must be reaped last. */ static intrusive_list<lwp_info> lwp_list; @@ -2129,7 +2125,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status) open_proc_mem_file (lp->ptid); ourstatus->set_execd - (make_unique_xstrdup (linux_proc_pid_to_exec_file (pid))); + (make_unique_xstrdup (linux_target->pid_to_exec_file (pid))); /* The thread that execed must have been resumed, but, when a thread execs, it changes its tid to the tgid, and the old @@ -4000,7 +3996,14 @@ linux_nat_target::thread_name (struct thread_info *thr) const char * linux_nat_target::pid_to_exec_file (int pid) { - return linux_proc_pid_to_exec_file (pid); + /* If there's no sysroot. Or the sysroot is just 'target:' and the + inferior is in the same mount namespce, then we can consider the + filesystem local. */ + bool local_fs = (gdb_sysroot.empty () + || (gdb_sysroot == TARGET_SYSROOT_PREFIX + && linux_ns_same (pid, LINUX_NS_MNT))); + + return linux_proc_pid_to_exec_file (pid, local_fs); } /* Object representing an /proc/PID/mem open file. We keep one such @@ -4585,6 +4588,20 @@ linux_nat_target::fileio_open (struct inferior *inf, const char *filename, return fd; } +/* Implementation of to_fileio_lstat. */ + +int +linux_nat_target::fileio_lstat (struct inferior *inf, const char *filename, + struct stat *sb, fileio_error *target_errno) +{ + int r = linux_mntns_lstat (linux_nat_fileio_pid_of (inf), filename, sb); + + if (r == -1) + *target_errno = host_to_fileio_error (errno); + + return r; +} + /* Implementation of to_fileio_readlink. */ std::optional<std::string> @@ -4707,9 +4724,7 @@ maintenance_info_lwps (const char *arg, int from_tty) } } -void _initialize_linux_nat (); -void -_initialize_linux_nat () +INIT_GDB_FILE (linux_nat) { add_setshow_boolean_cmd ("linux-nat", class_maintenance, &debug_linux_nat, _("\ |