tags:

views:

213

answers:

1

This might be genuine question but i am asking here since i was out of any clue when i was asked this question in an interview.

how could we debug a thread which was created by another thread? let's say there is a main process and it calles the function pthread_create to create a thread process which is not joinable and that means both teh main process and the newly created thread process will be eecuting their own tasks and if we start debugging the program how could we navigate to the thread that was created?.

thanks in advance.

+2  A: 

You can attach gdb to the whole process, then use gdb's thread ops to navigate between threads. It might help to print the thread id when pthread_create'ing the thread you want to debug.

Keith Randall
+1. I would probably be lazy and just set a breakpoint on the thread's entry point before setting the process running. I guess that approach only helps if you already have some idea about where in the thread the problem is.
Carl Norum