xref: /freebsd/share/man/man4/dtrace_kinst.4 (revision 38a52bd3b5cac3da6f7f6eef3dd050e6aa08ebb3)
1.\" Copyright (c) 2022 Christos Margiolis <christos@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd October 01, 2022
28.Dt DTRACE_KINST 4
29.Os
30.Sh NAME
31.Nm dtrace_kinst
32.Nd a DTrace provider for tracing arbitrary instructions in a given kernel
33function.
34.Sh SYNOPSIS
35kinst::<function>:<instruction>
36.Sh DESCRIPTION
37.Pp
38The DTrace
39.Nm kinst
40provider allows the user to trace any instruction in a given kernel function.
41<function> corresponds to the function to be traced, and <instruction> is the
42offset to the specific instruction, and can be obtained from the function's
43disassembly using
44.Xr kgdb 1 .
45.Pp
46.Nm kinst
47creates probes on-demand, meaning it searches for and parses the function's
48instructions each time
49.Xr dtrace 1
50is run, and not at module load time. This is in contrast to FBT's load-time
51parsing, since
52.Nm kinst
53can potentially create thousands of probes for just a single function, instead
54of up to two (entry and return) in the case of FBT.
55.Sh EXAMPLES
56.Pp
57Find the offset to the third instruction in
58.Fn vm_fault
59and trace it:
60.Bd -literal -offset indent
61# kgdb
62(kgdb) disas /r vm_fault
63Dump of assembler code for function vm_fault:
64   0xffffffff80876df0 <+0>:     55      push   %rbp
65   0xffffffff80876df1 <+1>:     48 89 e5        mov    %rsp,%rbp
66   0xffffffff80876df4 <+4>:     41 57   push   %r15
67
68# dtrace -n 'kinst::vm_fault:4'
69.Ed
70.Pp
71Trace all instructions in
72.Fn amd64_syscall :
73.Bd -literal -offset indent
74# dtrace -n 'kinst::amd64_syscall:'
75.Ed
76.Sh IMPLEMENTATION NOTES
77The provider is currently implemented only for amd64.
78.Sh SEE ALSO
79.Xr dtrace 1 ,
80.Xr kgdb 1
81.Sh HISTORY
82The
83.Nm kinst
84provider first appeared in
85.Fx
8614.0.
87.Sh AUTHORS
88This manual page was written by
89.An Christos Margiolis Aq Mt christos@FreeBSD.org .
90