Skip to content

Commit 4b33448

Browse files
jimcgregkh
authored andcommitted
dyndbg: allow anchored match on format query term
This should work: echo module=amd* format=^[IF_TRACE]: +p >/proc/dynamic_debug/control consider drivers/gpu/drm/amd/display/include/logger_types.h: It has 11 defines like: #define DC_LOG_IF_TRACE(...) pr_debug("[IF_TRACE]:"__VA_ARGS__) These defines are used 804 times at recent count; they are a good use case to evaluate existing format-message based classifications of *pr_debug*. Those macros prefix the supplied format with a fixed string, I'd expect most existing message classification schemes to do something similar. Hence we want to be able to anchor our match to the beginning of the format string, allowing easy construction of clear and precise queries, leveraging the existing classification scheme to enable and disable those callsites. Note that unlike other search terms, formats are implicitly floating substring matches, without the need for explicit wildcards. This makes no attempt at wider regex features, just the one we need. TLDR: Using the anchor also means the []s are less helpful for disamiguating the prefix from a random in-message occurrence, allowing shorter prefixes. Acked-by: <jbaron@akamai.com> Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Link: https://lore.kernel.org/r/20200719231058.1586423-17-jim.cromie@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 84da83a commit 4b33448

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎lib/dynamic_debug.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,16 @@ static int ddebug_change(const struct ddebug_query *query,
181181
continue;
182182

183183
/* match against the format */
184-
if (query->format &&
185-
!strstr(dp->format, query->format))
186-
continue;
184+
if (query->format) {
185+
if (*query->format == '^') {
186+
char *p;
187+
/* anchored search. match must be at beginning */
188+
p = strstr(dp->format, query->format+1);
189+
if (p != dp->format)
190+
continue;
191+
} else if (!strstr(dp->format, query->format))
192+
continue;
193+
}
187194

188195
/* match against the line number range */
189196
if (query->first_lineno &&

0 commit comments

Comments
 (0)