8

On linux in order to view the process stack at a given time we generally use

pstack <pid>

I am wondering what is the equivalent of the same in osx.

thanks

Joydeep sinha
  • 159
  • 2
  • 8

2 Answers2

12
sudo /usr/libexec/stackshot -i -u -p <pid>

This appends a stack trace of all threads of the process in question to the file /Library/Logs/stackshot-syms.log . Consider to remove the file stackshot-syms.log before calling stackshot. See: stackshot(1)

Note: stackshot is no longer included with OS X 10.11 EL Capitan. Use the lldb debugger instead:

echo "thread backtrace all" | lldb -p <pid>

lldb is part of the command line developer tools. If you don't have lldb on your machine, a popup will help with installing XCode.

chw1k
  • 186
  • 1
  • 5
4

Appears "an" equivalent is the sample command in OS X:

sample <pid> 0 takes a single stacktrace sample.

rogerdpack
  • 62,887
  • 36
  • 269
  • 388