perf probe: Detect probe target when m/x options are absent
Options -m and -x explicitly allow tracing of modules / user space binaries. In absense of these options, check if the first argument can be used as a target. perf probe /bin/zsh zfree is equivalent to perf probe -x /bin/zsh zfree. Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Anton Arapov <anton@redhat.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Jim Keniston <jkenisto@linux.vnet.ibm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Linux-mm <linux-mm@kvack.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20120416120925.30661.40409.sendpatchset@srdronam.in.ibm.com Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
225466f1c2
commit
73eff9f56e
@@ -85,21 +85,58 @@ static int parse_probe_event(const char *str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int set_target(const char *ptr)
|
||||
{
|
||||
int found = 0;
|
||||
const char *buf;
|
||||
|
||||
/*
|
||||
* The first argument after options can be an absolute path
|
||||
* to an executable / library or kernel module.
|
||||
*
|
||||
* TODO: Support relative path, and $PATH, $LD_LIBRARY_PATH,
|
||||
* short module name.
|
||||
*/
|
||||
if (!params.target && ptr && *ptr == '/') {
|
||||
params.target = ptr;
|
||||
found = 1;
|
||||
buf = ptr + (strlen(ptr) - 3);
|
||||
|
||||
if (strcmp(buf, ".ko"))
|
||||
params.uprobes = true;
|
||||
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static int parse_probe_event_argv(int argc, const char **argv)
|
||||
{
|
||||
int i, len, ret;
|
||||
int i, len, ret, found_target;
|
||||
char *buf;
|
||||
|
||||
found_target = set_target(argv[0]);
|
||||
if (found_target && argc == 1)
|
||||
return 0;
|
||||
|
||||
/* Bind up rest arguments */
|
||||
len = 0;
|
||||
for (i = 0; i < argc; i++)
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (i == 0 && found_target)
|
||||
continue;
|
||||
|
||||
len += strlen(argv[i]) + 1;
|
||||
}
|
||||
buf = zalloc(len + 1);
|
||||
if (buf == NULL)
|
||||
return -ENOMEM;
|
||||
len = 0;
|
||||
for (i = 0; i < argc; i++)
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (i == 0 && found_target)
|
||||
continue;
|
||||
|
||||
len += sprintf(&buf[len], "%s ", argv[i]);
|
||||
}
|
||||
params.mod_events = true;
|
||||
ret = parse_probe_event(buf);
|
||||
free(buf);
|
||||
|
Reference in New Issue
Block a user