From nobody Thu Mar 23 14:25:47 2023 X-Original-To: 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 4Pj71D424Qz41Q0f for ; Thu, 23 Mar 2023 14:25:52 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pj71C4SDdz4Y7J for ; Thu, 23 Mar 2023 14:25:51 +0000 (UTC) (envelope-from markjdb@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=klFPaRBe; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::836 as permitted sender) smtp.mailfrom=markjdb@gmail.com; dmarc=none Received: by mail-qt1-x836.google.com with SMTP id n2so26752057qtp.0 for ; Thu, 23 Mar 2023 07:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679581551; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :from:to:cc:subject:date:message-id:reply-to; bh=nMOuAX9Wdi+4ZQvGb0gLuH4byqKWi8ZH/0oGxROZ0Jo=; b=klFPaRBe5dQY7G1+/Y7xqGCaezw1PWmMatSp6b9RmKfl+GQdBFF07C2eJBjfOegixQ Vhc5MYD9MWKB+w5zzjTXQvQHPUJ9p7ektImh8LjtIYTYuvKCOU1PmNza011sezsUVNSc qRBiXyDy3y+Bb3xsYHBQVRGb7i2bjmSNxgVDgOMOHneTxl4vRec0uhhJX59UeQ6KIkQh h8HwYzqservA7WVSn/OlTzESeccczJK9sx1kS29U3xzku/lgEcYBK94jfGBgnfS8Ve9N vTQ2Pg3IL0yCYGOq/6qaS3V0uJMYsNCxN/tTiDwc+pifLkpOSuG6/vy6zpKlMCyb9inD CF4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679581551; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nMOuAX9Wdi+4ZQvGb0gLuH4byqKWi8ZH/0oGxROZ0Jo=; b=mZyIcz1jl42WgjbWHnIVVuCeVt+337jhOquOZtl2oC1zArKJ8J8g7sxPsLMY3Riwe3 cibCoGq7RUijqw8UPu4DTEqtE+5G/pq1AGcd/2xbDW4uNyhnJeMDyGE8nAiKF8G0gnBG 7e5bG9ZZloYYu6mxGnMOJlA7WlhVoqTpOb7NhtE/pXh8+EeqAEBiC+VkZDPAwet8xopR 111ZzAlq9Ogk24PxG99zdXskwdNZfABrWQRjgpFqVd+2LM1IEcD+D5mk5HIIWmPBbA/0 WZ1EB9LwCPk3Z9fVT47pgB3poerxnsvcWimnPbwlcIpWeZCgivHaTMQnBeK5BOKydSM8 EjpA== X-Gm-Message-State: AO0yUKVlaT9ZcmDoszBnmAmKigI9xTzvRMMWu4EK8coOisrf43cHS2hK Q3AHcoi3BnMZVhecgwkXDcKiK8++Z64= X-Google-Smtp-Source: AK7set8EaUhXhhpKSolhkiN3Jj63CUB2sLR7wRpRpaG3ODjBnvzoHdx2PzSDWLVct1ul1V+WsIAJzQ== X-Received: by 2002:ac8:5ccc:0:b0:3d5:cf4e:bd0 with SMTP id s12-20020ac85ccc000000b003d5cf4e0bd0mr12513028qta.63.1679581550687; Thu, 23 Mar 2023 07:25:50 -0700 (PDT) Received: from nuc (192-0-220-237.cpe.teksavvy.com. [192.0.220.237]) by smtp.gmail.com with ESMTPSA id 78-20020a370551000000b0074236d3a149sm4121427qkf.92.2023.03.23.07.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 07:25:50 -0700 (PDT) Date: Thu, 23 Mar 2023 10:25:47 -0400 From: Mark Johnston To: Domagoj Stolfa Cc: "Bjoern A. Zeeb" , dtrace@freebsd.org Subject: Re: USDT support (in build framework)? Message-ID: References: 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spamd-Result: default: False [-1.70 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; MID_RHS_NOT_FQDN(0.50)[]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_THREE(0.00)[3]; RCVD_TLS_LAST(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::836:from]; TAGGED_RCPT(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[dtrace@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; ARC_NA(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; DKIM_TRACE(0.00)[gmail.com:+]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; MLMMJ_DEST(0.00)[dtrace@freebsd.org]; FREEMAIL_TO(0.00)[gmail.com]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 4Pj71C4SDdz4Y7J X-Spamd-Bar: - X-ThisMailContainsUnwantedMimeParts: N On Thu, Mar 23, 2023 at 11:58:07AM +0000, Domagoj Stolfa wrote: > Hi: > > > I've done this for bhyve, specifically for virtio-net. I believe this is > the whole patch I needed: > > > +OBJS:=bhyve_provider.o ${OBJS} > +DTRACE_OBJS=${SRCS:C/\.c/.o/} > + > +beforelinking: > +       dtrace -G -s ${BHYVE_SRCDIR}/bhyve_provider.d ${DTRACE_OBJS} > + > > > however, it has been a while and I don't 100% recall if anything else > was necessary. I had to create a helper DTRACE_OBJS because using OBJS > would cause linking to fail later on. I'm sure there are better ways of > doing it, but this seems to work for me. Let me know if it fails! For a while it's been possible to simply add the provider definition to SRCS. We have rules in share/mk that handle the rest. Below is a patch which adds a USDT probe to cat(1) as an example, the probe just prints the file name of each file that gets processed. BTW, I can't seem to declare a probe argument with type const char * - when dtrace -h generates the header, the const qualifer gets stripped away. That seems like a bug. # dtrace -n 'cat$target:::foo {printf("%s", copyinstr(arg0));}' -c "cat /dev/null" dtrace: description 'cat$target:::foo ' matched 1 probe CPU ID FUNCTION:NAME 6 99502 scanfiles:foo /dev/null dtrace: pid 80789 has exited diff --git a/bin/cat/Makefile b/bin/cat/Makefile index 06bb071363f8..81cad980eaa3 100644 --- a/bin/cat/Makefile +++ b/bin/cat/Makefile @@ -5,6 +5,7 @@ PACKAGE=runtime PROG= cat +SRCS= cat.c catprov.d .ifdef BOOTSTRAPPING # For the bootstrap cat we disable all wide char support to allow building diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 5a1fab0c26a0..91f31d0b4668 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -74,6 +74,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "catprov.h" + static int bflag, eflag, lflag, nflag, sflag, tflag, vflag; static int rval; static const char *filename; @@ -266,6 +268,7 @@ scanfiles(char *argv[], int cooked __unused) fd = udom_open(path, O_RDONLY); #endif } + CAT_FOO(__DECONST(char *, filename)); if (fd < 0) { warn("%s", path); rval = 1; diff --git a/bin/cat/catprov.d b/bin/cat/catprov.d new file mode 100644 index 000000000000..5d9d2444cc23 --- /dev/null +++ b/bin/cat/catprov.d @@ -0,0 +1,3 @@ +provider cat { + probe foo(char *); +};