This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: threads and core file support
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: nick dot hudson at dsl dot pipex dot com
- Cc: gdb at sourceware dot org
- Date: Sat, 22 Dec 2007 15:14:03 +0100 (CET)
- Subject: Re: threads and core file support
- References: <200712221317.22469.nick.hudson@dsl.pipex.com>
> From: Nick Hudson <nick.hudson@dsl.pipex.com>
> Date: Sat, 22 Dec 2007 13:17:21 +0000
>
> Hi,
>
> I'm (slowly) working on improving NetBSD pthreads and core file
> support and it appears to me the best (only?) example to follow is
> sol-thread.c.
That code is old and hasn't been properly maintained for years; I
wouldn't recommend using it as a guideline. It also uses
libthreads_db, which makes building a cross-debugger almost impossible
and complicates matters unecessary for 1:1 threading models.
The Linux threading code suffers from the same problem, but is in many
respects even worse, because the Linux kernel lacked a proper threads
debugging interface for quite a while and the code was written towards
an evolving kernel interface.
My recommendation is to start working on making GDB aware of LWPs (I
think that's how kernel-level threads are called on NetBSD). You'll
probably need to write a NetBSD-specific replacement for inf-ptrace.c
for that. I recommend looking at inf-ttrace.c for an example on how
to handle multiple threads.
Then, after that, you might want the add a layer to link LWPs to
user-level threads. For a pthreads library that uses a 1:1 threading
model this can be as simple as annotating all threads with the
pthread_t identifier and changing the way GDB will print thread IDs
using that. For N:M threading models things are probably a bit more
complicated (but even Solaris is moving away from N:M threading).
Cheers,
Mark