lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1449273162-57734-1-git-send-email-costa@purestorage.com>
Date:	Fri,  4 Dec 2015 15:52:42 -0800
From:	Constantine Sapuntzakis <costa@...estorage.com>
To:	acme@...nel.org
Cc:	Constantine Sapuntzakis <costa@...estorage.com>,
	namhyung@...nel.org, peterz@...radead.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] DWARF/unwind support for ORDER_CALLER

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@...estorage.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ