This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: GDB support for thread-local storage
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Jim Blandy <jimb at redhat dot com>
- Cc: Andrew Cagney <ac131313 at ges dot redhat dot com>,Andrew Cagney <ac131313 at cygnus dot com>,James Cownie <jcownie at etnus dot com>, gdb at sources dot redhat dot com
- Date: Mon, 19 Aug 2002 12:05:44 -0400
- Subject: Re: GDB support for thread-local storage
- References: <20020625154201.GB17370@branoic.them.org> <17MsdN-0Qe-00@etnus.com> <20020625155555.GA18083@branoic.them.org> <3D1897DA.90405@cygnus.com> <20020625170147.GB19950@branoic.them.org> <npwusl4yds.fsf@zwingli.cygnus.com> <3D1A78E4.5060904@ges.redhat.com> <npr8it2uat.fsf@zwingli.cygnus.com>
On Wed, Jun 26, 2002 at 11:56:58PM -0500, Jim Blandy wrote:
>
> Andrew Cagney <ac131313@ges.redhat.com> writes:
> > > Doesn't libthread_db read `struct _pthread_descr_struct' from the
> > > linuxthreads library in the inferior, rather than knowing the layout
> > > itself? So it's actually the inferior's linuxthreads library that
> > > describes its own structures' layout.
> >
> > The structure layout will have been compiled into libthread-db.a. It
> > implicitly knows the layout itself.
>
> I think you're wrong here. Could you show me the code?
>
> (Not that the question is especially relevant to the discussion --- of
> course it could do a simple checksum check.)
You're right, and you're wrong. For instance, td_ta_map_id2thr.c:
#include <linuxthreads/internals.h>
struct pthread_handle_struct phc;
if (ps_pdread (ta->ph, ta->handles + pt % pthread_threads_max, &phc,
sizeof (struct pthread_handle_struct)) != PS_OK)
if (phc.h_descr == NULL)
etc.
which references:
struct pthread_handle_struct {
struct _pthread_fastlock h_lock; /* Fast lock for sychronized access */
pthread_descr h_descr; /* Thread descriptor or NULL if invalid */
char * h_bottom; /* Lowest address in the stack thread */
};
Worse, it reads the _pthread_descr_struct from the inferior.
_pthread_descr_struct does not describe the layout of anything; it's
the actual descriptor. It has things like a sigjmp_buf in it.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer