From nobody Sun Jul 20 21:40:19 2025 X-Original-To: dev-commits-src-main@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 4blcQQ6TP2z62dQ5; Sun, 20 Jul 2025 21:40:30 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx-01.divo.sbone.de (mx-01.divo.sbone.de [IPv6:2003:a:140a:2200:6:594:fffe:19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature ECDSA (prime256v1) client-digest SHA256) (Client CN "mx-01.divo.sbone.de", Issuer "E5" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4blcQP3pKQz3p9l; Sun, 20 Jul 2025 21:40:29 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=zabbadoz.net header.s=20240622 header.b=JREfaGaP; spf=pass (mx1.freebsd.org: domain of bzeeb-lists@lists.zabbadoz.net designates 2003:a:140a:2200:6:594:fffe:19 as permitted sender) smtp.mailfrom=bzeeb-lists@lists.zabbadoz.net; dmarc=pass (policy=none) header.from=zabbadoz.net Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:1025]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by mx-01.divo.sbone.de (Postfix) with ESMTPS id 28F73A64809; Sun, 20 Jul 2025 21:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zabbadoz.net; s=20240622; t=1753047617; bh=JI3xnDoMp09hzAbnT+nxyVNbuxaUqCHkcIl+aZo85w0=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=JREfaGaPw5ug44EqvX9um3tOYlj0njFrDkCqAmKGZf+9+uQzM0bU3xnPzC4Fb4oqU UmBfvg/VN5WUITEzaYEu0lrrnrGAB3F25tpbpH6P9Ad7fZgCdZQSs9x8ZeEgoWWZVS s1qVoR4TKG9CUlDX488UENM2Y/+rSYszdMsh6shf22HxXgMTx6kSuO0QFPpInIQ2q3 vPNkl5vCMio4XUeU1ua0/Y1lbo48czexInC+nMI7+Xu12FMcnBmduqTMtbthi6pJrW 4XJDT414LiJyz+Xme+gQRsZejB3PUFFyqIWHERP7s81hDcRQPd+roHuY6sbUoI6WAb VXDXjZkM0vz0wwMMFRvGjDE01ZWHeRWZF2iA7CaXCbagUk387/4XlGLB/LnRozc1IN Sx30W3comSH4mLn+5vjGwABbm5YNUOTCW068nQTy6NdNSKX6AD36dydlLVipu46yRb N2WeTDRrV7Ak/dUDYx6MGJczeI4LatuaXIH0Cjt9px83gB5dH+9QbxBu7GTP+7gxuP 7hXz6tyOKyzxqwTL2bpm/rKarpFaBhtogLywUJN0UplnMBKko0DwO7FvK8d4cuEQAk DG9xRCABcg6CmNnxvt/ZvXDt4A6e99yOkFa/HQcy4aGVZiDUJ5LXuXdY3JGuraCtsZ aHCBQDkbo1U8hpJPZ/lVAKCs= Received: from content-filter.t4-02.sbone.de (content-filter.t4-02.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:2742]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 373902D029E2; Sun, 20 Jul 2025 21:40:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:4902:0:7404:2:1025]) by content-filter.t4-02.sbone.de (content-filter.t4-02.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:2742]) (amavisd-new, port 10024) with ESMTP id 1-owy431V2FA; Sun, 20 Jul 2025 21:40:20 +0000 (UTC) Received: from strong-iwl0.sbone.de (strong-iwl0.sbone.de [IPv6:fde9:577b:c1a9:4902:a66b:b6ff:fe40:39a9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 29DF42D029D8; Sun, 20 Jul 2025 21:40:19 +0000 (UTC) Date: Sun, 20 Jul 2025 21:40:19 +0000 (UTC) From: "Bjoern A. Zeeb" To: "Simon J. Gerraty" cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: e67aef419093 - main - Add DEBUG_PRINTF to stand.h In-Reply-To: <202507172337.56HNbQvv083962@gitrepo.freebsd.org> Message-ID: <2n0q6oq1-9r92-q0p4-r97n-p167q13p4p4p@yvfgf.mnoonqbm.arg> References: <202507172337.56HNbQvv083962@gitrepo.freebsd.org> X-OpenPGP-Key-Id: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spamd-Result: default: False [-3.08 / 15.00]; NEURAL_HAM_SHORT(-0.95)[-0.949]; NEURAL_HAM_MEDIUM(-0.92)[-0.918]; DMARC_POLICY_ALLOW(-0.50)[zabbadoz.net,none]; NEURAL_HAM_LONG(-0.22)[-0.218]; R_DKIM_ALLOW(-0.20)[zabbadoz.net:s=20240622]; R_SPF_ALLOW(-0.20)[+ip6:2003:a:140a:2200:6:594:fffe:19]; MIME_GOOD(-0.10)[text/plain]; MISSING_XM_UA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:3320, ipnet:2003::/19, country:DE]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; RCVD_VIA_SMTP_AUTH(0.00)[]; MLMMJ_DEST(0.00)[dev-commits-src-all@FreeBSD.org,dev-commits-src-main@FreeBSD.org]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[zabbadoz.net:+] X-Rspamd-Queue-Id: 4blcQP3pKQz3p9l X-Spamd-Bar: --- On Thu, 17 Jul 2025, Simon J. Gerraty wrote: > The branch main has been updated by sjg: > > URL: https://cgit.FreeBSD.org/src/commit/?id=e67aef419093b08984b8a2de535bc3e4ce13e087 > > commit e67aef419093b08984b8a2de535bc3e4ce13e087 > Author: Simon J. Gerraty > AuthorDate: 2025-07-17 23:36:17 +0000 > Commit: Simon J. Gerraty > CommitDate: 2025-07-17 23:36:17 +0000 > > Add DEBUG_PRINTF to stand.h Given stand.h is included in other parts of the kernel and I don't know even how indrectly for the error case I have, this feels problematic. I know the experimental USB code I am testing has it's own cleamup to do but I did run into the conflict of DEBUG_PRINTF being re-defined there. Given the generic name I wonder if this should be STAND_DPRINTF or other? I admit, there's not much code exporting DEBUG_PRINTF or DPRINTF macros so this may just be the one and only case; not sure how much other vendor code is out there... > stand/ is mostly debugged with printfs, in an ad hoc and sometimes > fragile manner. For example BOOTP_DEBUG in bootp.c cannot be defined > unless NETIF_DEBUG is defined in dev_net.c or build fails for lack of the > symbol debug. > > The DEBUG_PRINTF implementation in stand.h addresses that and allows > for more control over debug output. It is compatible with the > usage in libsecureboot. > > Simply define _DEBUG_LEVEL to the desired level of debug > or in the case of libsecureboot _DEBUG_LEVEL_VAR to the variable that > will hold that value - default is _debug which is static so each > translation unit can be controlled independently. > > The 1st arg to DEBUG_PRINTF is a level which must be greater than or > equal to _DEBUG_LEVEL_VAR if the printf is to be called. > See libsecureboot for more examples. > > Reviewed by: imp > Sponsored by: Juniper Networks, Inc. > Differential Revision: https://reviews.freebsd.org/D51269 > --- > lib/libsecureboot/h/libsecureboot.h | 1 + > stand/common/dev_net.c | 57 ++++++++------------------- > stand/libsa/bootp.c | 78 +++++++++---------------------------- > stand/libsa/pkgfs.c | 33 +++++++++------- > stand/libsa/stand.h | 13 +++++++ > 5 files changed, 68 insertions(+), 114 deletions(-) .... > diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h > index e1188fb73a26..8b7d93074ef2 100644 > --- a/stand/libsa/stand.h > +++ b/stand/libsa/stand.h > @@ -558,4 +558,17 @@ void tslog_getbuf(void ** buf, size_t * len); > > __END_DECLS > > +/* define _DEBUG_LEVEL n or _DEBUG_LEVEL_VAR before include */ > +#ifndef DEBUG_PRINTF > +# if defined(_DEBUG_LEVEL) || defined(_DEBUG_LEVEL_VAR) > +# ifndef _DEBUG_LEVEL_VAR > +# define _DEBUG_LEVEL_VAR _debug > +static int _debug = _DEBUG_LEVEL; > +# endif > +# define DEBUG_PRINTF(n, args) if (_DEBUG_LEVEL_VAR >= n) printf args > +# else > +# define DEBUG_PRINTF(n, args) > +# endif > +#endif > + > #endif /* STAND_H */ > -- Bjoern A. Zeeb r15:7