perf probe: Warn unmatched function filter correctly
authorMasami Hiramatsu <mhiramat@kernel.org>
Mon, 18 Jul 2016 16:12:41 +0000 (01:12 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 18 Jul 2016 22:46:34 +0000 (19:46 -0300)
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-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146885835596.16106.2293540792775552481.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/map.c
tools/perf/util/probe-event.c

index b39b12a1208d4e997ac4eecf6fec61a21b014bbf..728129ac653a7e371fae4ebf13c67bd7e4d3de58 100644 (file)
@@ -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);
index d4f8835c0a279107ca428d77ffe19cba6f8bde48..953dc1ab2ed7bd0be442c4491c9c8a4862aa3386 100644 (file)
@@ -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))