Skip to content

Commit 8e59b5c

Browse files
jimcgregkh
authored andcommitted
dynamic_debug: add modname arg to exec_query callchain
Pass module name into ddebug_exec_queries(), ddebug_exec_query(), and ddebug_parse_query() as separate parameter. In ddebug_parse_query(), the module name is added into the query struct before the query-string is parsed. This allows the query-string to be shorter: instead of: $modname.dyndbg="module $modname +fp" do this: $modname.dyndbg="+fp" Omitting "module $modname" from the query string is actually required for $modname.dyndbg rules; the set-only-once check added in a previous patch will throw an error if its added again. ddebug_query="..." has no $modname associated with it, so the query string may include it. This also fixes redundant "module $modname" otherwise needed to handle multiple queries per string: $modname.dyndbg="func foo +fp; func bar +fp" Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Acked-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4107692 commit 8e59b5c

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎lib/dynamic_debug.c‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static int check_set(const char **dest, char *src, char *name)
338338
* Returns 0 on success, <0 on error.
339339
*/
340340
static int ddebug_parse_query(char *words[], int nwords,
341-
struct ddebug_query *query)
341+
struct ddebug_query *query, const char *modname)
342342
{
343343
unsigned int i;
344344
int rc;
@@ -348,6 +348,10 @@ static int ddebug_parse_query(char *words[], int nwords,
348348
return -EINVAL;
349349
memset(query, 0, sizeof(*query));
350350

351+
if (modname)
352+
/* support $modname.dyndbg=<multiple queries> */
353+
query->module = modname;
354+
351355
for (i = 0 ; i < nwords ; i += 2) {
352356
if (!strcmp(words[i], "func"))
353357
rc = check_set(&query->function, words[i+1], "func");
@@ -444,7 +448,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
444448
return 0;
445449
}
446450

447-
static int ddebug_exec_query(char *query_string)
451+
static int ddebug_exec_query(char *query_string, const char *modname)
448452
{
449453
unsigned int flags = 0, mask = 0;
450454
struct ddebug_query query;
@@ -455,7 +459,7 @@ static int ddebug_exec_query(char *query_string)
455459
nwords = ddebug_tokenize(query_string, words, MAXWORDS);
456460
if (nwords <= 0)
457461
return -EINVAL;
458-
if (ddebug_parse_query(words, nwords-1, &query))
462+
if (ddebug_parse_query(words, nwords-1, &query, modname))
459463
return -EINVAL;
460464
if (ddebug_parse_flags(words[nwords-1], &flags, &mask))
461465
return -EINVAL;
@@ -471,7 +475,7 @@ static int ddebug_exec_query(char *query_string)
471475
last error or number of matching callsites. Module name is either
472476
in param (for boot arg) or perhaps in query string.
473477
*/
474-
static int ddebug_exec_queries(char *query)
478+
static int ddebug_exec_queries(char *query, const char *modname)
475479
{
476480
char *split;
477481
int i, errs = 0, exitcode = 0, rc, nfound = 0;
@@ -487,7 +491,7 @@ static int ddebug_exec_queries(char *query)
487491

488492
vpr_info("query %d: \"%s\"\n", i, query);
489493

490-
rc = ddebug_exec_query(query);
494+
rc = ddebug_exec_query(query, modname);
491495
if (rc < 0) {
492496
errs++;
493497
exitcode = rc;
@@ -652,7 +656,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
652656
tmpbuf[len] = '\0';
653657
vpr_info("read %d bytes from userspace\n", (int)len);
654658

655-
ret = ddebug_exec_queries(tmpbuf);
659+
ret = ddebug_exec_queries(tmpbuf, NULL);
656660
kfree(tmpbuf);
657661
if (ret < 0)
658662
return ret;
@@ -878,7 +882,8 @@ static int ddebug_dyndbg_param_cb(char *param, char *val,
878882
if (strcmp(param, "dyndbg"))
879883
return on_err; /* determined by caller */
880884

881-
ddebug_exec_queries(val ? val : "+p");
885+
ddebug_exec_queries((val ? val : "+p"), modname);
886+
882887
return 0; /* query failure shouldnt stop module load */
883888
}
884889

@@ -1011,7 +1016,7 @@ static int __init dynamic_debug_init(void)
10111016
if (ddebug_setup_string[0] != '\0') {
10121017
pr_warn("ddebug_query param name is deprecated,"
10131018
" change it to dyndbg\n");
1014-
ret = ddebug_exec_queries(ddebug_setup_string);
1019+
ret = ddebug_exec_queries(ddebug_setup_string, NULL);
10151020
if (ret < 0)
10161021
pr_warn("Invalid ddebug boot param %s",
10171022
ddebug_setup_string);

0 commit comments

Comments
 (0)