I am looking to understand what is the state of a specific thread in my software, doing it from another thread. Specifically I'd like to know if it's I/O stuck. I was thinking of doing it by getting the backtrace(unless someone has another idea?), since I know what function it's supposed to be stuck on.. but I can't figure out how to get the backtrace of that specific thread, without calling the SEGFAULT handler... but gdb is able to do it(I doubt he creates SEGFAULTS..)
Can anyone help? any idea?
[Edit] all 3 answers refer to gdb, I KNOW I can do it from gdb, I wanted to know how to do it from a software(even linking to gdb libs somehow would be an answer, but how ? )
I know what function it's supposed to be stuck on.. but I can't figure out how to get the backtrace of that specific thread
You can get backtraces of all threads and try to find function which is supposed to be stuck on in backtraces output. Here is how to get all backtraces in gdb:
(gdb) thread apply all bt
(gdb) info threads [will list all the threads and also indicate the thread you are currently backtracing on]
(gdb) thread apply all bt [will show backtrace of all threads so that you can see which thread is stuck on the function you are interested in before switching to that thread]
(gdb) thread #threadno [will switch the backtrace to the specific thread you are interested in and a bt will show its backtrace.]
Ref http://www.delorie.com/gnu/docs/gdb/gdb_25.html
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