Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Oct 2022 19:00:15 +0300
From:      Christos Margiolis <christos@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        markj@freebsd.org
Subject:   Instruction-level dynamic tracing
Message-ID:  <20221001160015.sce47pwwtqu62vcr@pleb>

next in thread | raw e-mail | index | archive | help
Hello,

Me and markj@ implemented a new DTrace provider (kinst) that allows for
arbitrary kernel instruction tracing. The provider is currently
implemented only for amd64, but we plan to port it to other
architectures in the future as well.

kinst probes take the form of:
	
	kinst:<module>:<function>:<offset>

where "function" is the kernel function to be traced, and "offset" is
the offset to a specific instruction. This offset can be obtained from
the function's disassembly using kgdb.

For example, if I want to trace the second instruction in
amd64_syscall(), I first need to figure out the offset to the
second instruction:

	# kgdb
	(kgdb) disas /r amd64_syscall
	Dump of assembler code for function amd64_syscall:
	   0xffffffff809256c0 <+0>:     55      push   %rbp
	   0xffffffff809256c1 <+1>:     48 89 e5        mov    %rsp,%rbp
	   0xffffffff809256c4 <+4>:     41 57   push   %r15

The offset is 1. To trace it:

	# dtrace -n 'kinst::amd64_syscall:1'

Final code review: https://reviews.freebsd.org/D36851
Any review of the code would be appreciated.

Christos



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20221001160015.sce47pwwtqu62vcr>