This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Linux/ptrace: don't convert ptids when asking inf-ptrace layer to resume LWP
- From: Pedro Alves <palves at redhat dot com>
- To: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 03 Mar 2015 15:34:32 +0000
- Subject: Re: [PATCH] Linux/ptrace: don't convert ptids when asking inf-ptrace layer to resume LWP
- Authentication-results: sourceware.org; auth=none
- References: <201503031439 dot t23EdHZv020814 at glazunov dot sibelius dot xs4all dot nl> <54F5CF70 dot 2090706 at redhat dot com>
On 03/03/2015 03:12 PM, Pedro Alves wrote:
> On 03/03/2015 02:39 PM, Mark Kettenis wrote:
>>> - if (pid == -1)
>>> + if (ptid_equal (minus_one_ptid, ptid))
>>> /* Resume all threads. Traditionally ptrace() only supports
>>> single-threaded processes, so simply resume the inferior. */
>>> - pid = ptid_get_pid (inferior_ptid);
>>> + pid = get_ptrace_pid (inferior_ptid);
>>
>> This defenitely should remain ptid_get_pid(); you want to resume the
>> entire process and not an individual thread.
>
> My thinking is that it doesn't matter in practice.
>
> Or is it that if there are multiple kernel threads in the
> process, ptrace(PTRACE_CONT, PID) on bsd actually resumes
> them all? Then other things must be broken anyway.
>
> I was assuming that on BSD targets that use this method,
> there would only be one thread in the core thread list, and
> it would either have LWPID==0, or have PID==LWPID, thus it didn't
> matter if get_ptrace_pid returned the PID or the LWPID.
>
> If there anything that actually creates other threads with
> a different LWPID on these targets?
>
>>
>>> + else
>>> + pid = get_ptrace_pid (ptid);
>>
>> This should work for OpenBSD, and probably works for FreeBSD. It
>> won't work for NetBSD, but they will probably need their own
>> implementation of this function, so it's probably fine.
>>
>
In any case, I agree it's at least clearer. I'm testing this.
Thanks.
>From b8480e9cfcc2107b81751084c01a262eb1d52c74 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 3 Mar 2015 15:27:54 +0000
Subject: [PATCH] inf-ptrace.c: use ptid_get_pid when resuming all threads
In this case, we want to resume the entire process and not an
individual thread. Using the overall process id is clearer and more
correct.
gdb/
2015-03-03 Pedro Alves <palves@redhat.com>
* inf-ptrace.c (inf_ptrace_resume): Remove spurious whitespace.
Use ptid_get_pid to get the overall process id when resuming all
threads.
---
gdb/ChangeLog | 6 ++++++
gdb/inf-ptrace.c | 3 +--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 31a672e..20250e4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2015-03-03 Pedro Alves <palves@redhat.com>
+ * inf-ptrace.c (inf_ptrace_resume): Remove spurious whitespace.
+ Use ptid_get_pid to get the overall process id when resuming all
+ threads.
+
+2015-03-03 Pedro Alves <palves@redhat.com>
+
* i386-linux-nat.c (i386_linux_resume): Get the ptrace PID out of
the lwp field of ptid. Pass the full ptid to get_thread_regcache.
* inf-ptrace.c (get_ptrace_pid): New function.
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 606bdb4..3502a12 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -314,13 +314,12 @@ inf_ptrace_resume (struct target_ops *ops,
ptid_t ptid, int step, enum gdb_signal signal)
{
pid_t pid;
-
int request;
if (ptid_equal (minus_one_ptid, ptid))
/* Resume all threads. Traditionally ptrace() only supports
single-threaded processes, so simply resume the inferior. */
- pid = get_ptrace_pid (inferior_ptid);
+ pid = ptid_get_pid (inferior_ptid);
else
pid = get_ptrace_pid (ptid);
--
1.9.3