提交 a9710ba0 编写于 作者: A Andi Kleen 提交者: Arnaldo Carvalho de Melo

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: NAndi 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.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 076a30c4
......@@ -354,6 +354,8 @@ OPTIONS
To disable decoding entirely, use --no-itrace.
--full-source-path::
Show the full path for source files for srcline output.
include::callchain-overhead-calculation.txt[]
......
......@@ -260,6 +260,9 @@ OPTIONS
To disable decoding entirely, use --no-itrace.
--full-source-path::
Show the full path for source files for srcline output.
SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-script-perl[1],
......
......@@ -738,6 +738,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
"Instruction Tracing options",
itrace_parse_synth_opts),
OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
"Show full source file name path for source lines"),
OPT_END()
};
struct perf_data_file file = {
......
......@@ -1653,6 +1653,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
"Instruction Tracing options",
itrace_parse_synth_opts),
OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
"Show full source file name path for source lines"),
OPT_END()
};
const char * const script_subcommands[] = { "record", "report", NULL };
......
......@@ -10,6 +10,8 @@
#include "symbol.h"
bool srcline_full_filename;
#ifdef HAVE_LIBBFD_SUPPORT
/*
......@@ -277,7 +279,9 @@ char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
if (!addr2line(dso_name, addr, &file, &line, dso))
goto out;
if (asprintf(&srcline, "%s:%u", basename(file), line) < 0) {
if (asprintf(&srcline, "%s:%u",
srcline_full_filename ? file : basename(file),
line) < 0) {
free(file);
goto out;
}
......
......@@ -318,6 +318,7 @@ static inline int path__join3(char *bf, size_t size,
struct dso;
struct symbol;
extern bool srcline_full_filename;
char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
bool show_sym);
void free_srcline(char *srcline);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部