user2511624
user2511624

Reputation: 11

How to print kernel call stack in Mac OS X

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

Answers (4)

Technologeeks
Technologeeks

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

Vivek
Vivek

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

Sid Moore
Sid Moore

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

pmdj
pmdj

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

Related Questions