diff options
Diffstat (limited to 'gdbserver/linux-low.cc')
-rw-r--r-- | gdbserver/linux-low.cc | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 65268a6..98e5815 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -1,5 +1,5 @@ /* Low level interface to ptrace, for the remote server for GDB. - Copyright (C) 1995-2024 Free Software Foundation, Inc. + Copyright (C) 1995-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -46,7 +46,6 @@ #include <langinfo.h> #include <iconv.h> #include "gdbsupport/filestuff.h" -#include "gdbsupport/gdb-safe-ctype.h" #include "tracepoint.h" #include <inttypes.h> #include "gdbsupport/common-inferior.h" @@ -751,7 +750,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, /* Set the event status. */ event_lwp->waitstatus.set_execd (make_unique_xstrdup - (linux_proc_pid_to_exec_file (event_thr->id.lwp ()))); + (pid_to_exec_file (event_thr->id.lwp ()))); /* Mark the exec status as pending. */ event_lwp->stopped = 1; @@ -5006,23 +5005,31 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, if (res < 0) { if (errno == EIO - || (errno == EINVAL && regset->type == OPTIONAL_REGS)) + || (errno == EINVAL + && (regset->type == OPTIONAL_REGS + || regset->type == OPTIONAL_RUNTIME_REGS))) { /* If we get EIO on a regset, or an EINVAL and the regset is - optional, do not try it again for this process mode. */ + optional, do not try it again for this process mode. + Even if the regset can be enabled at runtime it is safe + to deactivate the regset in case of EINVAL, as we know + the regset itself was the invalid argument of the ptrace + call which means that it's unsupported by the kernel. */ disable_regset (regsets_info, regset); } - else if (errno == ENODATA) + else if (errno == ENODATA + || (errno == ENODEV + && regset->type == OPTIONAL_RUNTIME_REGS) + || errno == ESRCH) { - /* ENODATA may be returned if the regset is currently - not "active". This can happen in normal operation, - so suppress the warning in this case. */ - } - else if (errno == ESRCH) - { - /* At this point, ESRCH should mean the process is - already gone, in which case we simply ignore attempts - to read its registers. */ + /* ENODATA or ENODEV may be returned if the regset is + currently not "active". For ENODEV we additionally check + if the register set is of type OPTIONAL_RUNTIME_REGS. + This can happen in normal operation, so suppress the + warning in this case. + ESRCH should mean the process is already gone at this + point, in which case we simply ignore attempts to read + its registers. */ } else { @@ -5104,12 +5111,26 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info, if (res < 0) { if (errno == EIO - || (errno == EINVAL && regset->type == OPTIONAL_REGS)) + || (errno == EINVAL + && (regset->type == OPTIONAL_REGS + || regset->type == OPTIONAL_RUNTIME_REGS))) { /* If we get EIO on a regset, or an EINVAL and the regset is - optional, do not try it again for this process mode. */ + optional, do not try it again for this process mode. + Even if the regset can be enabled at runtime it is safe + to deactivate the regset in case of EINVAL, as we know + the regset itself was the invalid argument of the ptrace + call which means that it's unsupported by the kernel. */ disable_regset (regsets_info, regset); } + else if (errno == ENODEV + && regset->type == OPTIONAL_RUNTIME_REGS) + { + /* If we get ENODEV on a regset and the regset can be + enabled at runtime try it again for this process mode. + This can happen in normal operation, so suppress the + warning in this case. */ + } else if (errno == ESRCH) { /* At this point, ESRCH should mean the process is @@ -6033,7 +6054,7 @@ linux_process_target::supports_pid_to_exec_file () const char * linux_process_target::pid_to_exec_file (int pid) { - return linux_proc_pid_to_exec_file (pid); + return linux_proc_pid_to_exec_file (pid, linux_ns_same (pid, LINUX_NS_MNT)); } bool @@ -6050,6 +6071,12 @@ linux_process_target::multifs_open (int pid, const char *filename, } int +linux_process_target::multifs_lstat (int pid, const char *filename, struct stat *sb) +{ + return linux_mntns_lstat (pid, filename, sb); +} + +int linux_process_target::multifs_unlink (int pid, const char *filename) { return linux_mntns_unlink (pid, filename); @@ -6984,7 +7011,7 @@ replace_non_ascii (char *dest, const char *name) const char *result = dest; while (*name != '\0') { - if (!ISPRINT (*name)) + if (!c_isprint (*name)) *dest++ = '?'; else *dest++ = *name; |