0

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?

4 Answers4

1

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)

Technologeeks
  • 7,674
  • 25
  • 36
0

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.

pmdj
  • 22,018
  • 3
  • 52
  • 103
0

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. :-)

Sid Moore
  • 11
  • 2
0

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

Vivek
  • 564
  • 4
  • 13