diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2010-08-27 07:39:06 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-09-08 10:47:19 -0400 |
commit | aba91595cfcebd193425e20aabc407531526a1c5 (patch) | |
tree | 5473ed5aebc93bb0aea03a17d7ed968ca0e95dce /kernel/trace | |
parent | 367e94c10092469c896a226a77ef13cf6da757e4 (diff) |
tracing/kprobes: Fix handling of argument names
Set "argN" name for each argument automatically if it has no specified name.
Since dynamic trace event(kprobe_events) accepts special characters for its
argument, its format can show those special characters (e.g. '$', '%', '+').
However, perf can't parse those format because of the character (especially
'%') mess up the format. This sets "argX" name for those arguments if user
omitted the argument names.
E.g.
# echo 'p do_fork %ax IP=%ip $stack' > tracing/kprobe_events
# cat tracing/kprobe_events
p:kprobes/p_do_fork_0 do_fork arg1=%ax IP=%ip arg3=$stack
Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
LKML-Reference: <20100827113906.22882.59312.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace_kprobe.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 0116c038b0bc..a39251ef1a7b 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
@@ -997,15 +997,18 @@ static int create_trace_probe(int argc, char **argv) | |||
997 | 997 | ||
998 | /* Parse argument name */ | 998 | /* Parse argument name */ |
999 | arg = strchr(argv[i], '='); | 999 | arg = strchr(argv[i], '='); |
1000 | if (arg) | 1000 | if (arg) { |
1001 | *arg++ = '\0'; | 1001 | *arg++ = '\0'; |
1002 | else | 1002 | tp->args[i].name = kstrdup(argv[i], GFP_KERNEL); |
1003 | } else { | ||
1003 | arg = argv[i]; | 1004 | arg = argv[i]; |
1005 | /* If argument name is omitted, set "argN" */ | ||
1006 | snprintf(buf, MAX_EVENT_NAME_LEN, "arg%d", i + 1); | ||
1007 | tp->args[i].name = kstrdup(buf, GFP_KERNEL); | ||
1008 | } | ||
1004 | 1009 | ||
1005 | tp->args[i].name = kstrdup(argv[i], GFP_KERNEL); | ||
1006 | if (!tp->args[i].name) { | 1010 | if (!tp->args[i].name) { |
1007 | pr_info("Failed to allocate argument%d name '%s'.\n", | 1011 | pr_info("Failed to allocate argument[%d] name.\n", i); |
1008 | i, argv[i]); | ||
1009 | ret = -ENOMEM; | 1012 | ret = -ENOMEM; |
1010 | goto error; | 1013 | goto error; |
1011 | } | 1014 | } |
@@ -1014,7 +1017,7 @@ static int create_trace_probe(int argc, char **argv) | |||
1014 | *tmp = '_'; /* convert : to _ */ | 1017 | *tmp = '_'; /* convert : to _ */ |
1015 | 1018 | ||
1016 | if (conflict_field_name(tp->args[i].name, tp->args, i)) { | 1019 | if (conflict_field_name(tp->args[i].name, tp->args, i)) { |
1017 | pr_info("Argument%d name '%s' conflicts with " | 1020 | pr_info("Argument[%d] name '%s' conflicts with " |
1018 | "another field.\n", i, argv[i]); | 1021 | "another field.\n", i, argv[i]); |
1019 | ret = -EINVAL; | 1022 | ret = -EINVAL; |
1020 | goto error; | 1023 | goto error; |
@@ -1023,7 +1026,7 @@ static int create_trace_probe(int argc, char **argv) | |||
1023 | /* Parse fetch argument */ | 1026 | /* Parse fetch argument */ |
1024 | ret = parse_probe_arg(arg, tp, &tp->args[i], is_return); | 1027 | ret = parse_probe_arg(arg, tp, &tp->args[i], is_return); |
1025 | if (ret) { | 1028 | if (ret) { |
1026 | pr_info("Parse error at argument%d. (%d)\n", i, ret); | 1029 | pr_info("Parse error at argument[%d]. (%d)\n", i, ret); |
1027 | goto error; | 1030 | goto error; |
1028 | } | 1031 | } |
1029 | } | 1032 | } |