Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top