Multi-query strings have long allowed:
modprobe drm dyndbg="class DRM_UT_CORE +p; class DRM_UT_KMS +p"
modprobe drm dyndbg=<<EOX
class DRM_UT_CORE +pmf
class DRM_UT_KMS +pmf
EOX
More recently, the need for quoting was avoided by treating a comma
like a space/token-terminator:
modprobe drm dyndbg=class,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p
But that leaves unfinished business; that semi-colon needs escaping,
and thats not robust to further string interpolation. In particular,
it fails when passed to vng (virtme-ng).
So this patch adds '%' to the existing ';' and '\n' multi-cmd
separators, which is more shell-friendly, and avoids quoting and
escaping hassles.
modprobe drm dyndbg=class,DRM_UT_CORE,+p%class,DRM_UT_KMS,+p
NOTE: it does alter/break this (ill conceived) search:
[root@v6 lx]# ddcmd format %s +p
[ 38.170998] dyndbg: read 13 bytes from userspace
[ 38.171542] dyndbg: query 0: <format > on module: <*>
[ 38.172011] dyndbg: bad flag-op f, at start of format
[ 38.172487] dyndbg: flags parse failed
[ 38.172839] dyndbg: query 1: <s +p> on module: <*>
[ 38.173285] dyndbg: expecting pairs of match-spec <value>
[ 38.173791] dyndbg: query parse failed
[ 38.174141] dyndbg: processed 2 queries, with 0 matches, 2 errs
bash: echo: write error: Invalid argument
In trade for that minor format selection limitation, we get to do:
vng -v --user root -p 4 \
-a dynamic_debug.verbose=3 \
-a drm.debug=0x15 \
-a i915.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfml
modprobe drm
modprobe i915
NOTES/TLDR:
In this example, using both drm.debug & drm.dyndbg is mostly for
testing. Using drm.debug is preferred, because the drivers all
explicitly depend on that input/control-point, so settings there are
propagated to drivers.
But more to the point, drm.dyndbg explicitly limits the query to drm.
In fact, you could pass a module wildcard in the above, and achieve
the same thing:
vng -v --user root -p 4 \
-a dynamic_debug.verbose=3 \
-a \*.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfm%class,DRM_UT_ATOMIC,+pf
':' would be a more natural multi-cmd separator, but is reserved
for +T:<trace_buf> to designate separate tracebuf instances.
If '%' is distasteful, the backup plan is ",_,", since that would
never appear in a useful <format "$foo"> cmd.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
lib/dynamic_debug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index c974f6e19ca1..0ca3ba9e2032 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -963,7 +963,7 @@ static int ddebug_exec_queries(char *query, const char *modname)
int i, errs = 0, exitcode = 0, rc, nfound = 0;
for (i = 0; query; query = split) {
- split = strpbrk(query, ";\n");
+ split = strpbrk(query, "%;\n");
if (split)
*split++ = '\0';
--
2.43.0
pt., 8 gru 2023 o 01:15 Jim Cromie <jim.cromie@gmail.com> napisał(a):
>
> Multi-query strings have long allowed:
>
> modprobe drm dyndbg="class DRM_UT_CORE +p; class DRM_UT_KMS +p"
> modprobe drm dyndbg=<<EOX
> class DRM_UT_CORE +pmf
> class DRM_UT_KMS +pmf
> EOX
>
> More recently, the need for quoting was avoided by treating a comma
> like a space/token-terminator:
>
> modprobe drm dyndbg=class,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p
>
> But that leaves unfinished business; that semi-colon needs escaping,
> and thats not robust to further string interpolation. In particular,
> it fails when passed to vng (virtme-ng).
>
> So this patch adds '%' to the existing ';' and '\n' multi-cmd
> separators, which is more shell-friendly, and avoids quoting and
> escaping hassles.
>
> modprobe drm dyndbg=class,DRM_UT_CORE,+p%class,DRM_UT_KMS,+p
>
> NOTE: it does alter/break this (ill conceived) search:
>
> [root@v6 lx]# ddcmd format %s +p
> [ 38.170998] dyndbg: read 13 bytes from userspace
> [ 38.171542] dyndbg: query 0: <format > on module: <*>
> [ 38.172011] dyndbg: bad flag-op f, at start of format
> [ 38.172487] dyndbg: flags parse failed
> [ 38.172839] dyndbg: query 1: <s +p> on module: <*>
> [ 38.173285] dyndbg: expecting pairs of match-spec <value>
> [ 38.173791] dyndbg: query parse failed
> [ 38.174141] dyndbg: processed 2 queries, with 0 matches, 2 errs
> bash: echo: write error: Invalid argument
>
> In trade for that minor format selection limitation, we get to do:
>
> vng -v --user root -p 4 \
> -a dynamic_debug.verbose=3 \
> -a drm.debug=0x15 \
> -a i915.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfml
> modprobe drm
> modprobe i915
>
> NOTES/TLDR:
>
> In this example, using both drm.debug & drm.dyndbg is mostly for
> testing. Using drm.debug is preferred, because the drivers all
> explicitly depend on that input/control-point, so settings there are
> propagated to drivers.
>
> But more to the point, drm.dyndbg explicitly limits the query to drm.
> In fact, you could pass a module wildcard in the above, and achieve
> the same thing:
>
> vng -v --user root -p 4 \
> -a dynamic_debug.verbose=3 \
> -a \*.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfm%class,DRM_UT_ATOMIC,+pf
>
> ':' would be a more natural multi-cmd separator, but is reserved
> for +T:<trace_buf> to designate separate tracebuf instances.
>
> If '%' is distasteful, the backup plan is ",_,", since that would
> never appear in a useful <format "$foo"> cmd.
>
What if we use a different character for passing trace instance name
to the T flag, for example "-", +T-trace_buf
and then use ":" instead of "%" as a separator ?
> Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
> ---
> lib/dynamic_debug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index c974f6e19ca1..0ca3ba9e2032 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -963,7 +963,7 @@ static int ddebug_exec_queries(char *query, const char *modname)
> int i, errs = 0, exitcode = 0, rc, nfound = 0;
>
> for (i = 0; query; query = split) {
> - split = strpbrk(query, ";\n");
> + split = strpbrk(query, "%;\n");
> if (split)
> *split++ = '\0';
>
> --
> 2.43.0
>
On Fri, Dec 8, 2023 at 5:32 PM Łukasz Bartosik <lb@semihalf.com> wrote: > > pt., 8 gru 2023 o 01:15 Jim Cromie <jim.cromie@gmail.com> napisał(a): > > > > vng -v --user root -p 4 \ > > -a dynamic_debug.verbose=3 \ > > -a \*.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfm%class,DRM_UT_ATOMIC,+pf > > > > ':' would be a more natural multi-cmd separator, but is reserved > > for +T:<trace_buf> to designate separate tracebuf instances. > > > > If '%' is distasteful, the backup plan is ",_,", since that would > > never appear in a useful <format "$foo"> cmd. > > > > What if we use a different character for passing trace instance name > to the T flag, for example "-", +T-trace_buf > and then use ":" instead of "%" as a separator ? > *** entering the Bikeshed *** One of the nice constraints of the flags-val is that it always starts with +/-/= the 1st char of flags is the only place they would appear unquoted. using '-' again dilutes that specialness. the whole +T:named_stream. syntax has a mnemonic value, it seems to explain itself (but I'm weird) WRT to ':' vs '%' as multi-cmd separator, what do we lose in each trade ? ultimately it invalidates a query containing those chars. IOW # impossible query when cmd-splitting on % echo format "search for %s because %d" +p > /proc/dynamic_debug/control # impossible when splitting on : echo format "my_label: " +p > /proc/dynamic_debug/control NB: only format would see an arg with either : or %, since theyre *never* in filenames, functions or module (or class) names. Of the 2, % is even more unlikely to wind up in a name, colon already appears in host:path and urls, and in some class-name systems (tho not planned for "class" keyword) the ability to search for colon-terminated labels seems more useful than searching for a particular set of printf format specifiers, which btw cant have colons between them.
© 2016 - 2025 Red Hat, Inc.