diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-05-30 08:23:42 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-31 10:55:36 -0400 |
commit | 8db4841fc72acc58254029f050226ea5f8103854 (patch) | |
tree | 9342840928aa9f77057e425cb17ddf9edc97947a /tools/perf/util/symbol.h | |
parent | 55da80059de6c7533724fcd95f16c5d5618ecf4d (diff) |
perf symbols: Handle different endians properly during symbol load
Currently we dont care about the file object's endianness. It's possible
we read buildid file object from different architecture than we are
currentlly running on. So we need to care about properly reading such
object's data - handle different endianness properly.
Adding:
needs_swap DSO field
dso__swap_init function to initialize DSO's needs_swap
DSO__SWAP to read the data with proper swaps
Together with other endianity patches, this change fixies perf report
discrepancies on origin and target systems as described in test 1 below,
e.g. following perf report diff:
...
0.12% ps [kernel.kallsyms] [k] clear_page
- 0.12% awk bash [.] alloc_word_desc
+ 0.12% awk bash [.] yyparse
0.11% beah-rhts-task libpython2.6.so.1.0 [.] 0x5560e
0.10% perf libc-2.12.so [.] __ctype_toupper_loc
- 0.09% rhts-test-runne bash [.] maybe_make_export_env
+ 0.09% rhts-test-runne bash [.] 0x385a0
0.09% ps [kernel.kallsyms] [k] page_fault
...
Note, running following to test perf endianity handling:
test 1)
- origin system:
# perf record -a -- sleep 10 (any perf record will do)
# perf report > report.origin
# perf archive perf.data
- copy the perf.data, report.origin and perf.data.tar.bz2
to a target system and run:
# tar xjvf perf.data.tar.bz2 -C ~/.debug
# perf report > report.target
# diff -u report.origin report.target
- the diff should produce no output
(besides some white space stuff and possibly different
date/TZ output)
test 1)
- origin system:
# perf record -ag -fo /tmp/perf.data -- sleep 1
- mount origin system root to the target system on /mnt/origin
- target system:
# perf script --symfs /mnt/origin -I -i /mnt/origin/tmp/perf.data \
--kallsyms /mnt/origin/proc/kallsyms
- complete perf.data header is displayed
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1338380624-7443-2-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/symbol.h')
-rw-r--r-- | tools/perf/util/symbol.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 5649d63798cb..af0752b1aca1 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/list.h> | 9 | #include <linux/list.h> |
10 | #include <linux/rbtree.h> | 10 | #include <linux/rbtree.h> |
11 | #include <stdio.h> | 11 | #include <stdio.h> |
12 | #include <byteswap.h> | ||
12 | 13 | ||
13 | #ifdef HAVE_CPLUS_DEMANGLE | 14 | #ifdef HAVE_CPLUS_DEMANGLE |
14 | extern char *cplus_demangle(const char *, int); | 15 | extern char *cplus_demangle(const char *, int); |
@@ -160,11 +161,18 @@ enum dso_kernel_type { | |||
160 | DSO_TYPE_GUEST_KERNEL | 161 | DSO_TYPE_GUEST_KERNEL |
161 | }; | 162 | }; |
162 | 163 | ||
164 | enum dso_swap_type { | ||
165 | DSO_SWAP__UNSET, | ||
166 | DSO_SWAP__NO, | ||
167 | DSO_SWAP__YES, | ||
168 | }; | ||
169 | |||
163 | struct dso { | 170 | struct dso { |
164 | struct list_head node; | 171 | struct list_head node; |
165 | struct rb_root symbols[MAP__NR_TYPES]; | 172 | struct rb_root symbols[MAP__NR_TYPES]; |
166 | struct rb_root symbol_names[MAP__NR_TYPES]; | 173 | struct rb_root symbol_names[MAP__NR_TYPES]; |
167 | enum dso_kernel_type kernel; | 174 | enum dso_kernel_type kernel; |
175 | enum dso_swap_type needs_swap; | ||
168 | u8 adjust_symbols:1; | 176 | u8 adjust_symbols:1; |
169 | u8 has_build_id:1; | 177 | u8 has_build_id:1; |
170 | u8 hit:1; | 178 | u8 hit:1; |
@@ -182,6 +190,28 @@ struct dso { | |||
182 | char name[0]; | 190 | char name[0]; |
183 | }; | 191 | }; |
184 | 192 | ||
193 | #define DSO__SWAP(dso, type, val) \ | ||
194 | ({ \ | ||
195 | type ____r = val; \ | ||
196 | BUG_ON(dso->needs_swap == DSO_SWAP__UNSET); \ | ||
197 | if (dso->needs_swap == DSO_SWAP__YES) { \ | ||
198 | switch (sizeof(____r)) { \ | ||
199 | case 2: \ | ||
200 | ____r = bswap_16(val); \ | ||
201 | break; \ | ||
202 | case 4: \ | ||
203 | ____r = bswap_32(val); \ | ||
204 | break; \ | ||
205 | case 8: \ | ||
206 | ____r = bswap_64(val); \ | ||
207 | break; \ | ||
208 | default: \ | ||
209 | BUG_ON(1); \ | ||
210 | } \ | ||
211 | } \ | ||
212 | ____r; \ | ||
213 | }) | ||
214 | |||
185 | struct dso *dso__new(const char *name); | 215 | struct dso *dso__new(const char *name); |
186 | void dso__delete(struct dso *dso); | 216 | void dso__delete(struct dso *dso); |
187 | 217 | ||