DTRACE_KINST(4)
π DTRACE_KINST(4) β the Kernel Interfaces Manual, bestie edition π
okay so picture this: a whole manual page from the Kernel Interfaces Manual, and it's about dtrace_kinst β and I'm gonna walk you through literally every single thing in it, no skips, no cap π
β¨ NAME β¨
dtrace_kinst β a DTrace provider for tracing arbitrary instructions in a given kernel function π¦
πΈ SYNOPSIS πΈ
kinst::<function>:<instruction>
that's the whole vibe. three little pieces, colon-separated, and you're in π
π DESCRIPTION π
The DTrace kinst provider lets you trace any instruction in a given kernel function. iconic behavior, honestly.
- <function> β corresponds to the function to be traced π«Ά
- <instruction> β the offset to the specific instruction, and you can grab that from the function's disassembly using
kgdbfrom thegdbpackage π₯
kinst creates probes on-demand, meaning it searches for and parses the function's instructions each time dtrace(1) is run, and not at module load time. ngl that's the main character difference here.
This is in contrast to dtrace_fbt(4)'s load-time parsing, because kinst can potentially create thousands of probes for just a single function, instead of up to two (entry and return) in the case of dtrace_fbt(4). the way that's a whole different scale π
A result of this is that dtrace -l -P kinst will not match any probes. yes, really. don't come for me, that's just how it is π
π§ IMPLEMENTATION NOTES π§
The provider is currently implemented only for amd64. that's it, that's the note π
β EXAMPLES β
π find the offset for the third instruction in vm_fault() and trace it, printing the contents of the RSI register
# kgdb
(kgdb) disas /r vm_fault
Dump of assembler code for function vm_fault:
0xffffffff80876df0 <+0>: 55 push %rbp
0xffffffff80876df1 <+1>: 48 89 e5 mov %rsp,%rbp
0xffffffff80876df4 <+4>: 41 57 push %r15
# dtrace -n 'kinst::vm_fault:4 {printf("%#x", regs[R_RSI]);}'
2 81500 vm_fault:4 0x827c56000
2 81500 vm_fault:4 0x827878000
2 81500 vm_fault:4 0x1fab9bef0000
2 81500 vm_fault:4 0xe16cf749000
0 81500 vm_fault:4 0x13587c366000
...
π trace all instructions in amd64_syscall()
# dtrace -n 'kinst::amd64_syscall:'
look at that. no instruction specified, and it ate π₯
π¦ SEE ALSO π¦
go read those too, iykyk π
π HISTORY π
The kinst provider first appeared in FreeBSD 14.0. a whole era β¨
π AUTHORS π
This manual page was written by Christos Margiolis <christos@FreeBSD.org>. ty for your service, king π«Ά
okay bestie that's the whole page, mwah π and before you go: this lovely little Debian build is dated July 16, 2025 β go forth and trace some instructions, periodt πΈπ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2022 Christos Margiolis <christos@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms