Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1271301

[PATCH 3/3] perf test: Add callchain order setup for DWARF unwinder test

From Jiri Olsa <jolsa@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 3/3] perf test: Add callchain order setup for DWARF unwinder test
Date 2015-11-17 16:10 +0100
Message-ID <qvQ3p-6Fs-27@gated-at.bofh.it> (permalink)
References <qvQ3o-6Fs-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Adding callchain order setup for DWARF unwinder test. The test
now runs unwinder for both callee and caller orders.

Link: http://lkml.kernel.org/n/tip-zz3q3vrre3re8efdw3c89aef@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/tests/dwarf-unwind.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 07221793a3ac..05d9ba387c43 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -51,6 +51,12 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
 		"krava_1",
 		"test__dwarf_unwind"
 	};
+	/*
+	 * The funcs[MAX_STACK] array index, based on the
+	 * callchain order setup.
+	 */
+	int idx = callchain_param.order == ORDER_CALLER ?
+		  MAX_STACK - *cnt - 1 : *cnt;
 
 	if (*cnt >= MAX_STACK) {
 		pr_debug("failed: crossed the max stack value %d\n", MAX_STACK);
@@ -63,8 +69,10 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
 		return -1;
 	}
 
-	pr_debug("got: %s 0x%" PRIx64 "\n", symbol, entry->ip);
-	return strcmp((const char *) symbol, funcs[(*cnt)++]);
+	(*cnt)++;
+	pr_debug("got: %s 0x%" PRIx64 ", expecting %s\n",
+		 symbol, entry->ip, funcs[idx]);
+	return strcmp((const char *) symbol, funcs[idx]);
 }
 
 __attribute__ ((noinline))
@@ -105,8 +113,16 @@ static int compare(void *p1, void *p2)
 	/* Any possible value should be 'thread' */
 	struct thread *thread = *(struct thread **)p1;
 
-	if (global_unwind_retval == -INT_MAX)
+	if (global_unwind_retval == -INT_MAX) {
+		/* Call unwinder twice for both callchain orders. */
+		callchain_param.order = ORDER_CALLER;
+
 		global_unwind_retval = unwind_thread(thread);
+		if (!global_unwind_retval) {
+			callchain_param.order = ORDER_CALLEE;
+			global_unwind_retval = unwind_thread(thread);
+		}
+	}
 
 	return p1 - p2;
 }
-- 
2.4.3

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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] perf tools DWARF libunwind: Add callchain order support Jiri Olsa <jolsa@kernel.org> - 2015-11-17 16:10 +0100
  [PATCH 3/3] perf test: Add callchain order setup for DWARF unwinder test Jiri Olsa <jolsa@kernel.org> - 2015-11-17 16:10 +0100
    [tip:perf/core] perf test:   Add callchain order setup for DWARF unwinder test tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-26 09:30 +0100
  Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-18 05:30 +0100
  [PATCH 4/3] perf tools: Add callchain order support for libdw DWARF  unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-19 12:30 +0100
    Re: [PATCH 4/3] perf tools: Add callchain order support for libdw  DWARF unwinder "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-19 13:20 +0100
    Re: [PATCH 4/3] perf tools: Add callchain order support for libdw  DWARF unwinder "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-19 13:20 +0100
      [PATCHv2 4/3] perf tools: Add callchain order support for libdw  DWARF unwinder Jiri Olsa <jolsa@redhat.com> - 2015-11-19 14:10 +0100
        [tip:perf/core] perf callchain:   Add order support for libdw DWARF unwinder tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-26 09:30 +0100
  Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order  support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-19 20:20 +0100
    Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order  support Jiri Olsa <jolsa@redhat.com> - 2015-11-20 09:40 +0100
    Re: [PATCH 0/3] perf tools DWARF libunwind: Add callchain order support Milian Wolff <milian.wolff@kdab.com> - 2015-11-22 20:20 +0100

csiph-web