aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2013-08-07 07:38:48 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-08-07 16:35:32 -0400
commitd380b34830cc76461feab012f0bc52b01e65087c (patch)
treebb36e59b312ef27a1a11bacb308a138e8a9c9b10
parent39b12f7812710e9a5896805d96812b3ede7491e8 (diff)
perf tests: Adjust the vmlinux symtab matches kallsyms test
The vmlinux maps now map to the dso and the symbol values are now file offsets. For comparison with kallsyms the virtual memory address is needed which is obtained by unmapping the symbol value. The "vmlinux symtab matches kallsyms" is adjusted accordingly. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1375875537-4509-5-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/tests/vmlinux-kallsyms.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index add15392c622..e2e14984c3a0 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -25,6 +25,7 @@ int test__vmlinux_matches_kallsyms(void)
25 struct machine kallsyms, vmlinux; 25 struct machine kallsyms, vmlinux;
26 enum map_type type = MAP__FUNCTION; 26 enum map_type type = MAP__FUNCTION;
27 struct ref_reloc_sym ref_reloc_sym = { .name = "_stext", }; 27 struct ref_reloc_sym ref_reloc_sym = { .name = "_stext", };
28 u64 mem_start, mem_end;
28 29
29 /* 30 /*
30 * Step 1: 31 * Step 1:
@@ -123,10 +124,14 @@ int test__vmlinux_matches_kallsyms(void)
123 if (sym->start == sym->end) 124 if (sym->start == sym->end)
124 continue; 125 continue;
125 126
126 first_pair = machine__find_kernel_symbol(&kallsyms, type, sym->start, NULL, NULL); 127 mem_start = vmlinux_map->unmap_ip(vmlinux_map, sym->start);
128 mem_end = vmlinux_map->unmap_ip(vmlinux_map, sym->end);
129
130 first_pair = machine__find_kernel_symbol(&kallsyms, type,
131 mem_start, NULL, NULL);
127 pair = first_pair; 132 pair = first_pair;
128 133
129 if (pair && pair->start == sym->start) { 134 if (pair && pair->start == mem_start) {
130next_pair: 135next_pair:
131 if (strcmp(sym->name, pair->name) == 0) { 136 if (strcmp(sym->name, pair->name) == 0) {
132 /* 137 /*
@@ -138,10 +143,11 @@ next_pair:
138 * off the real size. More than that and we 143 * off the real size. More than that and we
139 * _really_ have a problem. 144 * _really_ have a problem.
140 */ 145 */
141 s64 skew = sym->end - pair->end; 146 s64 skew = mem_end - pair->end;
142 if (llabs(skew) >= page_size) 147 if (llabs(skew) >= page_size)
143 pr_debug("%#" PRIx64 ": diff end addr for %s v: %#" PRIx64 " k: %#" PRIx64 "\n", 148 pr_debug("%#" PRIx64 ": diff end addr for %s v: %#" PRIx64 " k: %#" PRIx64 "\n",
144 sym->start, sym->name, sym->end, pair->end); 149 mem_start, sym->name, mem_end,
150 pair->end);
145 151
146 /* 152 /*
147 * Do not count this as a failure, because we 153 * Do not count this as a failure, because we
@@ -159,7 +165,7 @@ detour:
159 if (nnd) { 165 if (nnd) {
160 struct symbol *next = rb_entry(nnd, struct symbol, rb_node); 166 struct symbol *next = rb_entry(nnd, struct symbol, rb_node);
161 167
162 if (next->start == sym->start) { 168 if (next->start == mem_start) {
163 pair = next; 169 pair = next;
164 goto next_pair; 170 goto next_pair;
165 } 171 }
@@ -172,10 +178,11 @@ detour:
172 } 178 }
173 179
174 pr_debug("%#" PRIx64 ": diff name v: %s k: %s\n", 180 pr_debug("%#" PRIx64 ": diff name v: %s k: %s\n",
175 sym->start, sym->name, pair->name); 181 mem_start, sym->name, pair->name);
176 } 182 }
177 } else 183 } else
178 pr_debug("%#" PRIx64 ": %s not on kallsyms\n", sym->start, sym->name); 184 pr_debug("%#" PRIx64 ": %s not on kallsyms\n",
185 mem_start, sym->name);
179 186
180 err = -1; 187 err = -1;
181 } 188 }
@@ -208,16 +215,19 @@ detour:
208 for (nd = rb_first(&vmlinux.kmaps.maps[type]); nd; nd = rb_next(nd)) { 215 for (nd = rb_first(&vmlinux.kmaps.maps[type]); nd; nd = rb_next(nd)) {
209 struct map *pos = rb_entry(nd, struct map, rb_node), *pair; 216 struct map *pos = rb_entry(nd, struct map, rb_node), *pair;
210 217
211 pair = map_groups__find(&kallsyms.kmaps, type, pos->start); 218 mem_start = vmlinux_map->unmap_ip(vmlinux_map, pos->start);
219 mem_end = vmlinux_map->unmap_ip(vmlinux_map, pos->end);
220
221 pair = map_groups__find(&kallsyms.kmaps, type, mem_start);
212 if (pair == NULL || pair->priv) 222 if (pair == NULL || pair->priv)
213 continue; 223 continue;
214 224
215 if (pair->start == pos->start) { 225 if (pair->start == mem_start) {
216 pair->priv = 1; 226 pair->priv = 1;
217 pr_info(" %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as", 227 pr_info(" %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as",
218 pos->start, pos->end, pos->pgoff, pos->dso->name); 228 pos->start, pos->end, pos->pgoff, pos->dso->name);
219 if (pos->pgoff != pair->pgoff || pos->end != pair->end) 229 if (mem_end != pair->end)
220 pr_info(": \n*%" PRIx64 "-%" PRIx64 " %" PRIx64 "", 230 pr_info(":\n*%" PRIx64 "-%" PRIx64 " %" PRIx64,
221 pair->start, pair->end, pair->pgoff); 231 pair->start, pair->end, pair->pgoff);
222 pr_info(" %s\n", pair->dso->name); 232 pr_info(" %s\n", pair->dso->name);
223 pair->priv = 1; 233 pair->priv = 1;