[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

How do I detect when a new thread is created?

There is no API documentation for libpthread_db I understood,
if there is please give me a pointer!

I am afraid I got stuck with digging in the source
code of nptl: How can I make my shared library detect
when the user application started a new thread?

What I need is that a function of the shared library
is called before the new thread executes any code
by itself; the function should be called by an existing
thread (the first one, I assume) or in the very least
- if called by the new thread itself - before any
user code was called or any memory was allocated by
the new thread id (malloc etc).

More important is: how can I implement this callback
after a thread is destructed?  To be precise, it must be
garanteed that the thread will not execute user code anymore,
nor will make additional calls to free() etc.

I've read some of the archives of this list, and at
some point someone said: "look how gdb is doing it",
but ... the libpthread_db interface seems not to provide
any callbacks to begin with; so how could this ever
be implemented? If one has to poll for thread events
like new threads being created, won't it be too late
then? The new thread will already have executed code
by its own then (not to mention that this polling would
consume ridiculous ammounts of cpu).

In desperate need of some documentation,

Carlo Wood <carlo alinoe com>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]