htop
htop copied to clipboard
Backtrace feature similar to strace
Hello,
currently i found it very useful to hit S key in the htop, to open strace window of selected thread. I absolutely love it and use it everyday. I've figured it currently executes following command:
strace -T -tt -s 512 -p 1497796
Would it also be possible to map B key to execute following command and show it's output?
cd /proc/1497796/cwd; gdb -batch -ex "bt" /proc/1497796/exe 1497796
I prints backtrace like this:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
0xf7f6a549 in __kernel_vsyscall ()
#0 0xf7f6a549 in __kernel_vsyscall ()
#1 0xf7a9a713 in __lll_lock_wait () from /usr/lib32/libpthread.so.0
#2 0xf7a92879 in pthread_mutex_lock () from /usr/lib32/libpthread.so.0
#3 0xf7e9999a in pthread_user_data_lock () at /home/dev/lib/pthread_extra/pthread_user_data.c:19
#4 0xf7e999eb in pthread_user_data_internal (thread=4050168512) at /home/dev/lib/pthread_extra/pthread_user_data.c:34
#5 0xf7e99379 in pthread_pause_enable () at /home/dev/lib/pthread_extra/pthread_pause.c:84
#6 0xf7e9953c in pthread_extra_thread_wrapper (arg=0x91eb8b0) at /home/dev/lib/pthread_extra/pthread_pause.c:253
#7 0xf7a90388 in start_thread () from /usr/lib32/libpthread.so.0
#8 0xf7d613da in clone () from /usr/lib32/libc.so.6
[Inferior 1 (process 1497796) detached]
Good thing about this is that i can see where the individual threads are getting stuck without having to use gdb manualy to attach to individual thread.
Please note that i use cd /proc/1497796/cwd; before calling gdb itself. The reason is that when using LD_PRELOAD with relative path, gdb can only find it when its run in same directory as the traced process.
Perhaps in addition to B key for backtrace, there can be even D key to launch full blown GDB attached to that process and switched to thread.