Re: howto debug libthread_db

Michael Snyder
2006-09-26T18:20:47Z

On Tue, 2006-09-26 at 16:06 +0200, Carmelo Amoroso wrote:
> Hi All,
> I'm trying to debug a simple multithread application on a remote target,
> and I like to debug the libthread_db itself... is it possible to do it?
> is it possible to set some breakpoints and stepping through?
> Is there anyone already played with it?
>
> I tried to use symbol-file to gdb client, and I successfully added a
> breakpoint, but I cannot reach it after I connected to the target and
> issued 'continue'.
>
> Any help will be appreciated

Interesting. I haven't done it (or not much anyway).

The first thing you must bear in mind is that libthread_db is not
part of the target application -- it is part of gdb (or in the
remote debugging context, part of gdbserver). So to debug it,
you must debug gdb, or in your case gdbserver.

It might be easier if you try this out first using a native gdb,
debugging itself.

When you debug gdb with gdb, it is easier if you change the prompt.
I usually do this in the 'parent' gdb, so I can tell it apart from
the 'child' gdb:

(gdb) set prompt (GDB)
(GDB)

Now, in the parent GDB, you should be able to set your
breakpoints in libthread_db, then start the child gdb,
load the multi-threaded program, and begin debugging it.

When you get ready to try this with gdbserver, you will
have to start one gdbserver and attach to it with another
gdbserver. Then you'll again have two gdbs running on the
host side, which you can again think of as parent and child,
only now the parent is debugging the child's gdbserver, not
the child gdb itself.