aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-04-19 09:57:06 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-04-19 09:57:06 -0400
commit1b2e2df4e395293e65dbda49e58cb4c7abeb7507 (patch)
tree86c1fbbe6da27fee35bcaf676359f24c481fdc13 /tools/perf/util
parent887c0066a810234cfae9927b3781b6a1c617fb39 (diff)
perf symbols: Introduce symbol__size method
Fixing some off by one cases in the process. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-fxumzufhk829z0q9anmvemea@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/annotate.c10
-rw-r--r--tools/perf/util/symbol.h5
2 files changed, 10 insertions, 5 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ed1f89d7044e..d8e2f414e610 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -101,7 +101,7 @@ int symbol__annotate_init(struct map *map __used, struct symbol *sym)
101int symbol__alloc_hist(struct symbol *sym) 101int symbol__alloc_hist(struct symbol *sym)
102{ 102{
103 struct annotation *notes = symbol__annotation(sym); 103 struct annotation *notes = symbol__annotation(sym);
104 const size_t size = sym->end - sym->start + 1; 104 const size_t size = symbol__size(sym);
105 size_t sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64)); 105 size_t sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64));
106 106
107 notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist); 107 notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist);
@@ -609,7 +609,7 @@ static void symbol__annotate_hits(struct symbol *sym, int evidx)
609{ 609{
610 struct annotation *notes = symbol__annotation(sym); 610 struct annotation *notes = symbol__annotation(sym);
611 struct sym_hist *h = annotation__histogram(notes, evidx); 611 struct sym_hist *h = annotation__histogram(notes, evidx);
612 u64 len = sym->end - sym->start, offset; 612 u64 len = symbol__size(sym), offset;
613 613
614 for (offset = 0; offset < len; ++offset) 614 for (offset = 0; offset < len; ++offset)
615 if (h->addr[offset] != 0) 615 if (h->addr[offset] != 0)
@@ -636,7 +636,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
636 else 636 else
637 d_filename = basename(filename); 637 d_filename = basename(filename);
638 638
639 len = sym->end - sym->start; 639 len = symbol__size(sym);
640 640
641 printf(" Percent | Source code & Disassembly of %s\n", d_filename); 641 printf(" Percent | Source code & Disassembly of %s\n", d_filename);
642 printf("------------------------------------------------\n"); 642 printf("------------------------------------------------\n");
@@ -696,7 +696,7 @@ void symbol__annotate_decay_histogram(struct symbol *sym, int evidx)
696{ 696{
697 struct annotation *notes = symbol__annotation(sym); 697 struct annotation *notes = symbol__annotation(sym);
698 struct sym_hist *h = annotation__histogram(notes, evidx); 698 struct sym_hist *h = annotation__histogram(notes, evidx);
699 int len = sym->end - sym->start, offset; 699 int len = symbol__size(sym), offset;
700 700
701 h->sum = 0; 701 h->sum = 0;
702 for (offset = 0; offset < len; ++offset) { 702 for (offset = 0; offset < len; ++offset) {
@@ -755,7 +755,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
755 if (symbol__annotate(sym, map, 0) < 0) 755 if (symbol__annotate(sym, map, 0) < 0)
756 return -1; 756 return -1;
757 757
758 len = sym->end - sym->start; 758 len = symbol__size(sym);
759 759
760 if (print_lines) { 760 if (print_lines) {
761 symbol__get_source_line(sym, map, evidx, &source_line, 761 symbol__get_source_line(sym, map, evidx, &source_line,
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index ac49ef208a5f..1f003884f1ab 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -65,6 +65,11 @@ struct symbol {
65 65
66void symbol__delete(struct symbol *sym); 66void symbol__delete(struct symbol *sym);
67 67
68static inline size_t symbol__size(const struct symbol *sym)
69{
70 return sym->end - sym->start + 1;
71}
72
68struct strlist; 73struct strlist;
69 74
70struct symbol_conf { 75struct symbol_conf {