Ubuntu – Is there tool to see call-stack of running thread similar to Process Explorer by Sysinternals

debuggingsoftware-recommendationsystem-monitor

Is there tool to see call-stack of running thread similar to Process Explorer by Sysinternals ?

So far I tried htop, qps and Linux Process Explorer. None of them can provide that information.

Thanks!

Best Answer

  • Gdb, the GNU debugging utility, can provide such functionality, although only for selected programs or processes individually. There is not an easy way to do it and switch between the call-stacks of the processes running on the system like the Sysinternals program does on Windows. However, you could try pstack, but I have not had much success with it.

    You also have to install the dbg packages (i.e. the symbol packages) so that any gdb call-stack backtrace will work. See the Ubuntu wiki for more information on these packages. Basically, the dbg version of the package is installed very like the normal one is. You run, for example,

    sudo apt-get install xserver-xorg-core-dbg
    

    You can do a backtrace on a program by starting the program under gdb or you can do one on a program already running by attaching gdb to that process: please see here for further details.

    Please see the official manual for more information on gdb and backtracing and more generally useful information is here at the Ubuntu debugging page.

    Additional ways of analysing running processes using strace,etc, which are of use to developers, etc, in analysing a process and its system calls, as opposed to stack calls, have been moved to this question here (as I thought they are now more relevant there):