From: Constantine Sapuntzakis <costa@purestorage.com>
To: acme@kernel.org
Cc: Constantine Sapuntzakis <costa@purestorage.com>,
namhyung@kernel.org, peterz@infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] DWARF/unwind support for ORDER_CALLER
Date: Fri, 4 Dec 2015 15:52:42 -0800 [thread overview]
Message-ID: <1449273162-57734-1-git-send-email-costa@purestorage.com> (raw)
Prior to this, perf report -G and kin did not respect ORDER_CALLER
for DWARF unwinds.
ORDER_CALLER is implemented for fp backtraces by reversing the
callchain when pushing onto the cursor. Simulate this behavior by
prepending the frames onto the cursor when doing the DWARF unwind.
Signed-off-by: Constantine Sapuntzakis <costa@purestorage.com>
---
tools/perf/util/callchain.c | 29 +++++++++++++++++++++++++++++
tools/perf/util/callchain.h | 3 +++
tools/perf/util/machine.c | 17 +++++++++++++++--
3 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 564377d..b93c760 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -742,6 +742,35 @@ int callchain_cursor_append(struct callchain_cursor *cursor,
return 0;
}
+int callchain_cursor_prepend(struct callchain_cursor *cursor,
+ u64 ip, struct map *map, struct symbol *sym)
+{
+ struct callchain_cursor_node *node = *cursor->last;
+
+ if (!node) {
+ node = calloc(1, sizeof(*node));
+ if (!node)
+ return -ENOMEM;
+ } else {
+ /* Pop the first free node off the end of the list */
+ *cursor->last = node->next;
+ }
+
+ node->ip = ip;
+ node->map = map;
+ node->sym = sym;
+
+ node->next = cursor->first;
+ cursor->first = node;
+
+ cursor->nr++;
+ if (cursor->nr == 1) {
+ cursor->last = &node->next;
+ }
+
+ return 0;
+}
+
int sample__resolve_callchain(struct perf_sample *sample, struct symbol **parent,
struct perf_evsel *evsel, struct addr_location *al,
int max_stack)
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 8ac8f043..efa90e9 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -182,6 +182,9 @@ static inline void callchain_cursor_reset(struct callchain_cursor *cursor)
int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip,
struct map *map, struct symbol *sym);
+int callchain_cursor_prepend(struct callchain_cursor *cursor, u64 ip,
+ struct map *map, struct symbol *sym);
+
/* Close a cursor writing session. Initialize for the reader */
static inline void callchain_cursor_commit(struct callchain_cursor *cursor)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 95a7f60..05192d3 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1896,7 +1896,7 @@ check_calls:
return 0;
}
-static int unwind_entry(struct unwind_entry *entry, void *arg)
+static int unwind_entry_callee(struct unwind_entry *entry, void *arg)
{
struct callchain_cursor *cursor = arg;
@@ -1906,6 +1906,16 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
entry->map, entry->sym);
}
+static int unwind_entry_caller(struct unwind_entry *entry, void *arg)
+{
+ struct callchain_cursor *cursor = arg;
+
+ if (symbol_conf.hide_unresolved && entry->sym == NULL)
+ return 0;
+ return callchain_cursor_prepend(cursor, entry->ip,
+ entry->map, entry->sym);
+}
+
int thread__resolve_callchain(struct thread *thread,
struct perf_evsel *evsel,
struct perf_sample *sample,
@@ -1929,7 +1939,10 @@ int thread__resolve_callchain(struct thread *thread,
(!sample->user_stack.size))
return 0;
- return unwind__get_entries(unwind_entry, &callchain_cursor,
+ return unwind__get_entries(callchain_param.order == ORDER_CALLEE ?
+ unwind_entry_callee :
+ unwind_entry_caller,
+ &callchain_cursor,
thread, sample, max_stack);
}
--
1.8.4.GIT
reply other threads:[~2015-12-04 23:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1449273162-57734-1-git-send-email-costa@purestorage.com \
--to=costa@purestorage.com \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®