From: Pedro Alves <palves@redhat.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Linux/ptrace: don't convert ptids when asking inf-ptrace layer to resume LWP
Date: Tue, 03 Mar 2015 16:25:00 -0000 [thread overview]
Message-ID: <54F5E064.8070205@redhat.com> (raw)
In-Reply-To: <201503031604.t23G4JqR008694@glazunov.sibelius.xs4all.nl>
On 03/03/2015 04:04 PM, Mark Kettenis wrote:
>> > Date: Tue, 03 Mar 2015 15:12:48 +0000
>> > From: Pedro Alves <palves@redhat.com>
>> >
>> > 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 can only speak for OpenBSD here, but yes, on OpenBSD, if you pass
> "PID" here, all threads within a process are resumed. If you want to
> resume an individual thread, you need to pass its thread ID. Thread
> IDs are also integers, but start at THREAD_PID_OFFSET, which is
> currently defined as 1000000.
>
> Are things broken? Perhaps. GDB used to properly support an
> all-stop/all-go model, and things still seem to work mostly ok.
> Perhaps this diff will actually make things better if there are places
> where GDB wants to resume or step a single thread that isn't the
> thread that stopped the process in the first place.
Yes, I assume so. Things like schedlock and stepping over a
breakpoint must have been subtly broken thus far, if they have
been letting all threads run while core gdb wants only one
thread to run.
>
> I've always considered it a serious flaw that Linux doesn't have a way
> to resume the entire process and that we need almost 5000 lines of
> code to deal with the consequences.
:-)
>
>> > 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.
> That assumption is incorrect.
OK.
> I see that this assumption has made its way into infrun.c:
>
> inferior_ptid = ptid_build (child_pid, child_pid, 0);
>
> That's wrong. The OS-specific code should fill in the LWPID part with
> the appropriate value by using thread_change_ptid(). AFAICT, the
> linux-nat.c code does that properly.
I think you're pointing at the follow fork code. That was born out
of a generalization of code that used to live in linux-nat.c, inf-ptrace.c,
etc. (d83ad864). The old inf-ptrace.c code used to do:
/* Switch inferior_ptid out of the parent's way. */
inferior_ptid = pid_to_ptid (fpid);
/* Delete the parent. */
detach_inferior (pid);
add_thread_silent (inferior_ptid);
'child_pid' is set at the top of follow_fork_inferior, like:
child_pid
= ptid_get_pid (inferior_thread ()->pending_follow.value.related_pid);
I think I even remember that long ago "related_pid" used to be
a single int, not a ptid.
This is again another case of losing information. I think we could
easily make that:
child_pid = inferior_thread ()->pending_follow.value.related_pid;
and drop that ptid_build, and things should work everywhere.
I have no idea if "follow fork" actually works on BSD targets correctly.
A buildbot slave would catch breakages like these. ( hint :-) )
>
>> > If there anything that actually creates other threads with
>> > a different LWPID on these targets?
> The initial thread ID of an OpenBSD process will be PID + THREAD_PID_OFFSET.
>
Thanks, didn't know that.
Pedro Alves
next prev parent reply other threads:[~2015-03-03 16:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-03 14:39 Mark Kettenis
2015-03-03 15:12 ` Pedro Alves
2015-03-03 15:34 ` Pedro Alves
2015-03-03 16:34 ` Pedro Alves
2015-03-03 16:04 ` Mark Kettenis
2015-03-03 16:25 ` Pedro Alves [this message]
2015-03-03 17:06 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54F5E064.8070205@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox