diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2012-04-27 16:30:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-30 16:25:39 -0400 |
commit | 8e59b5cfb9a6f43753236b554d785e8efca62db7 (patch) | |
tree | 1e6116dadf2106fe910d5cbc4fb03488028361fe | |
parent | 4107692760db8160a65347f7bb2fa7fa7bf9b0d1 (diff) |
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>
-rw-r--r-- | lib/dynamic_debug.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 76da6aa66ce7..cfd84638b1a4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -338,7 +338,7 @@ static int check_set(const char **dest, char *src, char *name) | |||
338 | * Returns 0 on success, <0 on error. | 338 | * Returns 0 on success, <0 on error. |
339 | */ | 339 | */ |
340 | static int ddebug_parse_query(char *words[], int nwords, | 340 | static int ddebug_parse_query(char *words[], int nwords, |
341 | struct ddebug_query *query) | 341 | struct ddebug_query *query, const char *modname) |
342 | { | 342 | { |
343 | unsigned int i; | 343 | unsigned int i; |
344 | int rc; | 344 | int rc; |
@@ -348,6 +348,10 @@ static int ddebug_parse_query(char *words[], int nwords, | |||
348 | return -EINVAL; | 348 | return -EINVAL; |
349 | memset(query, 0, sizeof(*query)); | 349 | memset(query, 0, sizeof(*query)); |
350 | 350 | ||
351 | if (modname) | ||
352 | /* support $modname.dyndbg=<multiple queries> */ | ||
353 | query->module = modname; | ||
354 | |||
351 | for (i = 0 ; i < nwords ; i += 2) { | 355 | for (i = 0 ; i < nwords ; i += 2) { |
352 | if (!strcmp(words[i], "func")) | 356 | if (!strcmp(words[i], "func")) |
353 | rc = check_set(&query->function, words[i+1], "func"); | 357 | rc = check_set(&query->function, words[i+1], "func"); |
@@ -444,7 +448,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, | |||
444 | return 0; | 448 | return 0; |
445 | } | 449 | } |
446 | 450 | ||
447 | static int ddebug_exec_query(char *query_string) | 451 | static int ddebug_exec_query(char *query_string, const char *modname) |
448 | { | 452 | { |
449 | unsigned int flags = 0, mask = 0; | 453 | unsigned int flags = 0, mask = 0; |
450 | struct ddebug_query query; | 454 | struct ddebug_query query; |
@@ -455,7 +459,7 @@ static int ddebug_exec_query(char *query_string) | |||
455 | nwords = ddebug_tokenize(query_string, words, MAXWORDS); | 459 | nwords = ddebug_tokenize(query_string, words, MAXWORDS); |
456 | if (nwords <= 0) | 460 | if (nwords <= 0) |
457 | return -EINVAL; | 461 | return -EINVAL; |
458 | if (ddebug_parse_query(words, nwords-1, &query)) | 462 | if (ddebug_parse_query(words, nwords-1, &query, modname)) |
459 | return -EINVAL; | 463 | return -EINVAL; |
460 | if (ddebug_parse_flags(words[nwords-1], &flags, &mask)) | 464 | if (ddebug_parse_flags(words[nwords-1], &flags, &mask)) |
461 | return -EINVAL; | 465 | return -EINVAL; |
@@ -471,7 +475,7 @@ static int ddebug_exec_query(char *query_string) | |||
471 | last error or number of matching callsites. Module name is either | 475 | last error or number of matching callsites. Module name is either |
472 | in param (for boot arg) or perhaps in query string. | 476 | in param (for boot arg) or perhaps in query string. |
473 | */ | 477 | */ |
474 | static int ddebug_exec_queries(char *query) | 478 | static int ddebug_exec_queries(char *query, const char *modname) |
475 | { | 479 | { |
476 | char *split; | 480 | char *split; |
477 | int i, errs = 0, exitcode = 0, rc, nfound = 0; | 481 | int i, errs = 0, exitcode = 0, rc, nfound = 0; |
@@ -487,7 +491,7 @@ static int ddebug_exec_queries(char *query) | |||
487 | 491 | ||
488 | vpr_info("query %d: \"%s\"\n", i, query); | 492 | vpr_info("query %d: \"%s\"\n", i, query); |
489 | 493 | ||
490 | rc = ddebug_exec_query(query); | 494 | rc = ddebug_exec_query(query, modname); |
491 | if (rc < 0) { | 495 | if (rc < 0) { |
492 | errs++; | 496 | errs++; |
493 | exitcode = rc; | 497 | exitcode = rc; |
@@ -652,7 +656,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, | |||
652 | tmpbuf[len] = '\0'; | 656 | tmpbuf[len] = '\0'; |
653 | vpr_info("read %d bytes from userspace\n", (int)len); | 657 | vpr_info("read %d bytes from userspace\n", (int)len); |
654 | 658 | ||
655 | ret = ddebug_exec_queries(tmpbuf); | 659 | ret = ddebug_exec_queries(tmpbuf, NULL); |
656 | kfree(tmpbuf); | 660 | kfree(tmpbuf); |
657 | if (ret < 0) | 661 | if (ret < 0) |
658 | return ret; | 662 | return ret; |
@@ -878,7 +882,8 @@ static int ddebug_dyndbg_param_cb(char *param, char *val, | |||
878 | if (strcmp(param, "dyndbg")) | 882 | if (strcmp(param, "dyndbg")) |
879 | return on_err; /* determined by caller */ | 883 | return on_err; /* determined by caller */ |
880 | 884 | ||
881 | ddebug_exec_queries(val ? val : "+p"); | 885 | ddebug_exec_queries((val ? val : "+p"), modname); |
886 | |||
882 | return 0; /* query failure shouldnt stop module load */ | 887 | return 0; /* query failure shouldnt stop module load */ |
883 | } | 888 | } |
884 | 889 | ||
@@ -1011,7 +1016,7 @@ static int __init dynamic_debug_init(void) | |||
1011 | if (ddebug_setup_string[0] != '\0') { | 1016 | if (ddebug_setup_string[0] != '\0') { |
1012 | pr_warn("ddebug_query param name is deprecated," | 1017 | pr_warn("ddebug_query param name is deprecated," |
1013 | " change it to dyndbg\n"); | 1018 | " change it to dyndbg\n"); |
1014 | ret = ddebug_exec_queries(ddebug_setup_string); | 1019 | ret = ddebug_exec_queries(ddebug_setup_string, NULL); |
1015 | if (ret < 0) | 1020 | if (ret < 0) |
1016 | pr_warn("Invalid ddebug boot param %s", | 1021 | pr_warn("Invalid ddebug boot param %s", |
1017 | ddebug_setup_string); | 1022 | ddebug_setup_string); |