Remove lwp -> pid conversion in linux_nat_xfer_partial
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 22 Mar 2017 14:35:07 +0000 (10:35 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Wed, 22 Mar 2017 14:35:16 +0000 (10:35 -0400)
commitb67aeab02c05fdd654f132a550dd4f196cb1f6d3
tree70854307923a84c0a2877c5e0ec5cab47f4c091f
parent11997a83a040245406b6e2e9978c6720f17e80c4
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.
gdb/ChangeLog
gdb/inf-ptrace.c
gdb/linux-nat.c
This page took 0.039455 seconds and 4 git commands to generate.