From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934913AbcI2SPO (ORCPT ); Thu, 29 Sep 2016 14:15:14 -0400 Received: from terminus.zytor.com ([198.137.202.10]:51892 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934894AbcI2SPC (ORCPT ); Thu, 29 Sep 2016 14:15:02 -0400 Date: Thu, 29 Sep 2016 11:14:54 -0700 From: tip-bot for Adrian Hunter Message-ID: Cc: jolsa@redhat.com, hpa@zytor.com, adrian.hunter@intel.com, mingo@kernel.org, mathieu.poirier@linaro.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, mhiramat@kernel.org, acme@redhat.com Reply-To: acme@redhat.com, mhiramat@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mathieu.poirier@linaro.org, mingo@kernel.org, adrian.hunter@intel.com, hpa@zytor.com, jolsa@redhat.com In-Reply-To: <1474641528-18776-7-git-send-email-adrian.hunter@intel.com> References: <1474641528-18776-7-git-send-email-adrian.hunter@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf symbols: Add dso__last_symbol() Git-Commit-ID: cd67f99fe90dcf515f1c70c474b84d56b6236cbb 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: cd67f99fe90dcf515f1c70c474b84d56b6236cbb Gitweb: http://git.kernel.org/tip/cd67f99fe90dcf515f1c70c474b84d56b6236cbb Author: Adrian Hunter AuthorDate: Fri, 23 Sep 2016 17:38:38 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 29 Sep 2016 11:17:01 -0300 perf symbols: Add dso__last_symbol() Add a function to find the last symbol in a DSO. This will be used when parsing address filters to calculate a region that includes the entire DSO. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Mathieu Poirier Link: http://lkml.kernel.org/r/1474641528-18776-7-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 15 +++++++++++++++ tools/perf/util/symbol.h | 1 + 2 files changed, 16 insertions(+) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 19c9c55..aecff69 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -345,6 +345,16 @@ static struct symbol *symbols__first(struct rb_root *symbols) return NULL; } +static struct symbol *symbols__last(struct rb_root *symbols) +{ + struct rb_node *n = rb_last(symbols); + + if (n) + return rb_entry(n, struct symbol, rb_node); + + return NULL; +} + static struct symbol *symbols__next(struct symbol *sym) { struct rb_node *n = rb_next(&sym->rb_node); @@ -466,6 +476,11 @@ struct symbol *dso__first_symbol(struct dso *dso, enum map_type type) return symbols__first(&dso->symbols[type]); } +struct symbol *dso__last_symbol(struct dso *dso, enum map_type type) +{ + return symbols__last(&dso->symbols[type]); +} + struct symbol *dso__next_symbol(struct symbol *sym) { return symbols__next(sym); diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 0dacfb7..d964844 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -259,6 +259,7 @@ struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, struct symbol *symbol__next_by_name(struct symbol *sym); struct symbol *dso__first_symbol(struct dso *dso, enum map_type type); +struct symbol *dso__last_symbol(struct dso *dso, enum map_type type); struct symbol *dso__next_symbol(struct symbol *sym); enum dso_type dso__type_fd(int fd);