Commit 8dc0564d authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf test: Add callchain order setup for DWARF unwinder test

Adding callchain order setup for DWARF unwinder test. The test now runs
unwinder for both callee and caller orders.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Tested-by: default avatarMilian Wolff <milian.wolff@kdab.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1447772739-18471-4-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent cb1dc22d
...@@ -51,6 +51,12 @@ static int unwind_entry(struct unwind_entry *entry, void *arg) ...@@ -51,6 +51,12 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
"krava_1", "krava_1",
"test__dwarf_unwind" "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) { if (*cnt >= MAX_STACK) {
pr_debug("failed: crossed the max stack value %d\n", 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) ...@@ -63,8 +69,10 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
return -1; return -1;
} }
pr_debug("got: %s 0x%" PRIx64 "\n", symbol, entry->ip); (*cnt)++;
return strcmp((const char *) symbol, funcs[(*cnt)++]); pr_debug("got: %s 0x%" PRIx64 ", expecting %s\n",
symbol, entry->ip, funcs[idx]);
return strcmp((const char *) symbol, funcs[idx]);
} }
__attribute__ ((noinline)) __attribute__ ((noinline))
...@@ -105,8 +113,16 @@ static int compare(void *p1, void *p2) ...@@ -105,8 +113,16 @@ static int compare(void *p1, void *p2)
/* Any possible value should be 'thread' */ /* Any possible value should be 'thread' */
struct thread *thread = *(struct thread **)p1; 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); global_unwind_retval = unwind_thread(thread);
if (!global_unwind_retval) {
callchain_param.order = ORDER_CALLEE;
global_unwind_retval = unwind_thread(thread);
}
}
return p1 - p2; return p1 - p2;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment