Skip to content

Commit

Permalink
perf annotate: Fix off by one symbol hist size allocation and hit acc…
Browse files Browse the repository at this point in the history
…ounting

We were not noticing it because symbol__inc_addr_samples was erroneously
dropping samples that hit the last byte in a function.

Working on a fix for a problem reported by David Miller, Stephane
Eranian and Sorin Dumitru, where addresses < sym->start were causing
problems, I noticed this other problem.

Cc: David Ahern <[email protected]>
Cc: David Miller <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Sorin Dumitru <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Mar 29, 2012
1 parent cc96aa7 commit 64c17be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ int symbol__annotate_init(struct map *map __used, struct symbol *sym)
int symbol__alloc_hist(struct symbol *sym)
{
struct annotation *notes = symbol__annotation(sym);
size_t sizeof_sym_hist = (sizeof(struct sym_hist) +
(sym->end - sym->start) * sizeof(u64));
const size_t size = sym->end - sym->start + 1;
size_t sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64));

notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist);
if (notes->src == NULL)
Expand Down Expand Up @@ -64,7 +64,7 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,

pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));

if (addr >= sym->end)
if (addr > sym->end)
return 0;

offset = addr - sym->start;
Expand Down

0 comments on commit 64c17be

Please sign in to comment.