aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFranck Bui-Huu <fbuihuu@gmail.com>2010-11-30 06:50:14 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-11-30 11:48:07 -0500
commit60e677373be9c0bf7c9a22937601d5a40e51c042 (patch)
treeab4a5af10366d0210b7715122cfa5ff307d26593 /tools
parentd214afbd81405d4da2c5745fe867e6b313fd4178 (diff)
perf header: Don't assume there's no attr info if no sample ids is provided
This primarily fixes perf-report, which didn't report the correct type of event if perf-record was called to record one event different from 'cycles': $ perf record -e instructions true [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.007 MB perf.data (~295 samples) ] $ perf report | head -n1 # Events: 7 cycles LPU-Reference: <m3mxor6nex.fsf@gmail.com> Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/header.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index d7e67b167ea3..64a85bafde63 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -946,11 +946,16 @@ perf_header__find_attr(u64 id, struct perf_header *header)
946 946
947 /* 947 /*
948 * We set id to -1 if the data file doesn't contain sample 948 * We set id to -1 if the data file doesn't contain sample
949 * ids. Check for this and avoid walking through the entire 949 * ids. This can happen when the data file contains one type
950 * list of ids which may be large. 950 * of event and in that case, the header can still store the
951 * event attribute information. Check for this and avoid
952 * walking through the entire list of ids which may be large.
951 */ 953 */
952 if (id == -1ULL) 954 if (id == -1ULL) {
955 if (header->attrs > 0)
956 return &header->attr[0]->attr;
953 return NULL; 957 return NULL;
958 }
954 959
955 for (i = 0; i < header->attrs; i++) { 960 for (i = 0; i < header->attrs; i++) {
956 struct perf_header_attr *attr = header->attr[i]; 961 struct perf_header_attr *attr = header->attr[i];