/* GNU/Linux native-dependent code common to multiple platforms.
- Copyright (C) 2001-2022 Free Software Foundation, Inc.
+ Copyright (C) 2001-2023 Free Software Foundation, Inc.
This file is part of GDB.
#include "symfile.h"
#include "gdbsupport/agent.h"
#include "tracepoint.h"
-#include "gdbsupport/buffer.h"
#include "target-descriptions.h"
#include "gdbsupport/filestuff.h"
#include "objfiles.h"
linux_enable_event_reporting (pid, options);
linux_ptrace_init_warnings ();
linux_proc_init_warnings ();
+ proc_mem_file_is_writable ();
}
linux_nat_target::~linux_nat_target ()
if (tp->has_pending_waitstatus ())
{
/* If the thread has a pending event, and it was stopped with a
- signal, use that signal to resume it. If it has a pending
+ signal, use that signal to resume it. If it has a pending
event of another kind, it was not stopped with a signal, so
resume it without a signal. */
if (tp->pending_waitstatus ().kind () == TARGET_WAITKIND_STOPPED)
}
static enum target_xfer_status
-linux_xfer_siginfo (enum target_object object,
+linux_xfer_siginfo (ptid_t ptid, enum target_object object,
const char *annex, gdb_byte *readbuf,
const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len)
if (offset > sizeof (siginfo))
return TARGET_XFER_E_IO;
- int pid = get_ptrace_pid (inferior_ptid);
- errno = 0;
- ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo);
- if (errno != 0)
+ if (!linux_nat_get_siginfo (ptid, &siginfo))
return TARGET_XFER_E_IO;
/* When GDB is built as a 64-bit application, ptrace writes into
/* Convert back to ptrace layout before flushing it out. */
siginfo_fixup (&siginfo, inf_siginfo, 1);
+ int pid = get_ptrace_pid (ptid);
errno = 0;
ptrace (PTRACE_SETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo);
if (errno != 0)
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
{
if (object == TARGET_OBJECT_SIGNAL_INFO)
- return linux_xfer_siginfo (object, annex, readbuf, writebuf,
+ return linux_xfer_siginfo (inferior_ptid, object, annex, readbuf, writebuf,
offset, len, xfered_len);
/* The target is connected but no live inferior is selected. Pass
return true if so. It wasn't writable before Linux 2.6.39, but
there's no way to know whether the feature was backported to older
kernels. So we check to see if it works. The result is cached,
- and this is garanteed to be called once early at startup. */
+ and this is garanteed to be called once early during inferior
+ startup, so that any warning is printed out consistently between
+ GDB invocations. Note we don't call it during GDB startup instead
+ though, because then we might warn with e.g. just "gdb --version"
+ on sandboxed systems. See PR gdb/29907. */
static bool
proc_mem_file_is_writable ()
/* Pause all */
target_stop (ptid);
- memcpy (s, "qTfSTM", sizeof ("qTfSTM"));
- s[sizeof ("qTfSTM")] = 0;
-
+ strcpy (s, "qTfSTM");
agent_run_command (pid, s, strlen (s) + 1);
/* Unpause all. */
}
while (*p++ == ','); /* comma-separated list */
- memcpy (s, "qTsSTM", sizeof ("qTsSTM"));
- s[sizeof ("qTsSTM")] = 0;
+ strcpy (s, "qTsSTM");
agent_run_command (pid, s, strlen (s) + 1);
p = s;
}
linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo)
{
int pid = get_ptrace_pid (ptid);
-
- errno = 0;
- ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, siginfo);
- if (errno != 0)
- {
- memset (siginfo, 0, sizeof (*siginfo));
- return false;
- }
- return true;
+ return ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, siginfo) == 0;
}
/* See nat/linux-nat.h. */
sigemptyset (&blocked_mask);
lwp_lwpid_htab_create ();
-
- proc_mem_file_is_writable ();
}
\f