I debug a multi thread process using GDB.
When I pause the debug to run some commands in GDB termial, how can I switch to another thread context?
When I stop debugging GDB is always on the main thread, but I want to switch for example to thread 1234
you can get thread_id from this command, such as "helloworld" thread
ps -o comm,tid -T `pgrep your_process_name` | grep helloworld
helloworld 12345
and lookup for thread number of it in gdb
gdb attach `pgrep your_process_name`
thread find 12345
Thread 3 has target id 'LWP 12345'
then switch to it
thread 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With