From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 316A53BB695 for ; Wed, 8 Jul 2026 02:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783477143; cv=none; b=DUhmz/afMpVJIYbWtJE23E9tSWse0kz7KcAq9NBOIR3qcQD+1zoyTR8ofmVvypR74aEbTVz59b1tioZnC53mOWmw00oEf72R7QBF7tYDzTBjlW6H9albCmns6sgwEtjeuxU7aOPTmkUr3IJASRxnHD58woT3EaADBzle+2S1NfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783477143; c=relaxed/simple; bh=f1LMLcm7HpUCjY0LgwqyXWI/nbYSKkJlJGfL377JIvQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WxHZnl43ydYt6Y/pEXkjQ022nEBYxFeAeZrdUcIBOoUFobkgpZ3VmUZCKoy4ES1lXkrFZDkJlTPmdXRdQEslG9O8W1skWnbnAppa2kSL+khIs5ESHVVpgWMNj6Gp2UfK0Xwo2QLAoNsczhvWZeW38ZnEyUmGbJfj4ws6k4pPMHE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=f+9tixgG; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f+9tixgG" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-495d310b587so71319b6e.3 for ; Tue, 07 Jul 2026 19:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783477140; x=1784081940; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=k3atFQ3HfHjIkDoR1IKy8zbGv01SGi/asouemJLY7Wc=; b=f+9tixgGI6vAOSH8Yy51o4nLhf/xg5DNdd9rRKA/F2MSMfsIFgGdNROB0EpBarjBEV QHCdZkcWEGUZ/ZxUXq1uMN57Jk+z2Qvmn3vR4AaaIpZ34AepTmMuOlKeTpAOED1FEgra 3rXeZ/cdkF7YDEf82UekpSmkPozT2yKjnY94HTxHMzJOB/QCz4/1vBoAb86TqwmSobvZ xDjVBZx7g6TbnZk9IzfJs3ouchR7u+1ri2zA4eJmDVRc6fng+Dz/tY83Q/MuSjM1mFso ipAfaV6IovFmVvv67SZAQU3sDJwdObhAv87mblY7XhXZUIKzqZzPIuQg/THNIrbAdeJM 9z5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783477140; x=1784081940; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=k3atFQ3HfHjIkDoR1IKy8zbGv01SGi/asouemJLY7Wc=; b=eTg3fm4bEN5gRz3/DMogcqL8MNdx4rEVnv4UUCtKyQQ014wTKqKqBns1juvSTqaexe A9TRpCGp1Z+9R2+GncbePopW4M99uF5n7DXZZjzA8EmlIcfixdJmSjz40uUgYsxu+Sej sqkBMZ8JPjhKFq4GGh1dGNSgf7cPI5PMFzoCaOWvYtMYTva9L1rPrQ4+IlKzyRUopZ2+ a37bs1gkwZ9d6HIo4wDKUYaWCv7pclUM3Cb7gI5bjtzAOpIgqNq0eYaV+DZV4yXA44Ym 5EvuwzPX1DDx6SxlMPpUnkE2HXP1p35L9YU2N+c/7hmTf2BY8212gc32xKECMHIh+uc8 tPlA== X-Forwarded-Encrypted: i=1; AFNElJ/+/kHe+aAYIEngIxDPbBWvP26QsveIxJYTR4V5KVqf5yoJq5BOpVcTxWv/23rD9b3WhTuH2K5Hw34TnBj1@vger.kernel.org X-Gm-Message-State: AOJu0YzZCRPbpPdGUVjchT+omzZFhjqhX4hzYdy8Yw8Zh+vjNZ0PNXr0 x6oua+3N1si0A98jxh1uRWO38FPDQdx6jU8pMOD6mFzvYzhwue/Z5JY+ X-Gm-Gg: AfdE7cnQqvyH4eInNsFJFCSHe+wgffnJ1P/JntVNyWzbuOVo1c1z5GUAVnymiXJbaUG l5Z3VobUJPBBuGqYpCgMXx2FsUnSNKKKHopikFnj6kgiWARLfEeylaUrziph/ft0Pr/FH/1ylhI ot/hmekVNrkfvDtQg00T6zMIRGbI5jkAmUOY0bVsz3drUCkP1RgBY2SMArQuHr+C9XmUqXx2ayv twUZeyJ1NdzocmctrPY5HKrpKulvnvg7aE4Em84GIWul0gLmCnlVYZ+4XFto8mDyXJVq0SFSGRq +R1zvd7YBl75uFoJG+20XtORtCoPQPHHvZnzWK8aJPh7aENwLQAlNnoKqI5PigfPRiv/jJ9r/PB APyazFTGhYqVECZl2IYWNGnpofbkozDK8TiYrJLjG2W6C3x6nmRUwKZfNBS5x0qD4PKU164vY3V 3Pd/hM/MB3wPzvbhXN+Zb6tP4GYWi4eMlwDjfbT5MHo57lsoEj6eg= X-Received: by 2002:a05:6808:124b:b0:496:e0:a47b with SMTP id 5614622812f47-4a2039be59bmr318703b6e.20.1783477139780; Tue, 07 Jul 2026 19:18:59 -0700 (PDT) Received: from [192.168.0.245] (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 5614622812f47-4a1aa006f74sm799975b6e.0.2026.07.07.19.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 19:18:59 -0700 (PDT) From: Jim Cromie Date: Tue, 07 Jul 2026 20:18:18 -0600 Subject: [PATCH v6 18/24] dyndbg: macrofy a 2-index for-loop pattern Precedence: bulk X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260707-dd-maint-2-v6-18-381f3edb0045@gmail.com> References: <20260707-dd-maint-2-v6-0-381f3edb0045@gmail.com> In-Reply-To: <20260707-dd-maint-2-v6-0-381f3edb0045@gmail.com> To: Andrew Morton , Jason Baron , Greg Kroah-Hartman , Jonathan Corbet , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Arnd Bergmann , Luis Chamberlain , Petr Pavlu Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783477102; l=2812; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=f1LMLcm7HpUCjY0LgwqyXWI/nbYSKkJlJGfL377JIvQ=; b=trvcg9ZaNLsNIpDb6Uahb5ZcOJlCuDAsyAa+3eRBSZB7MO61jqTE3zrEhQimlEmwi6binJuG6 P6IJQn6YMJGAAWzMGNmmmraV/JO+uz6t5b2sQ/9PueOX3S0uipM51O6 X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= dynamic-debug currently has 2 __sections (__dyndbg, __dyndb_classes), struct _ddebug_info keeps track of them both, with 2 members each: _vec and _vec#_len. We need to loop over these sections, with index and record pointer, making ref to both _vec and _vec_len. This is already fiddly and error-prone, and will get worse as we add a 3rd section. Lets instead embed/abstract the fiddly-ness in the `for_subvec()` macro, and avoid repeating it going forward. This is a for-loop macro expander, so it syntactically expects to precede either a single statement or a { block } of them, and the usual typeof or do-while-0 tricks are unavailable to fix the multiple-expansion warning. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: move RvB after SoB --- lib/dynamic_debug.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 6b699ed23d26..d99c69b9ad12 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -149,6 +149,20 @@ static void v3pr_info_dq(const struct ddebug_query *query, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } +/* + * simplify a repeated for-loop pattern walking N steps in a T _vec + * member inside a struct _box. It expects int i and T *_sp to be + * declared in the caller. + * @_i: caller provided counter. + * @_sp: cursor into _vec, to examine each item. + * @_box: ptr to a struct containing @_vec member + * @_vec: name of a member in @_box + */ +#define for_subvec(_i, _sp, _box, _vec) \ + for ((_i) = 0, (_sp) = (_box)->_vec; \ + (_i) < (_box)->num_##_vec; \ + (_i)++, (_sp)++) /* { block } */ + static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table const *dt, const char *class_string, int *class_id) @@ -156,7 +170,7 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons struct ddebug_class_map *map; int i, idx; - for (map = dt->classes, i = 0; i < dt->num_classes; i++, map++) { + for_subvec(i, map, dt, classes) { idx = match_string(map->class_names, map->length, class_string); if (idx >= 0) { *class_id = idx + map->base; @@ -1167,8 +1181,7 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug * the builtin/modular classmap vector/section. Save the start * and length of the subrange at its edges. */ - for (cm = di->classes, i = 0; i < di->num_classes; i++, cm++) { - + for_subvec(i, cm, di, classes) { if (!strcmp(cm->mod_name, dt->mod_name)) { if (!nc) { v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n", -- 2.55.0