From: Aaron Tomlin <atomlin@redhat.com>
To: acme@kernel.org
Cc: josla@redhat.com, mingo@redhat.com,
alexander.shishkin@linux.intel.com, namhyung@kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH/RFC] perf report: Add option to change offset format when address is specified as a sort_key
Date: Fri, 15 Dec 2017 15:35:10 +0000 [thread overview]
Message-ID: <20171215153510.14499-1-atomlin@redhat.com> (raw)
With --call-graph option, a user can choose to display call chains with a
specific sort_key. The sort_key can be either: function, address or srcline.
By default, when the address is specified as the sort_key, the offset (i.e.
symbol + offset) is provided in decimal (base 10) form.
This is because in __get_srcline() we use PRIu64 to display the offset.
This may or may not be desirable.
This patch adds a new option --hex, to change the offset format to
hexidecimal. Note, this can only be used with the -g, --call-graph option
when address is specified as a sort_key. When this option is not
specified, the default behavior is used, which is to display the offset
in decimal form.
Before:
$ ./perf report -n --fields=overhead,sample,period,pid,symbol --stdio \
> -g graph,callee,address --percent-limit 10 --no-children
[ ... ]
10.87% 1 506940477 15:migration/3 [k] _spin_trylock
|
---_spin_trylock +13
double_lock_balance +48
schedule +2007
migration_thread +613
kthread +158
child_rip +10
After:
$ ./perf report -n --fields=overhead,sample,period,pid,symbol --stdio \
> -g graph,callee,address --percent-limit 10 --hex --no-children
[ ... ]
10.87% 1 506940477 15:migration/3 [k] _spin_trylock
|
---_spin_trylock +0xd
double_lock_balance +0x30
schedule +0x7d7
migration_thread +0x265
kthread +0x9e
child_rip +0xa
Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
---
tools/perf/Documentation/perf-report.txt | 4 ++++
tools/perf/builtin-report.c | 2 ++
tools/perf/util/srcline.c | 6 ++++--
tools/perf/util/srcline.h | 1 +
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index ddde2b5..589435a 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -386,6 +386,10 @@ OPTIONS
sum of shown entries will be always 100%. "absolute" means it retains
the original value before and after the filter is applied.
+--hex::
+ When address is specified as a sort_key, show the offset in
+ hexidecimal form. (Default: decimal)
+
--header::
Show header information in the perf.data file. This includes
various information like hostname, OS and perf version, cpu/mem
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index af5dd03..7820e55 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -866,6 +866,8 @@ int cmd_report(int argc, const char **argv)
itrace_parse_synth_opts),
OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
"Show full source file name path for source lines"),
+ OPT_BOOLEAN(0, "hex", &show_hex_offset,
+ "When address is specified as a sort_key, show the offset in hexidecimal form"),
OPT_BOOLEAN(0, "show-ref-call-graph", &symbol_conf.show_ref_callgraph,
"Show callgraph from reference event"),
OPT_INTEGER(0, "socket-filter", &report.socket_filter,
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index d19f05c..98fc911 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -15,6 +15,7 @@
#include "symbol.h"
bool srcline_full_filename;
+bool show_hex_offset;
static const char *dso__name(struct dso *dso)
{
@@ -535,8 +536,9 @@ char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
strndup(sym->name, sym->namelen) : NULL;
if (sym) {
- if (asprintf(&srcline, "%s+%" PRIu64, show_sym ? sym->name : "",
- addr - sym->start) < 0)
+ if (asprintf(&srcline,
+ show_hex_offset ? "%s+%#" PRIx64 : "%s+%" PRIu64,
+ show_sym ? sym->name : "", addr - sym->start) < 0)
return SRCLINE_UNKNOWN;
} else if (asprintf(&srcline, "%s[%" PRIx64 "]", dso->short_name, addr) < 0)
return SRCLINE_UNKNOWN;
diff --git a/tools/perf/util/srcline.h b/tools/perf/util/srcline.h
index 847b708..1bca068 100644
--- a/tools/perf/util/srcline.h
+++ b/tools/perf/util/srcline.h
@@ -10,6 +10,7 @@ struct dso;
struct symbol;
extern bool srcline_full_filename;
+extern bool show_hex_offset;
char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
bool show_sym, bool show_addr);
char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
--
2.9.5
next reply other threads:[~2017-12-15 15:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 15:35 Aaron Tomlin [this message]
2017-12-22 23:59 ` [PATCH/RFC] perf report: Add option to change offset format when address is specified as a sort_key Jiri Olsa
2017-12-24 18:23 ` Aaron Tomlin
2017-12-25 21:46 ` Jiri Olsa
2017-12-26 14:51 ` Arnaldo Carvalho de Melo
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=20171215153510.14499-1-atomlin@redhat.com \
--to=atomlin@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=josla@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
/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.