[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tip-fja1ods5vqpg42mdz09xcz3r@git.kernel.org>
Date: Wed, 13 Apr 2016 00:27:01 -0700
From: tip-bot for Arnaldo Carvalho de Melo <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: mingo@...nel.org, milian.wolff@...b.com, jolsa@...nel.org,
dsahern@...il.com, namhyung@...nel.org, tglx@...utronix.de,
linux-kernel@...r.kernel.org, hpa@...or.com, acme@...hat.com,
adrian.hunter@...el.com, wangnan0@...wei.com
Subject: [tip:perf/core] perf evsel: Allow unresolved symbol names to be
printed as addresses
Commit-ID: fd4be13067ef65bf33b965a18c717889305d5fea
Gitweb: http://git.kernel.org/tip/fd4be13067ef65bf33b965a18c717889305d5fea
Author: Arnaldo Carvalho de Melo <acme@...hat.com>
AuthorDate: Mon, 11 Apr 2016 22:03:56 -0300
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 11 Apr 2016 22:18:24 -0300
perf evsel: Allow unresolved symbol names to be printed as addresses
The fprintf_sym() and fprintf_callchain() methods now allow users to
change the existing behaviour of showing "[unknown]" as the name of
unresolved symbols to instead show "[0x123456]", i.e. its address.
The current patch doesn't change tools to use this facility, the results
from 'perf trace' and 'perf script' cotinue like:
70.109 ( 0.001 ms): qemu-system-x8/10153 poll(ufds: 0x7f2d93ffe870, nfds: 1) = 0 Timeout
[unknown] (/usr/lib64/libc-2.22.so)
[unknown] (/usr/lib64/libspice-server.so.1.10.0)
[unknown] (/usr/lib64/libspice-server.so.1.10.0)
[unknown] (/usr/lib64/libspice-server.so.1.10.0)
start_thread+0xca (/usr/lib64/libpthread-2.22.so)
__clone+0x6d (/usr/lib64/libc-2.22.so)
The next patch will make 'perf trace' use the new formatting.
Suggested-by: Milian Wolff <milian.wolff@...b.com>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Wang Nan <wangnan0@...wei.com>
Link: http://lkml.kernel.org/n/tip-fja1ods5vqpg42mdz09xcz3r@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/session.c | 27 ++++++++++++++++++---------
tools/perf/util/session.h | 1 +
tools/perf/util/symbol.c | 25 +++++++++++++++++++++----
tools/perf/util/symbol.h | 6 ++++++
4 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index e384b65..0516d06 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1966,6 +1966,7 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
int print_symoffset = print_opts & PRINT_IP_OPT_SYMOFFSET;
int print_oneline = print_opts & PRINT_IP_OPT_ONELINE;
int print_srcline = print_opts & PRINT_IP_OPT_SRCLINE;
+ int print_unknown_as_addr = print_opts & PRINT_IP_OPT_UNKNOWN_AS_ADDR;
char s = print_oneline ? ' ' : '\t';
if (sample->callchain) {
@@ -2003,12 +2004,16 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
if (print_sym) {
printed += fprintf(fp, " ");
+ node_al.addr = addr;
+ node_al.map = node->map;
+
if (print_symoffset) {
- node_al.addr = addr;
- node_al.map = node->map;
- printed += symbol__fprintf_symname_offs(node->sym, &node_al, fp);
- } else
- printed += symbol__fprintf_symname(node->sym, fp);
+ printed += __symbol__fprintf_symname_offs(node->sym, &node_al,
+ print_unknown_as_addr, fp);
+ } else {
+ printed += __symbol__fprintf_symname(node->sym, &node_al,
+ print_unknown_as_addr, fp);
+ }
}
if (print_dso) {
@@ -2043,6 +2048,7 @@ int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample
int print_dso = print_opts & PRINT_IP_OPT_DSO;
int print_symoffset = print_opts & PRINT_IP_OPT_SYMOFFSET;
int print_srcline = print_opts & PRINT_IP_OPT_SRCLINE;
+ int print_unknown_as_addr = print_opts & PRINT_IP_OPT_UNKNOWN_AS_ADDR;
if (symbol_conf.use_callchain && sample->callchain) {
printed += perf_evsel__fprintf_callchain(evsel, sample, al, left_alignment,
@@ -2055,10 +2061,13 @@ int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample
if (print_sym) {
printed += fprintf(fp, " ");
- if (print_symoffset)
- printed += symbol__fprintf_symname_offs(al->sym, al, fp);
- else
- printed += symbol__fprintf_symname(al->sym, fp);
+ if (print_symoffset) {
+ printed += __symbol__fprintf_symname_offs(al->sym, al,
+ print_unknown_as_addr, fp);
+ } else {
+ printed += __symbol__fprintf_symname(al->sym, al,
+ print_unknown_as_addr, fp);
+ }
}
if (print_dso) {
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index ac83490..4257fac 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -42,6 +42,7 @@ struct perf_session {
#define PRINT_IP_OPT_SYMOFFSET (1<<3)
#define PRINT_IP_OPT_ONELINE (1<<4)
#define PRINT_IP_OPT_SRCLINE (1<<5)
+#define PRINT_IP_OPT_UNKNOWN_AS_ADDR (1<<6)
struct perf_tool;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e7588dc..bb162ee 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -264,8 +264,9 @@ size_t symbol__fprintf(struct symbol *sym, FILE *fp)
sym->name);
}
-size_t symbol__fprintf_symname_offs(const struct symbol *sym,
- const struct addr_location *al, FILE *fp)
+size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
+ const struct addr_location *al,
+ bool unknown_as_addr, FILE *fp)
{
unsigned long offset;
size_t length;
@@ -280,13 +281,29 @@ size_t symbol__fprintf_symname_offs(const struct symbol *sym,
length += fprintf(fp, "+0x%lx", offset);
}
return length;
- } else
+ } else if (al && unknown_as_addr)
+ return fprintf(fp, "[%#" PRIx64 "]", al->addr);
+ else
return fprintf(fp, "[unknown]");
}
+size_t symbol__fprintf_symname_offs(const struct symbol *sym,
+ const struct addr_location *al,
+ FILE *fp)
+{
+ return __symbol__fprintf_symname_offs(sym, al, false, fp);
+}
+
+size_t __symbol__fprintf_symname(const struct symbol *sym,
+ const struct addr_location *al,
+ bool unknown_as_addr, FILE *fp)
+{
+ return __symbol__fprintf_symname_offs(sym, al, unknown_as_addr, fp);
+}
+
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
{
- return symbol__fprintf_symname_offs(sym, NULL, fp);
+ return __symbol__fprintf_symname_offs(sym, NULL, false, fp);
}
void symbols__delete(struct rb_root *symbols)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index c8b7544..e256256 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -262,8 +262,14 @@ int symbol__init(struct perf_env *env);
void symbol__exit(void);
void symbol__elf_init(void);
struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
+size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
+ const struct addr_location *al,
+ bool unknown_as_addr, FILE *fp);
size_t symbol__fprintf_symname_offs(const struct symbol *sym,
const struct addr_location *al, FILE *fp);
+size_t __symbol__fprintf_symname(const struct symbol *sym,
+ const struct addr_location *al,
+ bool unknown_as_addr, FILE *fp);
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp);
size_t symbol__fprintf(struct symbol *sym, FILE *fp);
bool symbol_type__is_a(char symbol_type, enum map_type map_type);
Powered by blists - more mailing lists