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 4/4] perf script: add option resolving vmlinux path
Date: Tue, 28 Jun 2011 16:40:50 +0900 [thread overview]
Message-ID: <20110628074049.4269.64126.stgit@linux3> (raw)
In-Reply-To: <20110628074019.4269.32109.stgit@linux3>
Add the option get the path of [kernel.kallsyms].
Specify '--show-kernel-path' option to use this function.
This patch enables other applications to use this output easily.
Without --show-kernel-path option
# perf script -f ip,dso
ffffffff81467612 irq_return ([kernel.kallsyms])
ffffffff81467612 irq_return ([kernel.kallsyms])
7f24fc02a6b3 _start (/lib64/ld-2.14.so)
[snip]
With --show-kernel-path option
# perf script -f ip,dso --show-kernel-path
ffffffff81467612 irq_return (/lib/modules/3.0.0-rc3-tip+/build/vmlinux)
ffffffff81467612 irq_return (/lib/modules/3.0.0-rc3-tip+/build/vmlinux)
7f24fc02a6b3 _start (/lib64/ld-2.14.so)
[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 | 15 +++++----------
tools/perf/util/session.c | 26 +++++++++-----------------
tools/perf/util/symbol.c | 12 ++++++++++++
tools/perf/util/symbol.h | 2 ++
5 files changed, 31 insertions(+), 27 deletions(-)
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 39c4721..be59d8b 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -185,6 +185,9 @@ OPTIONS
--show-symbol-offset::
Show the offset of the symbols.
+--show-kernel-path::
+ Try to resolve the path of [kernel.kallsyms]
+
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 f9b7047..750673f 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -324,7 +324,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;
+ const char *symname;
unsigned long offset;
printf("%16" PRIx64, sample->addr);
@@ -359,14 +359,8 @@ static void print_sample_addr(union perf_event *event,
}
}
- if (PRINT_FIELD(DSO)) {
- if (al.map && al.map->dso && al.map->dso->name)
- dsoname = al.map->dso->name;
- else
- dsoname = "";
-
- printf(" (%s)", dsoname);
- }
+ if (PRINT_FIELD(DSO) && al.map && al.map->dso)
+ printf(" (%s)", dso__get_dsoname_for_print(al.map->dso));
}
static void process_event(union perf_event *event __unused,
@@ -1092,7 +1086,8 @@ static const struct option options[] = {
parse_output_fields),
OPT_BOOLEAN('\0', "show-symbol-offset", &show_symbol_offset,
"Show the offset of the symbol."),
-
+ OPT_BOOLEAN('\0', "show-kernel-path", &show_kernel_path,
+ "Show the path of [kernel.kallsyms]"),
OPT_END()
};
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index bb522ed..f385511 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -13,6 +13,8 @@
#include "sort.h"
#include "util.h"
+bool show_kernel_path;
+
static int perf_session__open(struct perf_session *self, bool force)
{
struct stat input_stat;
@@ -1208,7 +1210,7 @@ void perf_session__print_ip(union perf_event *event,
int print_sym, int print_dso, int print_offset)
{
struct addr_location al;
- const char *symname, *dsoname;
+ const char *symname;
unsigned long offset;
struct callchain_cursor *cursor = &session->callchain_cursor;
struct callchain_cursor_node *node;
@@ -1244,14 +1246,9 @@ void perf_session__print_ip(union perf_event *event,
printf(" %s", symname);
}
- if (print_dso) {
- if (node->map && node->map->dso && node->map->dso->name)
- dsoname = node->map->dso->name;
- else
- dsoname = "";
-
- printf(" (%s)", dsoname);
- }
+ if (print_dso && node->map && node->map->dso)
+ printf(" (%s)", dso__get_dsoname_for_print(
+ node->map->dso));
printf("\n");
callchain_cursor_advance(cursor);
@@ -1271,13 +1268,8 @@ void perf_session__print_ip(union perf_event *event,
}
}
- if (print_dso) {
- if (al.map && al.map->dso && al.map->dso->name)
- dsoname = al.map->dso->name;
- else
- dsoname = "";
-
- printf(" (%s)", dsoname);
- }
+ if (print_dso && al.map && al.map->dso)
+ printf(" (%s)",
+ dso__get_dsoname_for_print(al.map->dso));
}
}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index eec1963..60dbd39 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -41,6 +41,7 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
symbol_filter_t filter);
static int vmlinux_path__nr_entries;
static char **vmlinux_path;
+bool show_kernel_path;
struct symbol_conf symbol_conf = {
.exclude_other = true,
@@ -431,6 +432,17 @@ size_t dso__fprintf(struct dso *dso, enum map_type type, FILE *fp)
return ret;
}
+const char *dso__get_dsoname_for_print(struct dso *dso)
+{
+ if (dso) {
+ if (show_kernel_path && dso->long_name)
+ return dso->long_name;
+ else
+ return dso->name;
+ } else
+ return "";
+}
+
int kallsyms__parse(const char *filename, void *arg,
int (*process_symbol)(void *arg, const char *name,
char type, u64 start, u64 end))
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 325ee36..6b9a7f3 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -96,6 +96,7 @@ struct symbol_conf {
};
extern struct symbol_conf symbol_conf;
+extern bool show_kernel_path;
static inline void *symbol__priv(struct symbol *sym)
{
@@ -195,6 +196,7 @@ size_t dso__fprintf_buildid(struct dso *dso, FILE *fp);
size_t dso__fprintf_symbols_by_name(struct dso *dso,
enum map_type type, FILE *fp);
size_t dso__fprintf(struct dso *dso, enum map_type type, FILE *fp);
+const char *dso__get_dsoname_for_print(struct dso *dso);
enum symtab_type {
SYMTAB__KALLSYMS = 0,
next prev parent reply other threads:[~2011-06-28 7:40 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 ` [PATCH -tip 3/4] perf script: add the option to show the offset of symbols Akihiro Nagai
2011-06-28 14:52 ` 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 ` Akihiro Nagai [this message]
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=20110628074049.4269.64126.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.