diff options
author | Jiri Olsa <jolsa@redhat.com> | 2013-07-17 13:49:47 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-07-17 16:04:00 -0400 |
commit | 2a08c3ec4f7d6058a450d2d4bc6e366955872707 (patch) | |
tree | ffcd2c8c95e67260993ab8b7f4e96419adc7bcf8 | |
parent | 8d541e974f4b3ed5db7e278b4d64481af34910a9 (diff) |
perf header: Recognize version number for perf data file
Keep the recognized data file version within 'struct perf_header'.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.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: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1374083403-14591-8-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/header.c | 2 | ||||
-rw-r--r-- | tools/perf/util/header.h | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index eefb052190f3..f558f83769af 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -2480,6 +2480,7 @@ static int check_magic_endian(u64 magic, uint64_t hdr_sz, | |||
2480 | /* check for legacy format */ | 2480 | /* check for legacy format */ |
2481 | ret = memcmp(&magic, __perf_magic1, sizeof(magic)); | 2481 | ret = memcmp(&magic, __perf_magic1, sizeof(magic)); |
2482 | if (ret == 0) { | 2482 | if (ret == 0) { |
2483 | ph->version = PERF_HEADER_VERSION_1; | ||
2483 | pr_debug("legacy perf.data format\n"); | 2484 | pr_debug("legacy perf.data format\n"); |
2484 | if (is_pipe) | 2485 | if (is_pipe) |
2485 | return try_all_pipe_abis(hdr_sz, ph); | 2486 | return try_all_pipe_abis(hdr_sz, ph); |
@@ -2501,6 +2502,7 @@ static int check_magic_endian(u64 magic, uint64_t hdr_sz, | |||
2501 | return -1; | 2502 | return -1; |
2502 | 2503 | ||
2503 | ph->needs_swap = true; | 2504 | ph->needs_swap = true; |
2505 | ph->version = PERF_HEADER_VERSION_2; | ||
2504 | 2506 | ||
2505 | return 0; | 2507 | return 0; |
2506 | } | 2508 | } |
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index e6387dcb95c0..307c9aed972e 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h | |||
@@ -34,6 +34,11 @@ enum { | |||
34 | HEADER_FEAT_BITS = 256, | 34 | HEADER_FEAT_BITS = 256, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | enum perf_header_version { | ||
38 | PERF_HEADER_VERSION_1, | ||
39 | PERF_HEADER_VERSION_2, | ||
40 | }; | ||
41 | |||
37 | struct perf_file_section { | 42 | struct perf_file_section { |
38 | u64 offset; | 43 | u64 offset; |
39 | u64 size; | 44 | u64 size; |
@@ -85,12 +90,13 @@ struct perf_session_env { | |||
85 | }; | 90 | }; |
86 | 91 | ||
87 | struct perf_header { | 92 | struct perf_header { |
88 | bool needs_swap; | 93 | enum perf_header_version version; |
89 | u64 data_offset; | 94 | bool needs_swap; |
90 | u64 data_size; | 95 | u64 data_offset; |
91 | u64 feat_offset; | 96 | u64 data_size; |
97 | u64 feat_offset; | ||
92 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); | 98 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); |
93 | struct perf_session_env env; | 99 | struct perf_session_env env; |
94 | }; | 100 | }; |
95 | 101 | ||
96 | struct perf_evlist; | 102 | struct perf_evlist; |