From nobody Mon Feb 13 15:03:36 2023 X-Original-To: freebsd-dtrace@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PFnfh1TRCz3rF0f for ; Mon, 13 Feb 2023 15:03:56 +0000 (UTC) (envelope-from christos@freebsd.org) Received: from margiolis.net (mail.margiolis.net [95.179.159.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4PFnff6pPWz4Kvw; Mon, 13 Feb 2023 15:03:54 +0000 (UTC) (envelope-from christos@freebsd.org) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=margiolis.net header.s=default header.b=eXA5WSKi; spf=softfail (mx1.freebsd.org: 95.179.159.8 is neither permitted nor denied by domain of christos@freebsd.org) smtp.mailfrom=christos@freebsd.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=default; bh=ndDQk9IG3Zbc lB3lKfm2oYJilW/S74lr3LXz581DUwY=; h=subject:cc:to:from:date; d=margiolis.net; b=eXA5WSKiTFyhTbrcM6fyIVIzuVym/2gQvybqmQD4iylXO05dwm7 tLpCmoA/9PHHvBdBYtUAhoZZPdhqHn//V+eHNNZ1NT+zFago8XlNy2LMEb1MveGb8bunKJ hVyc+tERwDYq2w41PT16ALdvO2tHU7jxluqqFdMAZbENFn7LG8= Received: from pleb (ppp-94-66-59-44.home.otenet.gr [94.66.59.44]) by margiolis.net (OpenSMTPD) with ESMTPSA id 8f3e161d (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Mon, 13 Feb 2023 15:03:46 +0000 (UTC) Date: Mon, 13 Feb 2023 17:03:36 +0200 From: Christos Margiolis To: status-updates@freebsdfoundation.org Cc: freebsd-dtrace@freebsd.org, markj@freebsd.org Subject: [Development report #1] Improve the kinst DTrace provider Message-ID: <20230213150336.x2pugvnzdfpgvspr@pleb> List-Id: A discussion list for developers working on DTrace in FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-dtrace List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-dtrace@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spamd-Result: default: False [-2.80 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; MID_RHS_NOT_FQDN(0.50)[]; R_DKIM_ALLOW(-0.20)[margiolis.net:s=default]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[freebsd-dtrace@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[margiolis.net:+]; ASN(0.00)[asn:20473, ipnet:95.179.144.0/20, country:US]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DMARC_NA(0.00)[freebsd.org]; RCVD_COUNT_TWO(0.00)[2]; FREEFALL_USER(0.00)[christos]; ARC_NA(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; FROM_HAS_DN(0.00)[]; TO_DN_NONE(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Queue-Id: 4PFnff6pPWz4Kvw X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N 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:::`, where is the specific instruction. The offsets can be obtained from the function's disassembly using kgdb(1). If no 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/