Skip to contentSkip to conversation

perf annotate: Check if offset is less than symbol size

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Feb 17, 2011 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  289c082044643e55f65c6a16bb3621cf3f35a454
Gitweb:     http://git.kernel.org/tip/289c082044643e55f65c6a16bb3621cf3f35a454
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 9 Feb 2011 13:56:28 -0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 16 Feb 2011 14:47:55 -0200

perf annotate: Check if offset is less than symbol size

Just like done on symbol__inc_addr_samples to catch misparsed offsets from objdump.

Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Tom Zanussi <[email protected]>
LKML-Reference: <new-submission>

---
 tools/perf/util/annotate.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/util/annotate.c +2 -1
index 02976b8..70ec422 100644
@@ -541,11 +541,12 @@ void symbol__annotate_decay_histogram(struct symbol *sym, int evidx)
 	struct annotation *notes = symbol__annotation(sym);
 	struct sym_hist *h = annotation__histogram(notes, evidx);
 	struct objdump_line *pos;
+	int len = sym->end - sym->start;
 
 	h->sum = 0;
 
 	list_for_each_entry(pos, &notes->src->source, node) {
-		if (pos->offset != -1) {
+		if (pos->offset != -1 && pos->offset < len) {
 			h->addr[pos->offset] = h->addr[pos->offset] * 7 / 8;
 			h->sum += h->addr[pos->offset];
 		}