* Why does gdb use its own thread ids internally rather than the tid from the underlying thread implementation?
@ 2008-03-03 18:42 Martin Fouts
2008-03-03 19:57 ` Michael Snyder
0 siblings, 1 reply; 6+ messages in thread
From: Martin Fouts @ 2008-03-03 18:42 UTC (permalink / raw)
To: gdb; +Cc: Mike Chen
Hi,
We're trying to optimize the NetBSD 4.0 implementation of pthreads,
which has an M:N thread implementation, and are having some trouble
getting gdb to work because the underlying thread id for a thread can
change in an M:N implementation.
Can anyone provide any insight into why gdb doesn't use the underlying
thread id?
Or suggestions about how to accommodate M:N without zombie queues?
Thanks,
Marty
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why does gdb use its own thread ids internally rather than the tid from the underlying thread implementation?
2008-03-03 18:42 Why does gdb use its own thread ids internally rather than the tid from the underlying thread implementation? Martin Fouts
@ 2008-03-03 19:57 ` Michael Snyder
2008-03-03 20:09 ` Daniel Jacobowitz
2008-03-03 20:20 ` Why does gdb use its own thread ids internally rather than the ?tid " Mark Kettenis
0 siblings, 2 replies; 6+ messages in thread
From: Michael Snyder @ 2008-03-03 19:57 UTC (permalink / raw)
To: Martin Fouts; +Cc: gdb, Mike Chen
On Mon, 2008-03-03 at 10:38 -0800, Martin Fouts wrote:
> Hi,
>
> We're trying to optimize the NetBSD 4.0 implementation of pthreads,
> which has an M:N thread implementation, and are having some trouble
> getting gdb to work because the underlying thread id for a thread can
> change in an M:N implementation.
>
> Can anyone provide any insight into why gdb doesn't use the underlying
> thread id?
Sure. I think the main reason is that the underlying thread id
is usually something awkward for a user to type (like an 8-digit
hex number). GDB supplies a counting number, just like for
breakpoints, so that you can type "thread 2" instead of
"thread 77af21bc".
For another thing, gdb tries to present a more-or-less uniform
user interface across platforms. Underlying thread ids are
different from one platform to the next.
> Or suggestions about how to accommodate M:N without zombie queues?
Have you looked at the linux and solaris implementations?
They both have M:N thread models.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why does gdb use its own thread ids internally rather than the tid from the underlying thread implementation?
2008-03-03 19:57 ` Michael Snyder
@ 2008-03-03 20:09 ` Daniel Jacobowitz
2008-03-03 20:20 ` Why does gdb use its own thread ids internally rather than the ?tid " Mark Kettenis
1 sibling, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2008-03-03 20:09 UTC (permalink / raw)
To: Michael Snyder; +Cc: Martin Fouts, gdb, Mike Chen
On Mon, Mar 03, 2008 at 11:57:08AM -0800, Michael Snyder wrote:
> On Mon, 2008-03-03 at 10:38 -0800, Martin Fouts wrote:
> > Hi,
> >
> > We're trying to optimize the NetBSD 4.0 implementation of pthreads,
> > which has an M:N thread implementation, and are having some trouble
> > getting gdb to work because the underlying thread id for a thread can
> > change in an M:N implementation.
Hopefully, Mark Kettenis will have some advice on this. The threading
code is platform-specific, and I'm not familiar with any of the BSD ports.
> > Or suggestions about how to accommodate M:N without zombie queues?
>
> Have you looked at the linux and solaris implementations?
> They both have M:N thread models.
Not any more. Linux support for M:N was removed, since it did not
work and there were no viable M:N implementations to test with.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why does gdb use its own thread ids internally rather than the ?tid from the underlying thread implementation?
2008-03-03 19:57 ` Michael Snyder
2008-03-03 20:09 ` Daniel Jacobowitz
@ 2008-03-03 20:20 ` Mark Kettenis
2008-03-03 20:38 ` Michael Snyder
1 sibling, 1 reply; 6+ messages in thread
From: Mark Kettenis @ 2008-03-03 20:20 UTC (permalink / raw)
To: mfouts, gdb, mchen; +Cc: msnyder
> From: "Michael Snyder" <msnyder@specifix.com>
> Date: Mon, 03 Mar 2008 11:57:08 -0800
>
> On Mon, 2008-03-03 at 10:38 -0800, Martin Fouts wrote:
> > Hi,
> >
> > We're trying to optimize the NetBSD 4.0 implementation of pthreads,
> > which has an M:N thread implementation, and are having some trouble
> > getting gdb to work because the underlying thread id for a thread can
> > change in an M:N implementation.
> >
> > Can anyone provide any insight into why gdb doesn't use the underlying
> > thread id?
>
> Sure. I think the main reason is that the underlying thread id
> is usually something awkward for a user to type (like an 8-digit
> hex number). GDB supplies a counting number, just like for
> breakpoints, so that you can type "thread 2" instead of
> "thread 77af21bc".
>
> For another thing, gdb tries to present a more-or-less uniform
> user interface across platforms. Underlying thread ids are
> different from one platform to the next.
>
> > Or suggestions about how to accommodate M:N without zombie queues?
>
> Have you looked at the linux and solaris implementations?
> They both have M:N thread models.
Linux doesn't. And even Solaris uses a 1:1 model by default nowadays.
And I really doubt the code for M:N ever worked properly in GDB.
I'm afraid that implementing GDB support for an M:N threading model is
a largely unsolved problem.
Given the fact that GDB doesn't even have support for kernel-level
threads (or LWP's) on NetBSD, I'd start with getting that working.
After that, it might be possible by implementing an additional stratum
on top of that, that does the LWP to user-level thread ID translation,
and adds in the threads that are not bound to an LWP.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why does gdb use its own thread ids internally rather than the ?tid from the underlying thread implementation?
2008-03-03 20:20 ` Why does gdb use its own thread ids internally rather than the ?tid " Mark Kettenis
@ 2008-03-03 20:38 ` Michael Snyder
2008-03-03 20:56 ` Mark Kettenis
0 siblings, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2008-03-03 20:38 UTC (permalink / raw)
To: Mark Kettenis; +Cc: mfouts, gdb, mchen
On Mon, 2008-03-03 at 21:19 +0100, Mark Kettenis wrote:
> > From: "Michael Snyder" <msnyder@specifix.com>
> > Date: Mon, 03 Mar 2008 11:57:08 -0800
> >
> > On Mon, 2008-03-03 at 10:38 -0800, Martin Fouts wrote:
[...]
> > > Or suggestions about how to accommodate M:N without zombie queues?
> >
> > Have you looked at the linux and solaris implementations?
> > They both have M:N thread models.
>
> Linux doesn't. And even Solaris uses a 1:1 model by default nowadays.
> And I really doubt the code for M:N ever worked properly in GDB.
Really? It was never perfect, but I always thought of M:N on
solaris as "mostly working"...
>
> I'm afraid that implementing GDB support for an M:N threading model is
> a largely unsolved problem.
>
> Given the fact that GDB doesn't even have support for kernel-level
> threads (or LWP's) on NetBSD, I'd start with getting that working.
> After that, it might be possible by implementing an additional stratum
> on top of that, that does the LWP to user-level thread ID translation,
> and adds in the threads that are not bound to an LWP.
Out of curiosity, how different are the thread models
between netbsd and freebsd? I've noticed that there
seem to be at least two different models for debugging
threads on freebsd, but I'm not up to speed on it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why does gdb use its own thread ids internally rather than the ?tid from the underlying thread implementation?
2008-03-03 20:38 ` Michael Snyder
@ 2008-03-03 20:56 ` Mark Kettenis
0 siblings, 0 replies; 6+ messages in thread
From: Mark Kettenis @ 2008-03-03 20:56 UTC (permalink / raw)
To: msnyder; +Cc: mfouts, gdb, mchen
> From: Michael Snyder <msnyder@specifix.com>
> Date: Mon, 03 Mar 2008 12:37:58 -0800
>
> On Mon, 2008-03-03 at 21:19 +0100, Mark Kettenis wrote:
> > > From: "Michael Snyder" <msnyder@specifix.com>
> > > Date: Mon, 03 Mar 2008 11:57:08 -0800
> > >
> > > On Mon, 2008-03-03 at 10:38 -0800, Martin Fouts wrote:
> [...]
> > > > Or suggestions about how to accommodate M:N without zombie queues?
> > >
> > > Have you looked at the linux and solaris implementations?
> > > They both have M:N thread models.
> >
> > Linux doesn't. And even Solaris uses a 1:1 model by default nowadays.
> > And I really doubt the code for M:N ever worked properly in GDB.
>
> Really? It was never perfect, but I always thought of M:N on
> solaris as "mostly working"...
>
> >
> > I'm afraid that implementing GDB support for an M:N threading model is
> > a largely unsolved problem.
> >
> > Given the fact that GDB doesn't even have support for kernel-level
> > threads (or LWP's) on NetBSD, I'd start with getting that working.
> > After that, it might be possible by implementing an additional stratum
> > on top of that, that does the LWP to user-level thread ID translation,
> > and adds in the threads that are not bound to an LWP.
>
> Out of curiosity, how different are the thread models
> between netbsd and freebsd? I've noticed that there
> seem to be at least two different models for debugging
> threads on freebsd, but I'm not up to speed on it.
The code we have in GDB is for the old FreeBSD 4 userlevel threads
library, which you could call N:1 threading. As far as I know FreeBSD
tried to do both M:N and 1:1 in FreeBSD 5, but I think M:N was more or
less abandoned because they couldn't get it to work properly.
I'm not sure what the NetBSD folks are up to these days. Given the
history of FreeBSD, Linux and Solaris, I'd advise them to stick to
1:1, or at least get that working first before trying M:N.
OpenBSD has the beginnings of a 1:1 model, but it is not enabled by
default. The official threads library on OpenBSD is based on the same
code as the old FreeBSD userlevel threads library (N:1). This one is
supported by the same code in GDB.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-03-03 20:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-03 18:42 Why does gdb use its own thread ids internally rather than the tid from the underlying thread implementation? Martin Fouts
2008-03-03 19:57 ` Michael Snyder
2008-03-03 20:09 ` Daniel Jacobowitz
2008-03-03 20:20 ` Why does gdb use its own thread ids internally rather than the ?tid " Mark Kettenis
2008-03-03 20:38 ` Michael Snyder
2008-03-03 20:56 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox