Skip to contentSkip to conversation

perf annotate: Fix storing per line sym_hist_entry

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jul 30, 2017 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  48cc33085253d607706e68a67ac98fe2a6abdd3d
Gitweb:     http://git.kernel.org/tip/48cc33085253d607706e68a67ac98fe2a6abdd3d
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Fri, 28 Jul 2017 12:49:02 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 28 Jul 2017 12:53:05 -0300

perf annotate: Fix storing per line sym_hist_entry

The existing loop incremented the offset while using it as the array index, when we went to an array of sym_hist_entry instances, we should've moved the increment to outside of the array element reference, oops, fix it.

Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Taeung Song <[email protected]>
Cc Wang Nan <[email protected]>
Fixes 461c17f00f40 ("perf annotate: Store the sample period in each histogram bucket")
---
 tools/perf/util/annotate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/annotate.c +3 -2
index 5125c2b..2dab0e5 100644
@@ -963,8 +963,9 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
 		u64 period = 0;
 
 		while (offset < end) {
-			hits += h->addr[offset++].nr_samples;
-			period += h->addr[offset++].period;
+			hits   += h->addr[offset].nr_samples;
+			period += h->addr[offset].period;
+			++offset;
 		}
 
 		if (h->nr_samples) {