Skip to content

Commit 578b1e0

Browse files
changbindutorvalds
authored andcommitted
dynamic_debug: add wildcard support to filter files/functions/modules
Add wildcard '*'(matches zero or more characters) and '?' (matches one character) support when qurying debug flags. Now we can open debug messages using keywords. eg: 1. open debug logs in all usb drivers echo "file drivers/usb/* +p" > <debugfs>/dynamic_debug/control 2. open debug logs for usb xhci code echo "file *xhci* +p" > <debugfs>/dynamic_debug/control Signed-off-by: Du, Changbin <changbin.du@gmail.com> Cc: Jason Baron <jbaron@akamai.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a3d2cca commit 578b1e0

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎lib/dynamic_debug.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* By Greg Banks <gnb@melbourne.sgi.com>
99
* Copyright (c) 2008 Silicon Graphics Inc. All Rights Reserved.
1010
* Copyright (C) 2011 Bart Van Assche. All Rights Reserved.
11+
* Copyright (C) 2013 Du, Changbin <changbin.du@gmail.com>
1112
*/
1213

1314
#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
@@ -24,6 +25,7 @@
2425
#include <linux/sysctl.h>
2526
#include <linux/ctype.h>
2627
#include <linux/string.h>
28+
#include <linux/parser.h>
2729
#include <linux/string_helpers.h>
2830
#include <linux/uaccess.h>
2931
#include <linux/dynamic_debug.h>
@@ -147,22 +149,25 @@ static int ddebug_change(const struct ddebug_query *query,
147149
list_for_each_entry(dt, &ddebug_tables, link) {
148150

149151
/* match against the module name */
150-
if (query->module && strcmp(query->module, dt->mod_name))
152+
if (query->module &&
153+
!match_wildcard(query->module, dt->mod_name))
151154
continue;
152155

153156
for (i = 0; i < dt->num_ddebugs; i++) {
154157
struct _ddebug *dp = &dt->ddebugs[i];
155158

156159
/* match against the source filename */
157160
if (query->filename &&
158-
strcmp(query->filename, dp->filename) &&
159-
strcmp(query->filename, kbasename(dp->filename)) &&
160-
strcmp(query->filename, trim_prefix(dp->filename)))
161+
!match_wildcard(query->filename, dp->filename) &&
162+
!match_wildcard(query->filename,
163+
kbasename(dp->filename)) &&
164+
!match_wildcard(query->filename,
165+
trim_prefix(dp->filename)))
161166
continue;
162167

163168
/* match against the function */
164169
if (query->function &&
165-
strcmp(query->function, dp->function))
170+
!match_wildcard(query->function, dp->function))
166171
continue;
167172

168173
/* match against the format */

0 commit comments

Comments
 (0)