Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [patch] Fix a crash on NULL event_thread
Date: Wed, 17 Sep 2008 15:55:00 -0000	[thread overview]
Message-ID: <200809171654.39206.pedro@codesourcery.com> (raw)
In-Reply-To: <20080915185627.GA25128@host0.dyn.jankratochvil.net>

Hi Jan, sorry for the delay,

On Monday 15 September 2008 19:56:27, Jan Kratochvil wrote:
> > Would it be possible to add the thread to the thread list, in
> > addition to the lwp?
>
> IMO the reason for two lists is that really these two resources are
> different. You can perfectly have tracked LWPs with no corresponding thread
> structures. Attached a testcase using clone(2) which if you CTRL-C it has a
> state: (gdb) plist thread_list ptid
> $1 = {pid = 25112, lwp = 25112, tid = 0}
> (gdb) plist lwp_list ptid
> $2 = {pid = 25112, lwp = 25115, tid = 0}
> $3 = {pid = 25112, lwp = 25112, tid = 0}
>
> New thread notification will come from libthread_db but some time in
> between we have no corresponding thread structures such as they will never
> exist for standalone LWPs.

I understand the difference between LWPs and pthread threads.

A posix threads library hides the underlying threads implementation,
but that doesn't mean that we can only call "threads", things
that are visible through pthreads.  That is, in your non-pthreads
example, you're happy to call new lwps "threads", and
use CLONE_*THREAD*.

From GDB's perspective, a "thread" is an abstraction that
represents a locus of execution.  It doesn't really matter
if its comes from pthreads or using CLONE_THREAD directly.  You'll
still need to be able to see them in "info threads", and switch
between them with "thread", and GDB will have to manage thread
stepping state in them.  In fact, the new_thread_event thing is
calling "add_thread" on an LWP, that hasn't hit a thread
create event breakpoint yet.  So, we're talking about *when/where* to
call add_thread.  In your clone-thread.c example, just put a break
on child_func and let it hit to reliably trigger the
new_thread_event path.

I've been cooking some ideas about decoupling where we trigger the
[New Thread ...] notifications (currently in add_thread), from
managing the data structures, and about making GDB's core not
so agnostic of 1:1, M:N, x:y, target/thread/lwp/process child/parent
relations, but those will come later.

In the mean time, your patch preserves the old behaviour, and
looks good to me.  You'll need someone else to approve it,
though.

-- 
Pedro Alves


  reply	other threads:[~2008-09-17 15:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 22:17 Jan Kratochvil
2008-09-12 22:45 ` Pedro Alves
2008-09-15 18:59   ` Jan Kratochvil
2008-09-17 15:55     ` Pedro Alves [this message]
2008-09-17 18:04 ` Daniel Jacobowitz
2008-09-17 21:56   ` Jan Kratochvil

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=200809171654.39206.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /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