Reputation: 11
In Linux, I can use echo t > /proc/sysrq-trigger
to dump the kernel call stack of all threads in system.
Is there any method in Mac OS X for the same purpose? or any method to dump kernel stack of one process?
Upvotes: 0
Views: 1126
Reputation: 7907
Short answer: procexp 0 threads (as root) will do the trick, where procexp is "Process Explorer" from http://newosxbook.com/tools/procexp.html .
Slightly Longer answer: - Dtrace is overkill and will need SIP disablement - stackshot is deprecated since its underlying syscall (#365) was removed - A replacement, stack_snapshot_with_config(#491) can be used programmatically as well (this is what drives the above tool)
Upvotes: 1
Reputation: 564
From http://www.brendangregg.com/DTrace/DTrace-cheatsheet.pdf:
sudo dtrace -n 'fbt:::entry { stack(10); ustack(5) }'
prints 10 kernel frames, 5 userland frames
Upvotes: 0
Reputation: 11
Hmm... I didn't code on Mac OS X for serval years. But a tool with name 'stackshot' can help you do this. Try to google it to get the usage. :-)
Upvotes: 0
Reputation: 23438
The answer is probably dtrace. I know Instruments.app (or iprofiler) can do probe based profiling, so it takes periodic stack traces. (user or kernel; your choice) As far as I'm aware this is all based on dtrace, although I don't know it well enough to be able to tell you a way to take a one-off trace.
Upvotes: 0