aboutsummaryrefslogtreecommitdiff
path: root/gdb/inf-ptrace.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2017-03-22 10:35:07 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2017-03-22 10:35:16 -0400
commitb67aeab02c05fdd654f132a550dd4f196cb1f6d3 (patch)
tree70854307923a84c0a2877c5e0ec5cab47f4c091f /gdb/inf-ptrace.c
parent11997a83a040245406b6e2e9978c6720f17e80c4 (diff)
downloadgdb-b67aeab02c05fdd654f132a550dd4f196cb1f6d3.zip
gdb-b67aeab02c05fdd654f132a550dd4f196cb1f6d3.tar.gz
gdb-b67aeab02c05fdd654f132a550dd4f196cb1f6d3.tar.bz2
Remove lwp -> pid conversion in linux_nat_xfer_partial
The linux_nat_xfer_partial does a conversion of inferior_ptid: if it's an LWP (ptid::lwp != 0), it builds a new ptid with the lwp as the pid and assigns that temporarily to inferior_ptid. For example, if inferior_ptid is: { .pid = 1234, .lwp = 1235 } it will assign this to inferior_ptid for the duration of the call: { .pid = 1235, .lwp = 0 } Instead of doing this, this patch teaches the inf-ptrace implementation of xfer_partial to deal with ptids representing lwps by using get_ptrace_pid. Also, in linux_proc_xfer_spu and linux_proc_xfer_partial, we use ptid_get_lwp instead of ptid_get_pid. While not strictly necessary, since the content of /proc/<pid> and /proc/<lwp> should be the same, it's a bit safer, because: - some files under /proc/<pid>/ may not work if the <pid> thread is running, just like ptrace requires a stopped thread. The current thread's lwp id is more likely to be in the necessary state (stopped). - if the leader (<pid>) had exited and is thus now zombie, then several files under "/proc/<pid>" won't work, while they will if you use "/proc/<lwp>". The testsuite found no regression on native amd64 linux. gdb/ChangeLog: * inf-ptrace.c (inf_ptrace_xfer_partial): Get pid from ptid using get_ptrace_pid. * linux-nat.c (linux_nat_xfer_partial): Don't set/restore inferior_ptid. (linux_proc_xfer_partial, linux_proc_xfer_spu): Use lwp of inferior_ptid instead of pid.
Diffstat (limited to 'gdb/inf-ptrace.c')
-rw-r--r--gdb/inf-ptrace.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 61d2426..f912d28 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -520,7 +520,7 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object,
const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
{
- pid_t pid = ptid_get_pid (inferior_ptid);
+ pid_t pid = get_ptrace_pid (inferior_ptid);
switch (object)
{