Skip to content

Commit

Permalink
perf annotation: Add symbol__get_annotation
Browse files Browse the repository at this point in the history
Add a new utility function to get an function annotation out of existing
code.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1432749114-904-4-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Andi Kleen authored and Arnaldo Carvalho de Melo committed May 27, 2015
1 parent 18ffdfe commit 83be34a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,20 +506,27 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
return 0;
}

static struct annotation *symbol__get_annotation(struct symbol *sym)
{
struct annotation *notes = symbol__annotation(sym);

if (notes->src == NULL) {
if (symbol__alloc_hist(sym) < 0)
return NULL;
}
return notes;
}

static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
int evidx, u64 addr)
{
struct annotation *notes;

if (sym == NULL)
return 0;

notes = symbol__annotation(sym);
if (notes->src == NULL) {
if (symbol__alloc_hist(sym) < 0)
return -ENOMEM;
}

notes = symbol__get_annotation(sym);
if (notes == NULL)
return -ENOMEM;
return __symbol__inc_addr_samples(sym, map, notes, evidx, addr);
}

Expand Down

0 comments on commit 83be34a

Please sign in to comment.