Skip to content

Commit aaebe32

Browse files
jimcgregkh
authored andcommitted
dyndbg: accept 'file foo.c:func1' and 'file foo.c:10-100'
Accept these additional query forms: echo "file $filestr +_" > control path/to/file.c:100 # as from control, column 1 path/to/file.c:1-100 # or any legal line-range path/to/file.c:func_A # as from an editor/browser path/to/file.c:drm_* # wildcards still work path/to/file.c:*_foo # lead wildcard too 1st 2 examples are treated as line-ranges, 3-5 are treated as func's Doc these changes, and sprinkle in a few extra wild-card examples and trailing # explanation texts. Acked-by: <[email protected]> Signed-off-by: Jim Cromie <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8037072 commit aaebe32

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Documentation/admin-guide/dynamic-debug-howto.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ func
164164
of each callsite. Example::
165165

166166
func svc_tcp_accept
167+
func *recv* # in rfcomm, bluetooth, ping, tcp
167168

168169
file
169170
The given string is compared against either the src-root relative
@@ -172,6 +173,9 @@ file
172173

173174
file svcsock.c
174175
file kernel/freezer.c # ie column 1 of control file
176+
file drivers/usb/* # all callsites under it
177+
file inode.c:start_* # parse :tail as a func (above)
178+
file inode.c:1-100 # parse :tail as a line-range (above)
175179

176180
module
177181
The given string is compared against the module name
@@ -181,6 +185,7 @@ module
181185

182186
module sunrpc
183187
module nfsd
188+
module drm* # both drm, drm_kms_helper
184189

185190
format
186191
The given string is searched for in the dynamic debug format

lib/dynamic_debug.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ static int ddebug_parse_query(char *words[], int nwords,
359359
{
360360
unsigned int i;
361361
int rc = 0;
362+
char *fline;
362363

363364
/* check we have an even number of words */
364365
if (nwords % 2 != 0) {
@@ -374,7 +375,22 @@ static int ddebug_parse_query(char *words[], int nwords,
374375
if (!strcmp(words[i], "func")) {
375376
rc = check_set(&query->function, words[i+1], "func");
376377
} else if (!strcmp(words[i], "file")) {
377-
rc = check_set(&query->filename, words[i+1], "file");
378+
if (check_set(&query->filename, words[i+1], "file"))
379+
return -EINVAL;
380+
381+
/* tail :$info is function or line-range */
382+
fline = strchr(query->filename, ':');
383+
if (!fline)
384+
break;
385+
*fline++ = '\0';
386+
if (isalpha(*fline) || *fline == '*' || *fline == '?') {
387+
/* take as function name */
388+
if (check_set(&query->function, fline, "func"))
389+
return -EINVAL;
390+
} else {
391+
if (parse_linerange(query, fline))
392+
return -EINVAL;
393+
}
378394
} else if (!strcmp(words[i], "module")) {
379395
rc = check_set(&query->module, words[i+1], "module");
380396
} else if (!strcmp(words[i], "format")) {

0 commit comments

Comments
 (0)