This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Remove lwp -> pid conversion in linux_nat_xfer_partial
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Sat, 25 Mar 2017 00:30:22 -0400
- Subject: [binutils-gdb] Remove lwp -> pid conversion in linux_nat_xfer_partial
- Authentication-results: sourceware.org; auth=none
*** TEST RESULTS FOR COMMIT b67aeab02c05fdd654f132a550dd4f196cb1f6d3 ***
Author: Simon Marchi <simon.marchi@polymtl.ca>
Branch: master
Commit: b67aeab02c05fdd654f132a550dd4f196cb1f6d3
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.