diff options
author | Andi Kleen <ak@linux.intel.com> | 2019-02-24 10:37:19 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-25 08:58:28 -0500 |
commit | 94816add0005595ea33fc8456519be582330401e (patch) | |
tree | 2b6d96ee56bb88f1c4e1044b5ef62a29528d65bb /tools/perf/util/util.c | |
parent | 4b6ac811bce46c83811b83cdf87b41251596b9fc (diff) |
perf tools: Add perf_exe() helper to find perf binary
Also convert one existing user.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190224153722.27020-9-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 706818693086..d388f80d8703 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -568,3 +568,13 @@ out: | |||
568 | 568 | ||
569 | return tip; | 569 | return tip; |
570 | } | 570 | } |
571 | |||
572 | char *perf_exe(char *buf, int len) | ||
573 | { | ||
574 | int n = readlink("/proc/self/exe", buf, len); | ||
575 | if (n > 0) { | ||
576 | buf[n] = 0; | ||
577 | return buf; | ||
578 | } | ||
579 | return strcpy(buf, "perf"); | ||
580 | } | ||