getting info about threads in gdb/ddd

Abruzzo Forte e Gentile picture Abruzzo Forte e Gentile · Jan 14, 2011 · Viewed 7.3k times · Source

I am debugging a multi threaded application using ddd.

At the same time each second I can see on DDD console out that a new thread is created

 [NewThread 0x455fc940 (LWP 27373)]

and destroyed immediately after it.

 [Thread 0x455fc940  (LWP 27373) exited]

After few minutes I have this text out

 [NewThread 0x455fc940 (LWP 27363)]
 [Thread 0x455fc940  (LWP 27363) exited]
 [NewThread 0x455fc940 (LWP 27367)]
 [Thread 0x455fc940  (LWP 27367) exited]
 [NewThread 0x455fc940 (LWP 27373)]
 [Thread 0x455fc940  (LWP 27373) exited]
 ...and so on..

with this LWP increasing.

The threas comes and go too fast to be displayed using the window I got clicking on Status->Thread. Can you address me a bit about how to get information about that thread?

Do you know why this LWP is increasing all the time? More important how to get the function that is lunched into that thread?

Thank you all AFG

Answer

Marcus Borkenhagen picture Marcus Borkenhagen · Jan 14, 2011

LWP is an acronym and stands for Light Weight Process. It is in effect the thread ID of each newly spawned thread.

On what to do about those spawning and dying threads: you could try set a break point at clone, which is he system call (? am I correct?) which starts a new thread at a given function.

Note: When breaking at clone you know from where the thread will be started, but don't actually have a thread, you can then however set break points at the functions given as argument to clone...

That is, start your program from gdb or ddd with the start command, which sets a temporary break point at the program entry point (i.e. main), than set a break point at clone, continue and see what happens ;).

Update: setting a break point at clone works for me... at least in my test. I should add that this is linux specific - and is actually what pthread_create uses.