From: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
To: mhiramat@kernel.org
Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 5/5] tools/bootconfig: Match literal keys in tracing script helpers
Date: Sat, 31 Oct 2026 19:35:34 +0100 [thread overview]
Message-ID: <694f66b67c017072c0246997a09e67a79ebee04f.1793471731.git.edumucelli@gmail.com> (raw)
In-Reply-To: <cover.1793471731.git.edumucelli@gmail.com>
The xbc shell helpers interpolate bootconfig keys into regular expressions.
Dots in keys consequently match arbitrary characters: asking for
ftrace.options can also return ftraceXoptions. Branch and subkey lookups
also match unrelated keys that merely share the requested prefix.
Compare complete keys literally and require a dot at descendant boundaries.
Keep the optional subkey pattern operating on the suffix only.
Fixes: 7e66ef0046cc ("tools/bootconfig: Add a script to generate ftrace shell-command from bootconfig")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
---
The helper checks cover literal dotted keys, missing keys, branch
boundaries and subkey selection. The original helpers passed one of
five checks; the fixed helpers pass all five. These checks also pass
when combined with the other fixes in this series.
tools/bootconfig/scripts/xbc.sh | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/tools/bootconfig/scripts/xbc.sh b/tools/bootconfig/scripts/xbc.sh
index 1f0ebf50dd2d..16ee590661b4 100644
--- a/tools/bootconfig/scripts/xbc.sh
+++ b/tools/bootconfig/scripts/xbc.sh
@@ -36,21 +36,26 @@ xbc_get_val() { # key [maxnum]
if [ "$2" ]; then
MAXOPT="-L $2"
fi
- grep "^$1 =" $XBC_TMPFILE | cut -d= -f2- | \
+ awk -v key="$1" '$1 == key && $2 == "="' "$XBC_TMPFILE" | cut -d= -f2- | \
sed -e 's/", /" /g' -e "s/',/' /g" | \
xargs $MAXOPT -n 1 echo
}
xbc_has_key() { # key
- grep -q "^$1 =" $XBC_TMPFILE
+ awk -v key="$1" '$1 == key && $2 == "=" { found = 1 }
+ END { exit !found }' "$XBC_TMPFILE"
}
xbc_has_branch() { # prefix-key
- grep -q "^$1" $XBC_TMPFILE
+ awk -v key="$1" '$1 == key || index($1, key ".") == 1 { found = 1 }
+ END { exit !found }' "$XBC_TMPFILE"
}
xbc_subkeys() { # prefix-key depth [subkey-pattern]
__keys=`echo $1 | sed "s/\./ /g"`
__s=`nr_args $__keys`
- grep "^$1$3" $XBC_TMPFILE | cut -d= -f1| cut -d. -f$((__s + 1))-$((__s + $2)) | uniq
+ awk -v key="$1" -v pattern="$3" '
+ index($1, key ".") == 1 &&
+ substr($1, length(key) + 1) ~ ("^" pattern) { print $1 }
+ ' "$XBC_TMPFILE" | cut -d. -f$((__s + 1))-$((__s + $2)) | uniq
}
--
2.53.0
prev parent reply other threads:[~2026-10-31 18:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 18:35 [PATCH 0/5] tools/bootconfig: Fix tracing script filters and histogram dependencies Eduardo Mucelli Rezende Oliveira
2026-10-31 18:35 ` [PATCH 1/5] tools/bootconfig: Read the documented ftrace.notraces key Eduardo Mucelli Rezende Oliveira
2026-10-31 18:35 ` [PATCH 2/5] tools/bootconfig: Preserve quotes in exported event actions Eduardo Mucelli Rezende Oliveira
2026-10-31 18:35 ` [PATCH 3/5] tools/bootconfig: Ignore filter strings when resolving histogram variables Eduardo Mucelli Rezende Oliveira
2026-10-31 18:35 ` [PATCH 4/5] tools/bootconfig: Resolve histogram dependencies until no progress is made Eduardo Mucelli Rezende Oliveira
2026-10-31 18:35 ` Eduardo Mucelli Rezende Oliveira [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=694f66b67c017072c0246997a09e67a79ebee04f.1793471731.git.edumucelli@gmail.com \
--to=edumucelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®