diff options
| author | Christos Margiolis <christos@FreeBSD.org> | 2022-10-11 15:28:17 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2022-10-11 22:19:08 +0000 |
| commit | f0bc4ed144fc59b6f72d90c46b91ca803d3b29ce (patch) | |
| tree | 6520c0745b11dbace68162dfee3ddb14118ba3f3 /sys/cddl/dev/dtrace | |
| parent | 301a27dc65463fc9a909835863ff5566623f6ef2 (diff) | |
kinst: Initial revision
This is a new DTrace provider which allows arbitrary kernel instructions
to be traced. Currently it is implemented only for amd64.
kinst probes are created on demand by libdtrace, and there is a probe
for each kernel instruction. Probes are named
kinst:<module>:<function>:<offset>, where "offset" is the offset of the
target instruction relative to the beginning of the function. Omitting
"offset" causes all instructions in the function to be traced.
kinst works similarly to FBT in that it places a breakpoint on the
target instruction and hooks into the kernel breakpoint handler.
Because kinst has to be able to trace arbitrary instructions, it does
not emulate most of them in software but rather causes the traced thread
to execute a copy of the instruction before returning to the original
code.
The provider is quite low-level and as-is will be useful mostly only to
kernel developers. However, it provides a great deal of visibility into
kernel code execution and could be used as a building block for
higher-level tooling which can in some sense translate between C sources
and generated machine code. In particular, the "regs" variable recently
added to D allows the CPU's register file to be accessed from kinst
probes.
kinst is experimental and should not be used on production systems for
now.
In collaboration with: markj
Sponsored by: Google, Inc. (GSoC 2022)
MFC after: 3 months
Differential Revision: https://reviews.freebsd.org/D36851
Diffstat (limited to 'sys/cddl/dev/dtrace')
| -rw-r--r-- | sys/cddl/dev/dtrace/dtrace_cddl.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/cddl/dev/dtrace/dtrace_cddl.h b/sys/cddl/dev/dtrace/dtrace_cddl.h index 08b6f80d4bae..b2397d621355 100644 --- a/sys/cddl/dev/dtrace/dtrace_cddl.h +++ b/sys/cddl/dev/dtrace/dtrace_cddl.h @@ -88,6 +88,7 @@ typedef struct kdtrace_thread { void *td_systrace_args; /* syscall probe arguments. */ uint64_t td_fasttrap_tp_gen; /* Tracepoint hash table gen. */ struct trapframe *td_dtrace_trapframe; /* Trap frame from invop. */ + void *td_kinst; } kdtrace_thread_t; /* @@ -117,6 +118,7 @@ typedef struct kdtrace_thread { #define t_dtrace_systrace_args td_dtrace->td_systrace_args #define t_fasttrap_tp_gen td_dtrace->td_fasttrap_tp_gen #define t_dtrace_trapframe td_dtrace->td_dtrace_trapframe +#define t_kinst td_dtrace->td_kinst #define p_dtrace_helpers p_dtrace->p_dtrace_helpers #define p_dtrace_count p_dtrace->p_dtrace_count #define p_dtrace_probes p_dtrace->p_dtrace_probes |
