aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dynamic_debug.c
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2011-12-19 17:12:44 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2012-01-24 15:48:52 -0500
commit5ca7d2a6c5e4f24dfe39e8383c6d32e61d95d16a (patch)
tree9825251f6cd4a7027e8235a73d6a6c8654a6afed /lib/dynamic_debug.c
parentd6a238d25014d0ff918410d73e2a6300bca5d1f1 (diff)
dynamic_debug: describe_flags with '=[pmflt_]*'
Change describe_flags() to emit '=[pmflt_]+' for current callsite flags, or just '=_' when they're disabled. Having '=' in output allows a more selective grep expression; in contrast '-' may appear in filenames, line-ranges, and format-strings. '=' also has better mnemonics, saying; "the current setting is equal to <flags>". This allows grep "=_" <dbgfs>/dynamic_debug/control to see disabled callsites while avoiding the many occurrences of " = " seen in format strings. Enlarge flagsbufs to handle additional flag char, and alter ddebug_parse_flags() to allow flags=0, so that user can turn off all debug flags via: ~# echo =_ > <dbgfs>/dynamic_debug/control Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib/dynamic_debug.c')
-rw-r--r--lib/dynamic_debug.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index b199e0935053..cde4dfe2b2d5 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -75,6 +75,7 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = {
75 { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, 75 { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' },
76 { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, 76 { _DPRINTK_FLAGS_INCL_LINENO, 'l' },
77 { _DPRINTK_FLAGS_INCL_TID, 't' }, 77 { _DPRINTK_FLAGS_INCL_TID, 't' },
78 { _DPRINTK_FLAGS_NONE, '_' },
78}; 79};
79 80
80/* format a string into buf[] which describes the _ddebug's flags */ 81/* format a string into buf[] which describes the _ddebug's flags */
@@ -84,12 +85,12 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
84 char *p = buf; 85 char *p = buf;
85 int i; 86 int i;
86 87
87 BUG_ON(maxlen < 4); 88 BUG_ON(maxlen < 6);
88 for (i = 0; i < ARRAY_SIZE(opt_array); ++i) 89 for (i = 0; i < ARRAY_SIZE(opt_array); ++i)
89 if (dp->flags & opt_array[i].flag) 90 if (dp->flags & opt_array[i].flag)
90 *p++ = opt_array[i].opt_char; 91 *p++ = opt_array[i].opt_char;
91 if (p == buf) 92 if (p == buf)
92 *p++ = '-'; 93 *p++ = '_';
93 *p = '\0'; 94 *p = '\0';
94 95
95 return buf; 96 return buf;
@@ -108,7 +109,7 @@ static void ddebug_change(const struct ddebug_query *query,
108 struct ddebug_table *dt; 109 struct ddebug_table *dt;
109 unsigned int newflags; 110 unsigned int newflags;
110 unsigned int nfound = 0; 111 unsigned int nfound = 0;
111 char flagbuf[8]; 112 char flagbuf[10];
112 113
113 /* search for matching ddebugs */ 114 /* search for matching ddebugs */
114 mutex_lock(&ddebug_lock); 115 mutex_lock(&ddebug_lock);
@@ -152,7 +153,7 @@ static void ddebug_change(const struct ddebug_query *query,
152 continue; 153 continue;
153 dp->flags = newflags; 154 dp->flags = newflags;
154 if (verbose) 155 if (verbose)
155 pr_info("changed %s:%d [%s]%s %s\n", 156 pr_info("changed %s:%d [%s]%s =%s\n",
156 dp->filename, dp->lineno, 157 dp->filename, dp->lineno,
157 dt->mod_name, dp->function, 158 dt->mod_name, dp->function,
158 ddebug_describe_flags(dp, flagbuf, 159 ddebug_describe_flags(dp, flagbuf,
@@ -370,8 +371,6 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
370 if (i < 0) 371 if (i < 0)
371 return -EINVAL; 372 return -EINVAL;
372 } 373 }
373 if (flags == 0)
374 return -EINVAL;
375 if (verbose) 374 if (verbose)
376 pr_info("flags=0x%x\n", flags); 375 pr_info("flags=0x%x\n", flags);
377 376
@@ -666,7 +665,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
666{ 665{
667 struct ddebug_iter *iter = m->private; 666 struct ddebug_iter *iter = m->private;
668 struct _ddebug *dp = p; 667 struct _ddebug *dp = p;
669 char flagsbuf[8]; 668 char flagsbuf[10];
670 669
671 if (verbose) 670 if (verbose)
672 pr_info("called m=%p p=%p\n", m, p); 671 pr_info("called m=%p p=%p\n", m, p);
@@ -677,10 +676,10 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
677 return 0; 676 return 0;
678 } 677 }
679 678
680 seq_printf(m, "%s:%u [%s]%s %s \"", 679 seq_printf(m, "%s:%u [%s]%s =%s \"",
681 dp->filename, dp->lineno, 680 dp->filename, dp->lineno,
682 iter->table->mod_name, dp->function, 681 iter->table->mod_name, dp->function,
683 ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf))); 682 ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf)));
684 seq_escape(m, dp->format, "\t\r\n\""); 683 seq_escape(m, dp->format, "\t\r\n\"");
685 seq_puts(m, "\"\n"); 684 seq_puts(m, "\"\n");
686 685