mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
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 <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Anton Arapov <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jim Keniston <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Linux-mm <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Srikar Dronamraju <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
parent
225466f1c2
commit
73eff9f56e
2 changed files with 46 additions and 5 deletions
|
|
@ -104,6 +104,10 @@ OPTIONS
|
|||
Specify path to the executable or shared library file for user
|
||||
space tracing. Can also be used with --funcs option.
|
||||
|
||||
In absence of -m/-x options, perf probe checks if the first argument after
|
||||
the options is an absolute path name. If its an absolute path, perf probe
|
||||
uses it as a target module/target user space binary to probe.
|
||||
|
||||
PROBE SYNTAX
|
||||
------------
|
||||
Probe points are defined by following syntax.
|
||||
|
|
@ -190,11 +194,11 @@ Delete all probes on schedule().
|
|||
|
||||
Add probes at zfree() function on /bin/zsh
|
||||
|
||||
./perf probe -x /bin/zsh zfree
|
||||
./perf probe -x /bin/zsh zfree or ./perf probe /bin/zsh zfree
|
||||
|
||||
Add probes at malloc() function on libc
|
||||
|
||||
./perf probe -x /lib/libc.so.6 malloc
|
||||
./perf probe -x /lib/libc.so.6 malloc or ./perf probe /lib/libc.so.6 malloc
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue