diff options
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 07c8f3792954..a5e2015319ee 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -1942,7 +1942,6 @@ int perf_file_header__read(struct perf_file_header *header, | |||
1942 | else | 1942 | else |
1943 | return -1; | 1943 | return -1; |
1944 | } else if (ph->needs_swap) { | 1944 | } else if (ph->needs_swap) { |
1945 | unsigned int i; | ||
1946 | /* | 1945 | /* |
1947 | * feature bitmap is declared as an array of unsigned longs -- | 1946 | * feature bitmap is declared as an array of unsigned longs -- |
1948 | * not good since its size can differ between the host that | 1947 | * not good since its size can differ between the host that |
@@ -1958,14 +1957,17 @@ int perf_file_header__read(struct perf_file_header *header, | |||
1958 | * file), punt and fallback to the original behavior -- | 1957 | * file), punt and fallback to the original behavior -- |
1959 | * clearing all feature bits and setting buildid. | 1958 | * clearing all feature bits and setting buildid. |
1960 | */ | 1959 | */ |
1961 | for (i = 0; i < BITS_TO_LONGS(HEADER_FEAT_BITS); ++i) | 1960 | mem_bswap_64(&header->adds_features, |
1962 | header->adds_features[i] = bswap_64(header->adds_features[i]); | 1961 | BITS_TO_U64(HEADER_FEAT_BITS)); |
1963 | 1962 | ||
1964 | if (!test_bit(HEADER_HOSTNAME, header->adds_features)) { | 1963 | if (!test_bit(HEADER_HOSTNAME, header->adds_features)) { |
1965 | for (i = 0; i < BITS_TO_LONGS(HEADER_FEAT_BITS); ++i) { | 1964 | /* unswap as u64 */ |
1966 | header->adds_features[i] = bswap_64(header->adds_features[i]); | 1965 | mem_bswap_64(&header->adds_features, |
1967 | header->adds_features[i] = bswap_32(header->adds_features[i]); | 1966 | BITS_TO_U64(HEADER_FEAT_BITS)); |
1968 | } | 1967 | |
1968 | /* unswap as u32 */ | ||
1969 | mem_bswap_32(&header->adds_features, | ||
1970 | BITS_TO_U32(HEADER_FEAT_BITS)); | ||
1969 | } | 1971 | } |
1970 | 1972 | ||
1971 | if (!test_bit(HEADER_HOSTNAME, header->adds_features)) { | 1973 | if (!test_bit(HEADER_HOSTNAME, header->adds_features)) { |
@@ -2091,6 +2093,35 @@ static int read_attr(int fd, struct perf_header *ph, | |||
2091 | return ret <= 0 ? -1 : 0; | 2093 | return ret <= 0 ? -1 : 0; |
2092 | } | 2094 | } |
2093 | 2095 | ||
2096 | static int perf_evsel__set_tracepoint_name(struct perf_evsel *evsel) | ||
2097 | { | ||
2098 | struct event_format *event = trace_find_event(evsel->attr.config); | ||
2099 | char bf[128]; | ||
2100 | |||
2101 | if (event == NULL) | ||
2102 | return -1; | ||
2103 | |||
2104 | snprintf(bf, sizeof(bf), "%s:%s", event->system, event->name); | ||
2105 | evsel->name = strdup(bf); | ||
2106 | if (event->name == NULL) | ||
2107 | return -1; | ||
2108 | |||
2109 | return 0; | ||
2110 | } | ||
2111 | |||
2112 | static int perf_evlist__set_tracepoint_names(struct perf_evlist *evlist) | ||
2113 | { | ||
2114 | struct perf_evsel *pos; | ||
2115 | |||
2116 | list_for_each_entry(pos, &evlist->entries, node) { | ||
2117 | if (pos->attr.type == PERF_TYPE_TRACEPOINT && | ||
2118 | perf_evsel__set_tracepoint_name(pos)) | ||
2119 | return -1; | ||
2120 | } | ||
2121 | |||
2122 | return 0; | ||
2123 | } | ||
2124 | |||
2094 | int perf_session__read_header(struct perf_session *session, int fd) | 2125 | int perf_session__read_header(struct perf_session *session, int fd) |
2095 | { | 2126 | { |
2096 | struct perf_header *header = &session->header; | 2127 | struct perf_header *header = &session->header; |
@@ -2172,6 +2203,9 @@ int perf_session__read_header(struct perf_session *session, int fd) | |||
2172 | 2203 | ||
2173 | lseek(fd, header->data_offset, SEEK_SET); | 2204 | lseek(fd, header->data_offset, SEEK_SET); |
2174 | 2205 | ||
2206 | if (perf_evlist__set_tracepoint_names(session->evlist)) | ||
2207 | goto out_delete_evlist; | ||
2208 | |||
2175 | header->frozen = 1; | 2209 | header->frozen = 1; |
2176 | return 0; | 2210 | return 0; |
2177 | out_errno: | 2211 | out_errno: |