aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-11-24 13:34:22 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-11-24 13:34:22 -0500
commitdbf8d70df6bc23ebdf78061e93eaec86e5019814 (patch)
tree1aa936cc03a19306db47be0f93be1ccb656afb33
parent2ea1baba8708adcb4fc18523bd6d2068c0a66f6d (diff)
Handle pointers to kernel strings nicer
Some trace events point to strings within the kernel, and print them with '%s'. Since the stored value is just a pointer, unless we export those strings we can't print them out. Instead of trying to print out garbage (a string pointer), print out the value instead. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--parse-events.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/parse-events.c b/parse-events.c
index ff44523..af50bc1 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -2255,6 +2255,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
2255{ 2255{
2256 struct print_flag_sym *flag; 2256 struct print_flag_sym *flag;
2257 unsigned long long val, fval; 2257 unsigned long long val, fval;
2258 unsigned long addr;
2258 char *str; 2259 char *str;
2259 int print; 2260 int print;
2260 int len; 2261 int len;
@@ -2274,7 +2275,19 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
2274 } 2275 }
2275 /* Zero sized fields, mean the rest of the data */ 2276 /* Zero sized fields, mean the rest of the data */
2276 len = arg->field.field->size ? : size; 2277 len = arg->field.field->size ? : size;
2277 str = malloc_or_die(size + 1); 2278
2279 /*
2280 * Some events pass in pointers. If this is not an array
2281 * and the size is the same as long_size, assume that it
2282 * is a pointer.
2283 */
2284 if (!(arg->field.field->flags & FIELD_IS_ARRAY) &&
2285 len == long_size) {
2286 addr = *(unsigned long *)(data + arg->field.field->offset);
2287 trace_seq_printf(s, "%lx", addr);
2288 break;
2289 }
2290 str = malloc_or_die(len + 1);
2278 memcpy(str, data + arg->field.field->offset, len); 2291 memcpy(str, data + arg->field.field->offset, len);
2279 str[len] = 0; 2292 str[len] = 0;
2280 trace_seq_puts(s, str); 2293 trace_seq_puts(s, str);