From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751844AbbE1Jd5 (ORCPT ); Thu, 28 May 2015 05:33:57 -0400 Received: from terminus.zytor.com ([198.137.202.10]:46812 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753895AbbE1Jc3 (ORCPT ); Thu, 28 May 2015 05:32:29 -0400 Date: Thu, 28 May 2015 02:32:14 -0700 From: tip-bot for Andi Kleen Message-ID: Cc: eranian@google.com, tglx@linutronix.de, namhyung@kernel.org, mingo@kernel.org, jolsa@redhat.com, acme@redhat.com, ak@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org Reply-To: tglx@linutronix.de, namhyung@kernel.org, eranian@google.com, mingo@kernel.org, acme@redhat.com, jolsa@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, ak@linux.intel.com In-Reply-To: <1432749114-904-4-git-send-email-andi@firstfloor.org> References: <1432749114-904-4-git-send-email-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf annotation: Add symbol__get_annotation Git-Commit-ID: 83be34a7a913bdf9f21f524333c63d9c48a28ef4 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 83be34a7a913bdf9f21f524333c63d9c48a28ef4 Gitweb: http://git.kernel.org/tip/83be34a7a913bdf9f21f524333c63d9c48a28ef4 Author: Andi Kleen AuthorDate: Wed, 27 May 2015 10:51:46 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 27 May 2015 20:30:56 -0300 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 Cc: Jiri Olsa Cc: Namhyung Kim Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1432749114-904-4-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 7f5bdfc..bf80430 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, 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) { @@ -513,13 +524,9 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, 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); }