Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288837
b: refs/heads/master
c: 85f7f6c
h: refs/heads/master
i:
  288835: dc3cf83
v: v3
  • Loading branch information
Jim Cromie authored and Greg Kroah-Hartman committed Jan 24, 2012
1 parent 4fb2a26 commit 94270fb
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 574b3725e327531c70361d1a10b8dc8dd2b93590
refs/heads/master: 85f7f6c0edb8414053d788229c97d5ecff21efab
23 changes: 8 additions & 15 deletions trunk/Documentation/dynamic-debug-howto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dynamically enabled per-callsite.
Dynamic debug has even more useful features:

* Simple query language allows turning on and off debugging statements by
matching any combination of:
matching any combination of 0 or 1 of:

- source filename
- function name
Expand Down Expand Up @@ -79,31 +79,24 @@ Command Language Reference
==========================

At the lexical level, a command comprises a sequence of words separated
by whitespace characters. Note that newlines are treated as word
separators and do *not* end a command or allow multiple commands to
be done together. So these are all equivalent:
by spaces or tabs. So these are all equivalent:

nullarbor:~ # echo -c 'file svcsock.c line 1603 +p' >
<debugfs>/dynamic_debug/control
nullarbor:~ # echo -c ' file svcsock.c line 1603 +p ' >
<debugfs>/dynamic_debug/control
nullarbor:~ # echo -c 'file svcsock.c\nline 1603 +p' >
<debugfs>/dynamic_debug/control
nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
<debugfs>/dynamic_debug/control

Commands are bounded by a write() system call. If you want to do
multiple commands you need to do a separate "echo" for each, like:
Command submissions are bounded by a write() system call.
Multiple commands can be written together, separated by ';' or '\n'.

nullarbor:~ # echo 'file svcsock.c line 1603 +p' > /proc/dprintk ;\
> echo 'file svcsock.c line 1563 +p' > /proc/dprintk
~# echo "func pnpacpi_get_resources +p; func pnp_assign_mem +p" \
> <debugfs>/dynamic_debug/control

or even like:
If your query set is big, you can batch them too:

nullarbor:~ # (
> echo 'file svcsock.c line 1603 +p' ;\
> echo 'file svcsock.c line 1563 +p' ;\
> ) > /proc/dprintk
~# cat query-batch-file > <debugfs>/dynamic_debug/control

At the syntactical level, a command comprises a sequence of match
specifications, followed by a flags change specification.
Expand Down
73 changes: 58 additions & 15 deletions trunk/lib/dynamic_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ do { \
} while (0)

/*
* Search the tables for _ddebug's which match the given
* `query' and apply the `flags' and `mask' to them. Tells
* the user which ddebug's were changed, or whether none
* were matched.
* Search the tables for _ddebug's which match the given `query' and
* apply the `flags' and `mask' to them. Returns number of matching
* callsites, normally the same as number of changes. If verbose,
* logs the changes. Takes ddebug_lock.
*/
static void ddebug_change(const struct ddebug_query *query,
unsigned int flags, unsigned int mask)
static int ddebug_change(const struct ddebug_query *query,
unsigned int flags, unsigned int mask)
{
int i;
struct ddebug_table *dt;
Expand Down Expand Up @@ -192,6 +192,8 @@ static void ddebug_change(const struct ddebug_query *query,

if (!nfound && verbose)
pr_info("no matches for query\n");

return nfound;
}

/*
Expand Down Expand Up @@ -449,7 +451,7 @@ static int ddebug_exec_query(char *query_string)
unsigned int flags = 0, mask = 0;
struct ddebug_query query;
#define MAXWORDS 9
int nwords;
int nwords, nfound;
char *words[MAXWORDS];

nwords = ddebug_tokenize(query_string, words, MAXWORDS);
Expand All @@ -461,8 +463,47 @@ static int ddebug_exec_query(char *query_string)
return -EINVAL;

/* actually go and implement the change */
ddebug_change(&query, flags, mask);
return 0;
nfound = ddebug_change(&query, flags, mask);
vpr_info_dq((&query), (nfound) ? "applied" : "no-match");

return nfound;
}

/* handle multiple queries in query string, continue on error, return
last error or number of matching callsites. Module name is either
in param (for boot arg) or perhaps in query string.
*/
static int ddebug_exec_queries(char *query)
{
char *split;
int i, errs = 0, exitcode = 0, rc, nfound = 0;

for (i = 0; query; query = split) {
split = strpbrk(query, ";\n");
if (split)
*split++ = '\0';

query = skip_spaces(query);
if (!query || !*query || *query == '#')
continue;

if (verbose)
pr_info("query %d: \"%s\"\n", i, query);

rc = ddebug_exec_query(query);
if (rc < 0) {
errs++;
exitcode = rc;
} else
nfound += rc;
i++;
}
pr_info("processed %d queries, with %d matches, %d errs\n",
i, nfound, errs);

if (exitcode)
return exitcode;
return nfound;
}

#define PREFIX_SIZE 64
Expand Down Expand Up @@ -615,9 +656,9 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
if (verbose)
pr_info("read %d bytes from userspace\n", (int)len);

ret = ddebug_exec_query(tmpbuf);
ret = ddebug_exec_queries(tmpbuf);
kfree(tmpbuf);
if (ret)
if (ret < 0)
return ret;

*offp += len;
Expand Down Expand Up @@ -927,13 +968,15 @@ static int __init dynamic_debug_init(void)

/* ddebug_query boot param got passed -> set it up */
if (ddebug_setup_string[0] != '\0') {
ret = ddebug_exec_query(ddebug_setup_string);
if (ret)
ret = ddebug_exec_queries(ddebug_setup_string);
if (ret < 0)
pr_warn("Invalid ddebug boot param %s",
ddebug_setup_string);
else
pr_info("ddebug initialized with string %s",
ddebug_setup_string);
pr_info("%d changes by ddebug_query\n", ret);

/* keep tables even on ddebug_query parse error */
ret = 0;
}

out_free:
Expand Down

0 comments on commit 94270fb

Please sign in to comment.