[Development report #1] Improve the kinst DTrace provider
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 13 Feb 2023 15:03:36 UTC
Since February 01, 2023, I've been working on a FreeBSD Foundation sponsored project to extend the kinst DTrace provider. kinst is a new DTrace provider created by me and Mark Johnston (markj@) that allows for arbitrary instruction tracing within a kernel function. kinst probes take the form `kinst::<function>:<offset>`, where <offset> is the specific instruction. The offsets can be obtained from the function's disassembly using kgdb(1). If no <offset> is specified, kinst will trace all instructions in that function. It is part of the base system from FreeBSD 14.0 onwards. This project's goals are to implement inline function tracing, port kinst to riscv and/or arm64, as well as a few additions to the D language. So far, I've been working on a standalone program [1], which uses the DWARF Debugging Standard [2] to find all call sites of a given inline function. I've published some notes [3] on how we can extract useful information about inline functions. The program takes an inline function name and a debug file and outputs all call sites in the following format: compilation_unit1_definition:line [lower_bound - upper_bound] inline_call1_file:line [lower_bound - upper_bound] inline_call2_file:line ... compilation_unit2_definition:line [lower_bound - upper_bound] inline_call1_file:line ... For example: $ inlinecall critical_enter /usr/lib/debug/boot/kernel/kernel.debug /usr/src/sys/sys/systm.h:175 [0xffffffff8086f47a - 0xffffffff8086f48b] /usr/src/sys/sys/buf_ring.h:80 /usr/src/sys/sys/systm.h:175 [0xffffffff808b0b4a - 0xffffffff808b0b5b] /usr/src/sys/sys/buf_ring.h:80 /usr/src/sys/sys/systm.h:175 [0xffffffff80955264 - 0xffffffff80955275] /usr/src/sys/sys/smr.h:111 /usr/src/sys/sys/systm.h:175 [0xffffffff80a051f4 - 0xffffffff80a05208] /usr/src/sys/kern/kern_malloc.c:431 [0xffffffff80a0514c - 0xffffffff80a0515b] /usr/src/sys/kern/kern_malloc.c:388 ...more This program is more of an exercise in libdwarf. Parts of the code will be added to libdtrace in order to implement inline tracing. Christos [1] https://git.sr.ht/~crm/inlinecall [2] https://dwarfstd.org/ [3] https://margiolis.net/w/dwarf_inline/