summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2011-07-15 12:34:09 -0600
committerIngo Molnar <mingo@elte.hu>2011-07-21 09:57:36 +0200
commiteda3913bb70ecebac13adccffe1e7f96e93cee02 (patch)
tree832f84f625dcfcf30eeb0ca88d58fe7774f4327e /tools/perf/util/header.c
parent0111919da268e1ced315e009ad0d0435a2fb32ac (diff)
downloadlinux-stable-eda3913bb70ecebac13adccffe1e7f96e93cee02.tar.gz
linux-stable-eda3913bb70ecebac13adccffe1e7f96e93cee02.tar.bz2
linux-stable-eda3913bb70ecebac13adccffe1e7f96e93cee02.zip
perf tools: Fix endian conversion reading event attr from file header
The perf_event_attr struct has two __u32's at the top and they need to be swapped individually. With this change I was able to analyze a perf.data collected in a 32-bit PPC VM on an x86 system. I tested both 32-bit and 64-bit binaries for the Intel analysis side; both read the PPC perf.data file correctly. -v2: - changed the existing perf_event__attr_swap() to swap only elements of perf_event_attr and exported it for use in swapping the attributes in the file header - updated swap_ops used for processing events Signed-off-by: David Ahern <dsahern@gmail.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: acme@ghostprotocols.net Cc: peterz@infradead.org Cc: paulus@samba.org Cc: <stable@kernel.org> Link: http://lkml.kernel.org/r/1310754849-12474-1-git-send-email-dsahern@gmail.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index afb0849fe530..cb2959a3fb43 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -877,9 +877,12 @@ int perf_session__read_header(struct perf_session *session, int fd)
struct perf_evsel *evsel;
off_t tmp;
- if (perf_header__getbuffer64(header, fd, &f_attr, sizeof(f_attr)))
+ if (readn(fd, &f_attr, sizeof(f_attr)) <= 0)
goto out_errno;
+ if (header->needs_swap)
+ perf_event__attr_swap(&f_attr.attr);
+
tmp = lseek(fd, 0, SEEK_CUR);
evsel = perf_evsel__new(&f_attr.attr, i);