diff options
-rw-r--r-- | tools/perf/util/annotate.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index a91d7b186081..ae71325d3dc7 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -603,29 +603,28 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disa | |||
603 | return NULL; | 603 | return NULL; |
604 | } | 604 | } |
605 | 605 | ||
606 | static double disasm__calc_percent(struct disasm_line *next, | 606 | static double disasm__calc_percent(struct annotation *notes, int evidx, |
607 | struct annotation *notes, int evidx, | 607 | s64 offset, s64 end, const char **path) |
608 | s64 offset, u64 len, const char **path) | ||
609 | { | 608 | { |
610 | struct source_line *src_line = notes->src->lines; | 609 | struct source_line *src_line = notes->src->lines; |
611 | struct sym_hist *h = annotation__histogram(notes, evidx); | 610 | struct sym_hist *h = annotation__histogram(notes, evidx); |
612 | unsigned int hits = 0; | 611 | unsigned int hits = 0; |
613 | double percent = 0.0; | 612 | double percent = 0.0; |
614 | 613 | ||
615 | while (offset < (s64)len && | 614 | if (src_line) { |
616 | (next == NULL || offset < next->offset)) { | 615 | while (offset < end) { |
617 | if (src_line) { | ||
618 | if (*path == NULL) | 616 | if (*path == NULL) |
619 | *path = src_line[offset].path; | 617 | *path = src_line[offset].path; |
620 | percent += src_line[offset].percent; | ||
621 | } else | ||
622 | hits += h->addr[offset]; | ||
623 | 618 | ||
624 | ++offset; | 619 | percent += src_line[offset++].percent; |
625 | } | 620 | } |
621 | } else { | ||
622 | while (offset < end) | ||
623 | hits += h->addr[offset++]; | ||
626 | 624 | ||
627 | if (src_line == NULL && h->sum) | 625 | if (h->sum) |
628 | percent = 100.0 * hits / h->sum; | 626 | percent = 100.0 * hits / h->sum; |
627 | } | ||
629 | 628 | ||
630 | return percent; | 629 | return percent; |
631 | } | 630 | } |
@@ -648,8 +647,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
648 | 647 | ||
649 | next = disasm__get_next_ip_line(¬es->src->source, dl); | 648 | next = disasm__get_next_ip_line(¬es->src->source, dl); |
650 | 649 | ||
651 | percent = disasm__calc_percent(next, notes, evsel->idx, | 650 | percent = disasm__calc_percent(notes, evsel->idx, offset, |
652 | offset, len, &path); | 651 | next ? next->offset : (s64) len, |
652 | &path); | ||
653 | if (percent < min_pcnt) | 653 | if (percent < min_pcnt) |
654 | return -1; | 654 | return -1; |
655 | 655 | ||