Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print stack trace of all threads without attaching GDB

Is it possible to programatically print out stack trace of all running threads without attaching GDB? The application is running on an embedded system with Linux.

I've found a very similar thread but the solution uses a special GDB command.

like image 803
c0dehunter Avatar asked Dec 29 '25 12:12

c0dehunter


1 Answers

This has been solved with the help of this thread and this thread.

Quoting:

Signal Handling with the help of backtrace can solve your purpose.

I mean if you have a PID of the Thread, you can raise a signal for that thread. and in the handler you can use the backtrace. since the handler would be executing in that partucular thread, the backtrace there would be the output what you are needed.

like image 128
c0dehunter Avatar answered Jan 01 '26 02:01

c0dehunter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!