diff options
author | Andi Kleen <ak@linux.intel.com> | 2015-05-27 13:51:46 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-05-27 19:30:56 -0400 |
commit | 83be34a7a913bdf9f21f524333c63d9c48a28ef4 (patch) | |
tree | b91e24977e5b62070bd291f512d667376007f612 /tools/perf/util/annotate.c | |
parent | 18ffdfe8e98f861a39590ef2374ad51fc963567e (diff) |
perf annotation: Add symbol__get_annotation
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>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r-- | tools/perf/util/annotate.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 7f5bdfc9bc87..bf8043009909 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -506,6 +506,17 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map, | |||
506 | return 0; | 506 | return 0; |
507 | } | 507 | } |
508 | 508 | ||
509 | static struct annotation *symbol__get_annotation(struct symbol *sym) | ||
510 | { | ||
511 | struct annotation *notes = symbol__annotation(sym); | ||
512 | |||
513 | if (notes->src == NULL) { | ||
514 | if (symbol__alloc_hist(sym) < 0) | ||
515 | return NULL; | ||
516 | } | ||
517 | return notes; | ||
518 | } | ||
519 | |||
509 | static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, | 520 | static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, |
510 | int evidx, u64 addr) | 521 | int evidx, u64 addr) |
511 | { | 522 | { |
@@ -513,13 +524,9 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, | |||
513 | 524 | ||
514 | if (sym == NULL) | 525 | if (sym == NULL) |
515 | return 0; | 526 | return 0; |
516 | 527 | notes = symbol__get_annotation(sym); | |
517 | notes = symbol__annotation(sym); | 528 | if (notes == NULL) |
518 | if (notes->src == NULL) { | 529 | return -ENOMEM; |
519 | if (symbol__alloc_hist(sym) < 0) | ||
520 | return -ENOMEM; | ||
521 | } | ||
522 | |||
523 | return __symbol__inc_addr_samples(sym, map, notes, evidx, addr); | 530 | return __symbol__inc_addr_samples(sym, map, notes, evidx, addr); |
524 | } | 531 | } |
525 | 532 | ||