Discussion:
using linuxthread_db
(too old to reply)
Martin Koller
2004-11-03 11:26:34 UTC
Permalink
Hi,

(using Linux 2.4.22, glibc-2.3.2, gcc-3.2.3)

I wanted to compile an application with the linuxthread_db library because I
need to ptrace() (debug programmatically) a threaded application.

When I do gcc -o father father.c -lthread_db I get
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libthread_db.so:
undefined reference to `ps_pdwrite'
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libthread_db.so:
undefined reference to `ps_pglobal_lookup'
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libthread_db.so:
undefined reference to `ps_lsetfpregs'
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libthread_db.so:
undefined reference to `ps_getpid'
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libthread_db.so:
undefined reference to `ps_lsetregs'
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libthread_db.so:
undefined reference to `ps_pdread'
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libthread_db.so:
undefined reference to `ps_lgetfpregs'
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libthread_db.so:
undefined reference to `ps_lgetregs'
collect2: ld returned 1 exit status

Doing a lot of searches in glibc, etc. sources, it seems that those
functions are only implemented inside gdb itself.
Also, there is no Linux documentation for the linuxthread_db calls (I found
similar ones on a Sun page ...)

Anybody knows what these functions are good for and how to implement these,
and/or also hints on how to use the libthread_db functions at all ?

Thanks

Martin
Paul Pluzhnikov
2004-11-03 14:51:32 UTC
Permalink
Post by Martin Koller
When I do gcc -o father father.c -lthread_db I get
undefined reference to `ps_pdwrite'
...
Doing a lot of searches in glibc, etc. sources, it seems that those
functions are only implemented inside gdb itself.
That's right: *you* are supposed to provide these.
Post by Martin Koller
Also, there is no Linux documentation for the linuxthread_db calls (I found
similar ones on a Sun page ...)
Read this page:
http://docs.sun.com/db/doc/816-0216/6m6nguphk?a=view

In particular:

To be able to inspect and manipulate target processes, libthread_db
makes use of certain process control primitives that must
be provided by the process using libthread_db. The imported
interfaces are defined in proc_service(3PROC). In other words,
the controlling process is linked with libthread_db, and it calls
routines in libthread_db. libthread_db in turn calls certain
routines that it expects the controlling process to provide. These
process control primitives allow libthread_db to:

* Look up symbols in a target process.
...

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Loading...