From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbcGRQM7 (ORCPT ); Mon, 18 Jul 2016 12:12:59 -0400 Received: from mail.kernel.org ([198.145.29.136]:34944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbcGRQM5 (ORCPT ); Mon, 18 Jul 2016 12:12:57 -0400 From: Masami Hiramatsu To: Arnaldo Carvalho de Melo Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org, Namhyung Kim , Peter Zijlstra , Ingo Molnar Subject: [PATCH] [BUGFIX] perf-probe: Warn unmatched function filter correctly Date: Tue, 19 Jul 2016 01:12:41 +0900 Message-Id: <146885835596.16106.2293540792775552481.stgit@devbox> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20160715131439.GE3021@kernel.org> References: <20160715131439.GE3021@kernel.org> In-Reply-To: <20160715131439.GE3021@kernel.org> References: <20160715131439.GE3021@kernel.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Warn unmatched function filter correctly instead of warning "symbol-loading error", since that can be a filter issue. >>From the technical point of view, this adds a filter chech in map__load and if there is a filter, it returns -2 (filter-out), instead of -1 (error), and perf-probe checks it and change message. E.g. without this fix: ---- # perf probe -F rt_sp* no symbols found in [kernel.kallsyms], maybe install a debug package? Failed to load symbols in kernel ---- With this fix: ---- # perf probe -F rt_sp* no symbols passed the given filter. Failed to find symbols matched to "rt_sp*" Error: Failed to show functions. ---- Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Masami Hiramatsu --- tools/perf/util/map.c | 3 +++ tools/perf/util/probe-event.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index b39b12a..728129a 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -312,6 +312,9 @@ int map__load(struct map *map, symbol_filter_t filter) pr_warning("%.*s was updated (is prelink enabled?). " "Restart the long running apps that use it!\n", (int)real_len, name); + } else if (filter) { + pr_warning("no symbols passed the given filter.\n"); + return -2; /* Empty but maybe by the filter */ } else { pr_warning("no symbols found in %s, maybe install " "a debug package?\n", name); diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index d4f8835..953dc1a 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -3312,8 +3312,16 @@ int show_available_funcs(const char *target, struct strfilter *_filter, /* Load symbols with given filter */ available_func_filter = _filter; - if (map__load(map, filter_available_functions)) { - pr_err("Failed to load symbols in %s\n", (target) ? : "kernel"); + ret = map__load(map, filter_available_functions); + if (ret) { + if (ret == -2) { + char *str = strfilter__string(_filter); + pr_err("Failed to find symbols matched to \"%s\"\n", + str); + free(str); + } else + pr_err("Failed to load symbols in %s\n", + (target) ? : "kernel"); goto end; } if (!dso__sorted_by_name(map->dso, map->type))