aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2015-08-07 18:24:05 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-10 10:58:05 -0400
commita9710ba091b0dcdace90f791706e9192313ffb7c (patch)
tree8d6e07ac2f6632de86779732095df9b61cc3a575
parent076a30c411ba2b91a18d44a5a01977035cdd7716 (diff)
perf tools: Support full source file paths for srcline
For perf report/script srcline currently only the base file name of the source file is printed. This is a good default because it usually fits on the screen. But in some cases we want to know the full file name, for example to aggregate hits per file. In the later case we need more than the base file name to resolve file naming collisions: for example the kernel source has ~70 files named "core.c" It's also useful as input to post processing tools which want to point to the right file. Add a flag to allow full file name output. Add an option to perf report/script to enable this option. Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1438986245-15191-1-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-report.txt2
-rw-r--r--tools/perf/Documentation/perf-script.txt3
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/builtin-script.c2
-rw-r--r--tools/perf/util/srcline.c6
-rw-r--r--tools/perf/util/util.h1
6 files changed, 15 insertions, 1 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 960da203ec11..1a782ef02b68 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -354,6 +354,8 @@ OPTIONS
354 354
355 To disable decoding entirely, use --no-itrace. 355 To disable decoding entirely, use --no-itrace.
356 356
357--full-source-path::
358 Show the full path for source files for srcline output.
357 359
358include::callchain-overhead-calculation.txt[] 360include::callchain-overhead-calculation.txt[]
359 361
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index e2fec5fc21e7..8e9be1f9c1dd 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -260,6 +260,9 @@ OPTIONS
260 260
261 To disable decoding entirely, use --no-itrace. 261 To disable decoding entirely, use --no-itrace.
262 262
263--full-source-path::
264 Show the full path for source files for srcline output.
265
263SEE ALSO 266SEE ALSO
264-------- 267--------
265linkperf:perf-record[1], linkperf:perf-script-perl[1], 268linkperf:perf-record[1], linkperf:perf-script-perl[1],
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3a9d1b659fcd..f301e865001f 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -738,6 +738,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
738 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", 738 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
739 "Instruction Tracing options", 739 "Instruction Tracing options",
740 itrace_parse_synth_opts), 740 itrace_parse_synth_opts),
741 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
742 "Show full source file name path for source lines"),
741 OPT_END() 743 OPT_END()
742 }; 744 };
743 struct perf_data_file file = { 745 struct perf_data_file file = {
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 7912feb9a024..7b376d215e94 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1653,6 +1653,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1653 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", 1653 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
1654 "Instruction Tracing options", 1654 "Instruction Tracing options",
1655 itrace_parse_synth_opts), 1655 itrace_parse_synth_opts),
1656 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
1657 "Show full source file name path for source lines"),
1656 OPT_END() 1658 OPT_END()
1657 }; 1659 };
1658 const char * const script_subcommands[] = { "record", "report", NULL }; 1660 const char * const script_subcommands[] = { "record", "report", NULL };
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index c93fb0c5bd0b..fc08248f08ca 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -10,6 +10,8 @@
10 10
11#include "symbol.h" 11#include "symbol.h"
12 12
13bool srcline_full_filename;
14
13#ifdef HAVE_LIBBFD_SUPPORT 15#ifdef HAVE_LIBBFD_SUPPORT
14 16
15/* 17/*
@@ -277,7 +279,9 @@ char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
277 if (!addr2line(dso_name, addr, &file, &line, dso)) 279 if (!addr2line(dso_name, addr, &file, &line, dso))
278 goto out; 280 goto out;
279 281
280 if (asprintf(&srcline, "%s:%u", basename(file), line) < 0) { 282 if (asprintf(&srcline, "%s:%u",
283 srcline_full_filename ? file : basename(file),
284 line) < 0) {
281 free(file); 285 free(file);
282 goto out; 286 goto out;
283 } 287 }
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 81487037acf7..88a891562a47 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -318,6 +318,7 @@ static inline int path__join3(char *bf, size_t size,
318struct dso; 318struct dso;
319struct symbol; 319struct symbol;
320 320
321extern bool srcline_full_filename;
321char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym, 322char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
322 bool show_sym); 323 bool show_sym);
323void free_srcline(char *srcline); 324void free_srcline(char *srcline);