From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 03/12] perf callchain: Enable printing the srcline in the history
Date: Tue, 25 Nov 2014 10:22:01 -0300 [thread overview]
Message-ID: <1416921730-5063-4-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1416921730-5063-1-git-send-email-acme@kernel.org>
From: Andi Kleen <ak@linux.intel.com>
For lbr-as-callgraph we need to see the line number in the history,
because many LBR entries can be in a single function, and just
showing the same function name many times is not useful.
When the history code is configured to sort by address, also try to
resolve the address to a file:srcline and display this in the browser.
If that doesn't work still display the address.
This can be also useful without LBRs for understanding which call in a large
function (or in which inlined function) called something else.
Contains fixes from Namhyung Kim
v2: Refactor code into common function
v3: Fix GTK build
v4: Rebase
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1415844328-4884-7-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/callchain.c | 11 ++++++++++-
tools/perf/util/callchain.h | 1 +
tools/perf/util/srcline.c | 6 ++++--
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 38da69c8c1ff..b6624aeaaca9 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -815,7 +815,16 @@ char *callchain_list__sym_name(struct callchain_list *cl,
int printed;
if (cl->ms.sym) {
- printed = scnprintf(bf, bfsize, "%s", cl->ms.sym->name);
+ if (callchain_param.key == CCKEY_ADDRESS &&
+ cl->ms.map && !cl->srcline)
+ cl->srcline = get_srcline(cl->ms.map->dso,
+ map__rip_2objdump(cl->ms.map,
+ cl->ip));
+ if (cl->srcline)
+ printed = scnprintf(bf, bfsize, "%s %s",
+ cl->ms.sym->name, cl->srcline);
+ else
+ printed = scnprintf(bf, bfsize, "%s", cl->ms.sym->name);
} else
printed = scnprintf(bf, bfsize, "%#" PRIx64, cl->ip);
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 3e1ed15d11f1..3f158474c892 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -70,6 +70,7 @@ extern struct callchain_param callchain_param;
struct callchain_list {
u64 ip;
struct map_symbol ms;
+ char *srcline;
struct list_head list;
};
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 77c180637138..ac877f96fed7 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -258,7 +258,7 @@ char *get_srcline(struct dso *dso, unsigned long addr)
const char *dso_name;
if (!dso->has_srcline)
- return SRCLINE_UNKNOWN;
+ goto out;
if (dso->symsrc_filename)
dso_name = dso->symsrc_filename;
@@ -289,7 +289,9 @@ out:
dso->has_srcline = 0;
dso__free_a2l(dso);
}
- return SRCLINE_UNKNOWN;
+ if (asprintf(&srcline, "%s[%lx]", dso->short_name, addr) < 0)
+ return SRCLINE_UNKNOWN;
+ return srcline;
}
void free_srcline(char *srcline)
--
1.9.3
next prev parent reply other threads:[~2014-11-25 13:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 13:21 [GIT PULL 00/12] perf/core improvements and fixes Arnaldo Carvalho de Melo
2014-11-25 13:21 ` [PATCH 01/12] perf hists browser: Print overhead percent value for first-level callchain Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 02/12] perf tools: Collapse first level callchain entry if it has sibling Arnaldo Carvalho de Melo
2014-11-25 13:22 ` Arnaldo Carvalho de Melo [this message]
2014-11-25 13:22 ` [PATCH 04/12] perf symbols: Move bfd_demangle stubbing to its only user Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 05/12] perf callchain: Make get_srcline fall back to sym+offset Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 06/12] perf tools: Fix segfault due to invalid kernel dso access Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 07/12] perf tools: Allow to force redirect pr_debug to stderr Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 08/12] perf evsel: Introduce perf_evsel__compute_deltas function Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 09/12] perf evsel: Introduce perf_counts_values__scale function Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 10/12] perf evsel: Introduce perf_evsel__read_cb function Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 11/12] perf tools: Add per-pkg format file parsing Arnaldo Carvalho de Melo
2014-11-25 13:22 ` [PATCH 12/12] perf tools: Add snapshot " 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=1416921730-5063-4-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).