Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jiri Olsa <jolsa@kernel.org>
Tested-by: Milian 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
8dc0564d cb1dc22d

+19 -3
+19 -3
tools/perf/tests/dwarf-unwind.c
··· 51 51 "krava_1", 52 52 "test__dwarf_unwind" 53 53 }; 54 + /* 55 + * The funcs[MAX_STACK] array index, based on the 56 + * callchain order setup. 57 + */ 58 + int idx = callchain_param.order == ORDER_CALLER ? 59 + MAX_STACK - *cnt - 1 : *cnt; 54 60 55 61 if (*cnt >= MAX_STACK) { 56 62 pr_debug("failed: crossed the max stack value %d\n", MAX_STACK); ··· 69 63 return -1; 70 64 } 71 65 72 - pr_debug("got: %s 0x%" PRIx64 "\n", symbol, entry->ip); 73 - return strcmp((const char *) symbol, funcs[(*cnt)++]); 66 + (*cnt)++; 67 + pr_debug("got: %s 0x%" PRIx64 ", expecting %s\n", 68 + symbol, entry->ip, funcs[idx]); 69 + return strcmp((const char *) symbol, funcs[idx]); 74 70 } 75 71 76 72 __attribute__ ((noinline)) ··· 113 105 /* Any possible value should be 'thread' */ 114 106 struct thread *thread = *(struct thread **)p1; 115 107 116 - if (global_unwind_retval == -INT_MAX) 108 + if (global_unwind_retval == -INT_MAX) { 109 + /* Call unwinder twice for both callchain orders. */ 110 + callchain_param.order = ORDER_CALLER; 111 + 117 112 global_unwind_retval = unwind_thread(thread); 113 + if (!global_unwind_retval) { 114 + callchain_param.order = ORDER_CALLEE; 115 + global_unwind_retval = unwind_thread(thread); 116 + } 117 + } 118 118 119 119 return p1 - p2; 120 120 }