aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2011-12-19 17:13:12 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2012-01-24 15:48:55 -0500
commit2b6783191da7211c88f98eb1a2bd2027bff36e30 (patch)
tree3227bbc5c9c187b6dbaa133a6f7e2e4364942594
parent7281491c594e7b8501eb5dfcf6cd3724f8a1b5b0 (diff)
dynamic_debug: add trim_prefix() to provide source-root relative paths
trim_prefix(path) skips past the absolute source path root, and returns the pointer to the relative path from there. It is used to shorten the displayed path in $DBGMT/dynamic_debug/control via ddebug_proc_show(), and in ddebug_change() to allow relative filenames to be used in applied queries. For example: ~# echo file kernel/freezer.c +p > $DBGMT/dynamic_debug/control kernel/freezer.c:128 [freezer]cancel_freezing p " clean up: %s\012" trim_prefix(path) insures common prefix before trimming it, so out-of-tree module paths are shown as full absolute paths. 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>
-rw-r--r--Documentation/dynamic-debug-howto.txt7
-rw-r--r--lib/dynamic_debug.c18
2 files changed, 19 insertions, 6 deletions
diff --git a/Documentation/dynamic-debug-howto.txt b/Documentation/dynamic-debug-howto.txt
index f959909d715..378b5d1bf43 100644
--- a/Documentation/dynamic-debug-howto.txt
+++ b/Documentation/dynamic-debug-howto.txt
@@ -144,11 +144,12 @@ func
144 func svc_tcp_accept 144 func svc_tcp_accept
145 145
146file 146file
147 The given string is compared against either the full 147 The given string is compared against either the full pathname, the
148 pathname or the basename of the source file of each 148 src-root relative pathname, or the basename of the source file of
149 callsite. Examples: 149 each callsite. Examples:
150 150
151 file svcsock.c 151 file svcsock.c
152 file kernel/freezer.c
152 file /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c 153 file /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c
153 154
154module 155module
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index d8773dcd83c..a5508a12b83 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -69,6 +69,17 @@ static inline const char *basename(const char *path)
69 return tail ? tail+1 : path; 69 return tail ? tail+1 : path;
70} 70}
71 71
72/* Return the path relative to source root */
73static inline const char *trim_prefix(const char *path)
74{
75 int skip = strlen(__FILE__) - strlen("lib/dynamic_debug.c");
76
77 if (strncmp(path, __FILE__, skip))
78 skip = 0; /* prefix mismatch, don't skip */
79
80 return path + skip;
81}
82
72static struct { unsigned flag:8; char opt_char; } opt_array[] = { 83static struct { unsigned flag:8; char opt_char; } opt_array[] = {
73 { _DPRINTK_FLAGS_PRINT, 'p' }, 84 { _DPRINTK_FLAGS_PRINT, 'p' },
74 { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, 85 { _DPRINTK_FLAGS_INCL_MODNAME, 'm' },
@@ -125,7 +136,8 @@ static void ddebug_change(const struct ddebug_query *query,
125 /* match against the source filename */ 136 /* match against the source filename */
126 if (query->filename && 137 if (query->filename &&
127 strcmp(query->filename, dp->filename) && 138 strcmp(query->filename, dp->filename) &&
128 strcmp(query->filename, basename(dp->filename))) 139 strcmp(query->filename, basename(dp->filename)) &&
140 strcmp(query->filename, trim_prefix(dp->filename)))
129 continue; 141 continue;
130 142
131 /* match against the function */ 143 /* match against the function */
@@ -154,7 +166,7 @@ static void ddebug_change(const struct ddebug_query *query,
154 dp->flags = newflags; 166 dp->flags = newflags;
155 if (verbose) 167 if (verbose)
156 pr_info("changed %s:%d [%s]%s =%s\n", 168 pr_info("changed %s:%d [%s]%s =%s\n",
157 dp->filename, dp->lineno, 169 trim_prefix(dp->filename), dp->lineno,
158 dt->mod_name, dp->function, 170 dt->mod_name, dp->function,
159 ddebug_describe_flags(dp, flagbuf, 171 ddebug_describe_flags(dp, flagbuf,
160 sizeof(flagbuf))); 172 sizeof(flagbuf)));
@@ -714,7 +726,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
714 } 726 }
715 727
716 seq_printf(m, "%s:%u [%s]%s =%s \"", 728 seq_printf(m, "%s:%u [%s]%s =%s \"",
717 dp->filename, dp->lineno, 729 trim_prefix(dp->filename), dp->lineno,
718 iter->table->mod_name, dp->function, 730 iter->table->mod_name, dp->function,
719 ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf))); 731 ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf)));
720 seq_escape(m, dp->format, "\t\r\n\""); 732 seq_escape(m, dp->format, "\t\r\n\"");