Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pstack a process on OSX 10.9

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

like image 737
Joydeep sinha Avatar asked Jul 02 '14 04:07

Joydeep sinha


2 Answers

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.

like image 135
chw1k Avatar answered Nov 14 '22 10:11

chw1k


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

sample <pid> 0 takes a single stacktrace sample.

like image 1
rogerdpack Avatar answered Nov 14 '22 09:11

rogerdpack