diff options
| author | Ingo Molnar <mingo@kernel.org> | 2015-01-28 09:30:32 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2015-01-28 09:30:32 -0500 |
| commit | 41ca5d4e9be11ea6ae040b51d9628a189fd82896 (patch) | |
| tree | f9c35cc37b9622f6cccd91b94548f44b9a534029 /tools/perf/tests/dwarf-unwind.c | |
| parent | 0fcedc8631ec28ca25d3c0b116e8fa0c19dd5f6d (diff) | |
| parent | 3669ef9fa7d35f573ec9c0e0341b29251c2734a7 (diff) | |
Merge commit 3669ef9fa7d3 ("x86, tls: Interpret an all-zero struct user_desc as 'no segment'") into x86/asm
Pick up the latestest asm fixes before advancing it any further.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/tests/dwarf-unwind.c')
| -rw-r--r-- | tools/perf/tests/dwarf-unwind.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c index ab28cca2cb97..0bf06bec68c7 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c | |||
| @@ -11,6 +11,9 @@ | |||
| 11 | #include "thread.h" | 11 | #include "thread.h" |
| 12 | #include "callchain.h" | 12 | #include "callchain.h" |
| 13 | 13 | ||
| 14 | /* For bsearch. We try to unwind functions in shared object. */ | ||
| 15 | #include <stdlib.h> | ||
| 16 | |||
| 14 | static int mmap_handler(struct perf_tool *tool __maybe_unused, | 17 | static int mmap_handler(struct perf_tool *tool __maybe_unused, |
| 15 | union perf_event *event, | 18 | union perf_event *event, |
| 16 | struct perf_sample *sample __maybe_unused, | 19 | struct perf_sample *sample __maybe_unused, |
| @@ -28,7 +31,7 @@ static int init_live_machine(struct machine *machine) | |||
| 28 | mmap_handler, machine, true); | 31 | mmap_handler, machine, true); |
| 29 | } | 32 | } |
| 30 | 33 | ||
| 31 | #define MAX_STACK 6 | 34 | #define MAX_STACK 8 |
| 32 | 35 | ||
| 33 | static int unwind_entry(struct unwind_entry *entry, void *arg) | 36 | static int unwind_entry(struct unwind_entry *entry, void *arg) |
| 34 | { | 37 | { |
| @@ -37,6 +40,8 @@ static int unwind_entry(struct unwind_entry *entry, void *arg) | |||
| 37 | static const char *funcs[MAX_STACK] = { | 40 | static const char *funcs[MAX_STACK] = { |
| 38 | "test__arch_unwind_sample", | 41 | "test__arch_unwind_sample", |
| 39 | "unwind_thread", | 42 | "unwind_thread", |
| 43 | "compare", | ||
| 44 | "bsearch", | ||
| 40 | "krava_3", | 45 | "krava_3", |
| 41 | "krava_2", | 46 | "krava_2", |
| 42 | "krava_1", | 47 | "krava_1", |
| @@ -88,10 +93,37 @@ static int unwind_thread(struct thread *thread) | |||
| 88 | return err; | 93 | return err; |
| 89 | } | 94 | } |
| 90 | 95 | ||
| 96 | static int global_unwind_retval = -INT_MAX; | ||
| 97 | |||
| 98 | __attribute__ ((noinline)) | ||
| 99 | static int compare(void *p1, void *p2) | ||
| 100 | { | ||
| 101 | /* Any possible value should be 'thread' */ | ||
| 102 | struct thread *thread = *(struct thread **)p1; | ||
| 103 | |||
| 104 | if (global_unwind_retval == -INT_MAX) | ||
| 105 | global_unwind_retval = unwind_thread(thread); | ||
| 106 | |||
| 107 | return p1 - p2; | ||
| 108 | } | ||
| 109 | |||
| 91 | __attribute__ ((noinline)) | 110 | __attribute__ ((noinline)) |
| 92 | static int krava_3(struct thread *thread) | 111 | static int krava_3(struct thread *thread) |
| 93 | { | 112 | { |
| 94 | return unwind_thread(thread); | 113 | struct thread *array[2] = {thread, thread}; |
| 114 | void *fp = &bsearch; | ||
| 115 | /* | ||
| 116 | * make _bsearch a volatile function pointer to | ||
| 117 | * prevent potential optimization, which may expand | ||
| 118 | * bsearch and call compare directly from this function, | ||
| 119 | * instead of libc shared object. | ||
| 120 | */ | ||
| 121 | void *(*volatile _bsearch)(void *, void *, size_t, | ||
| 122 | size_t, int (*)(void *, void *)); | ||
| 123 | |||
| 124 | _bsearch = fp; | ||
| 125 | _bsearch(array, &thread, 2, sizeof(struct thread **), compare); | ||
| 126 | return global_unwind_retval; | ||
| 95 | } | 127 | } |
| 96 | 128 | ||
| 97 | __attribute__ ((noinline)) | 129 | __attribute__ ((noinline)) |
