From: Akihiro Nagai <akihiro.nagai.hw@hitachi.com>
To: Arnaldo Carvalho de Melo <acme@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
David Ahern <dsahern@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
pp-manager@sdl.hitachi.co.jp,
Akihiro Nagai <akihiro.nagai.hw@hitachi.com>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
Arnaldo Carvalho de Melo <acme@infradead.org>,
David Ahern <dsahern@gmail.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Subject: [PATCH -tip 3/4] perf script: add the option to show the offset of symbols
Date: Tue, 28 Jun 2011 16:40:44 +0900 [thread overview]
Message-ID: <20110628074044.4269.40422.stgit@linux3> (raw)
In-Reply-To: <20110628074019.4269.32109.stgit@linux3>
Add the option '--show-symbol-offset' to show the offset from
the symbols in the output of perf-script. We can get the more
detailed address information.
Output sample:
# perf script -f ip,addr,sym --show-symbol-offset
301ec016b0 ffffffff81467612 irq_return+0x0
301ec016b0 _start+0x0 ffffffff81467612 irq_return+0x0
301ec04b70 _dl_start+0x0 301ec016b3 _start+0x3
301ec04b70 _dl_start+0x0 ffffffff81467612 irq_return+0x0
301ec04b96 _dl_start+0x26 ffffffff81467612 irq_return+0x0
301ec04b9d _dl_start+0x2d ffffffff81467612 irq_return+0x0
301ec04c0d _dl_start+0x9d 301ec04beb _dl_start+0x7b
301ec04bf0 _dl_start+0x80 301ec04c11 _dl_start+0xa1
[snip]
Signed-off-by: Akihiro Nagai <akihiro.nagai.hw@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
tools/perf/Documentation/perf-script.txt | 3 +++
tools/perf/builtin-script.c | 20 ++++++++++++++------
tools/perf/util/session.c | 16 ++++++++++------
tools/perf/util/session.h | 3 ++-
4 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index c6068cb..39c4721 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -182,6 +182,9 @@ OPTIONS
--hide-call-graph::
When printing symbols do not display call chain.
+--show-symbol-offset::
+ Show the offset of the symbols.
+
SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-script-perl[1],
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 2d68086..f9b7047 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -21,6 +21,7 @@ static u64 last_timestamp;
static u64 nr_unordered;
extern const struct option record_options[];
static bool no_callchain;
+static bool show_symbol_offset;
enum perf_output_field {
PERF_OUTPUT_COMM = 1U << 0,
@@ -324,6 +325,7 @@ static void print_sample_addr(union perf_event *event,
struct addr_location al;
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
const char *symname, *dsoname;
+ unsigned long offset;
printf("%16" PRIx64, sample->addr);
@@ -346,12 +348,15 @@ static void print_sample_addr(union perf_event *event,
al.sym = map__find_symbol(al.map, al.addr, NULL);
if (PRINT_FIELD(SYM)) {
- if (al.sym && al.sym->name)
+ printf(" ");
+ if (al.sym && al.sym->name) {
symname = al.sym->name;
- else
- symname = "";
-
- printf(" %16s", symname);
+ offset = al.addr - al.sym->start;
+ if (show_symbol_offset)
+ printf("%16s+0x%lx", symname, offset);
+ else
+ printf("%16s", symname);
+ }
}
if (PRINT_FIELD(DSO)) {
@@ -390,7 +395,8 @@ static void process_event(union perf_event *event __unused,
else
printf("\n");
perf_session__print_ip(event, sample, session,
- PRINT_FIELD(SYM), PRINT_FIELD(DSO));
+ PRINT_FIELD(SYM), PRINT_FIELD(DSO),
+ show_symbol_offset);
}
printf("\n");
@@ -1084,6 +1090,8 @@ static const struct option options[] = {
OPT_CALLBACK('f', "fields", NULL, "str",
"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr",
parse_output_fields),
+ OPT_BOOLEAN('\0', "show-symbol-offset", &show_symbol_offset,
+ "Show the offset of the symbol."),
OPT_END()
};
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 632266f..bb522ed 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1205,10 +1205,11 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
void perf_session__print_ip(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session,
- int print_sym, int print_dso)
+ int print_sym, int print_dso, int print_offset)
{
struct addr_location al;
const char *symname, *dsoname;
+ unsigned long offset;
struct callchain_cursor *cursor = &session->callchain_cursor;
struct callchain_cursor_node *node;
@@ -1259,12 +1260,15 @@ void perf_session__print_ip(union perf_event *event,
} else {
printf("%16" PRIx64, sample->ip);
if (print_sym) {
- if (al.sym && al.sym->name)
+ printf(" ");
+ if (al.sym && al.sym->name) {
symname = al.sym->name;
- else
- symname = "";
-
- printf(" %s", symname);
+ offset = al.addr - al.sym->start;
+ if (print_offset)
+ printf("%s+0x%lx", symname, offset);
+ else
+ printf("%s", symname);
+ }
}
if (print_dso) {
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index de4178d..8187e68 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -170,6 +170,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
void perf_session__print_ip(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session,
- int print_sym, int print_dso);
+ int print_sym, int print_dso,
+ int print_offset);
#endif /* __PERF_SESSION_H */
next prev parent reply other threads:[~2011-06-28 7:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-28 7:40 [PATCH -tip 0/4] perf script: add BTS analysis features Akihiro Nagai
2011-06-28 7:40 ` [PATCH -tip 1/4] perf script: resolve DSOs and symbols for user-space Akihiro Nagai
2011-06-28 7:40 ` [PATCH -tip 2/4] perf script: print DSOs and symbols for BTS branch_from addr Akihiro Nagai
2011-06-28 7:40 ` Akihiro Nagai [this message]
2011-06-28 14:52 ` [PATCH -tip 3/4] perf script: add the option to show the offset of symbols David Ahern
2011-06-28 14:55 ` David Ahern
2011-06-30 4:44 ` Akihiro Nagai
2011-06-30 15:42 ` David Ahern
2011-06-28 7:40 ` [PATCH -tip 4/4] perf script: add option resolving vmlinux path Akihiro Nagai
2011-06-28 15:21 ` [PATCH -tip 0/4] perf script: add BTS analysis features David Ahern
2011-06-30 5:18 ` Akihiro Nagai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110628074044.4269.40422.stgit@linux3 \
--to=akihiro.nagai.hw@hitachi.com \
--cc=acme@infradead.org \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=pp-manager@sdl.hitachi.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox