Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  PSTACK (1)


pstack - print the backtrace of the running program


See Also


pstack [-loOtv] [-a arg count] [-f frame count] pid


The pstack utility prints the stack backtraces for the running program. The pstack attaches to the traced process using the ptrace 2 debugging interface. If possible, the symbolic name and offset for the function executing in each frame is displayed. The pstack can be directed to print the shared object name, which contains the function.

The first line of the output displays the pid of the traced process, binary name as reported by the kernel, and the currently active osrel version of the ABI for the process. After that, for each thread in the process, the thread id is displayed, followed by the backtrace.

The following options are available:
-a count
  Try to guess the arguments of each function appearing in the backtrace. Not more than count arguments are printed for each function. Ability to correctly read the argument values depends on the architecture and compiler optimization, but it is generally impossible to do.
-f count
  For each thread, print not more than count frames in the backtrace.
-l Instead of walking the stacks of the running threads, print the names of the shared objects loaded into the process address space. The output of the utility resembles the output of ldd(1) command run on the binary.
-o Show the names of the objects which contain the location of the frame current instruction pointer.
-O Same as -o , but displays the full path to the objects instead of only names.
-t Measure and print the time which the target process was suspended to walk the stack frames.
-v Be verbose.


gdb(1), ldd(1), ptrace(2), libunwind(3), procfs(5)


The pstack command is reimplemented by
.An Konstantin Belousov to mimic the user interface of other similar pstack utilities, in particular, the pstack written by
.An Peter Edwards . This version relies on the libunwind library as the stack unwinding backend.


On i386, the argument printing code assumes that the frame layout is standard, which is currently often not the case due to the padding added between return address and previous frame pointer, as done by compilers to align the stack.

On amd64, the argument printing currently does not work. The amd64 ABI specifies that integer arguments are passed in the registers which are not required to be preserved across function calls. As the result, there is typically no way to re-create the arguments values on any frame except the current one.

The symbol names cannot be inferred if the corresponding binary or shared object are already deleted, since libunwind needs to read the symbols from the on-disk ELF image. This could typically occur if the binary or library is reinstalled, but the process uses older version of the binary with the same name.

The pstack only works on the processes executing ELF binaries.

You cannot get a backtrace for the process, to which another debugger is currently attached. The ptrace(2) debugging mechanism used to obtain the neccessary live process information causes some syscalls to return EINTR errors on pstack detach.

The pstack utility cannot yet extract a backtrace from the core dump.

The architecture of the program and pstack shall match (this is libunwind restriction).

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.