aboutsummaryrefslogtreecommitdiff
path: root/gdbserver/linux-low.h
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-03-28 18:35:34 +0100
committerPedro Alves <pedro@palves.net>2022-04-14 20:22:56 +0100
commit421490af33bfbfe8a8429f0e43fb3e9f8727476e (patch)
treed6a5ec2d36574605c40b8ef69bcc791ecc59056d /gdbserver/linux-low.h
parent366e3746c572c2c78454761e62fa9181cba413ca (diff)
downloadgdb-421490af33bfbfe8a8429f0e43fb3e9f8727476e.zip
gdb-421490af33bfbfe8a8429f0e43fb3e9f8727476e.tar.gz
gdb-421490af33bfbfe8a8429f0e43fb3e9f8727476e.tar.bz2
gdbserver/linux: Access memory even if threads are running
Similarly to how the native Linux target was changed and subsequently reworked in these commits: 05c06f318fd9 Linux: Access memory even if threads are running 8a89ddbda2ec Avoid /proc/pid/mem races (PR 28065) ... teach GDBserver to access memory even when the current thread is running, by always accessing memory via /proc/PID/mem. The existing comment: /* Neither ptrace nor /proc/PID/mem allow accessing memory through a running LWP. */ ... is incorrect for /proc/PID/mem does allow that. Actually, from GDB's perspective, GDBserver could already access memory while threads were running, but at the expense of pausing all threads for the duration of the memory access, via prepare_to_access_memory. This new implementation does not require pausing any thread, thus linux_process_target::prepare_to_access_memory / linux_process_target::done_accessing_memory become nops. A subsequent patch will remove the whole prepare_to_access_memory infrastructure completely. The GDBserver linux-low.cc implementation is simpler than GDB's linux-nat.c's, because GDBserver always adds the unfollowed vfork/fork children to the process list immediately when the fork/vfork event is seen out of ptrace. I.e., there's no need to keep the file descriptor stored on a side map, we can store it directly in the process structure. Change-Id: I0abfd782ceaa4ddce8d3e5f3e2dfc5928862ef61
Diffstat (limited to 'gdbserver/linux-low.h')
-rw-r--r--gdbserver/linux-low.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 27cc964..4284fb3 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -127,6 +127,9 @@ struct process_info_private
/* &_r_debug. 0 if not yet determined. -1 if no PT_DYNAMIC in Phdrs. */
CORE_ADDR r_debug;
+
+ /* The /proc/pid/mem file used for reading/writing memory. */
+ int mem_fd;
};
struct lwp_info;
@@ -163,10 +166,6 @@ public:
void store_registers (regcache *regcache, int regno) override;
- int prepare_to_access_memory () override;
-
- void done_accessing_memory () override;
-
int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
int len) override;
@@ -544,6 +543,10 @@ private:
data. */
process_info *add_linux_process (int pid, int attached);
+ /* Same as add_linux_process, but don't open the /proc/PID/mem file
+ yet. */
+ process_info *add_linux_process_no_mem_file (int pid, int attached);
+
/* Add a new thread. */
lwp_info *add_lwp (ptid_t ptid);