perf map: Shorten map_groups__find_by_name() signature
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 24 Apr 2018 15:16:09 +0000 (12:16 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 26 Apr 2018 16:47:09 +0000 (13:47 -0300)
Another step in the road to elliminate the MAP_{FUNCTION,VARIABLE}
separation, reducing the exposure to these details in the tools using
the symbol APIs.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-8a1hvrqe3r5i0kw865u3uxwt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/vmlinux-kallsyms.c
tools/perf/util/machine.c
tools/perf/util/map.h
tools/perf/util/probe-event.c
tools/perf/util/symbol-elf.c
tools/perf/util/symbol.c

index 1e5adb65632a8def52a4c329e66df0e1b9d05ba1..d80416e07f4bf15c471d8e1a965d4bdad3e1f5f8 100644 (file)
@@ -183,7 +183,7 @@ next_pair:
                 * so use the short name, less descriptive but the same ("[kernel]" in
                 * both cases.
                 */
-               pair = map_groups__find_by_name(&kallsyms.kmaps, type,
+               pair = map_groups__find_by_name(&kallsyms.kmaps,
                                                (map->dso->kernel ?
                                                        map->dso->short_name :
                                                        map->dso->name));
index e354d94a68e85ee33d31644f84ecc755de89de8c..fc71f2c69c8b5d1fc8596d8bee2166daf46a8933 100644 (file)
@@ -673,8 +673,7 @@ struct map *machine__findnew_module_map(struct machine *machine, u64 start,
        if (kmod_path__parse_name(&m, filename))
                return NULL;
 
-       map = map_groups__find_by_name(&machine->kmaps, MAP__FUNCTION,
-                                      m.name);
+       map = map_groups__find_by_name(&machine->kmaps, m.name);
        if (map) {
                /*
                 * If the map's dso is an offline module, give dso__load()
@@ -1055,10 +1054,9 @@ static bool is_kmod_dso(struct dso *dso)
 static int map_groups__set_module_path(struct map_groups *mg, const char *path,
                                       struct kmod_path *m)
 {
-       struct map *map;
        char *long_name;
+       struct map *map = map_groups__find_by_name(mg, m->name);
 
-       map = map_groups__find_by_name(mg, MAP__FUNCTION, m->name);
        if (map == NULL)
                return 0;
 
index fc91bac8fed083e5dbf597d5bef2740e88dba64a..8ff75be0a96554f8f1dc0f2073dac69ecb8d503b 100644 (file)
@@ -254,8 +254,12 @@ struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
 int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
                                   FILE *fp);
 
-struct map *map_groups__find_by_name(struct map_groups *mg,
-                                    enum map_type type, const char *name);
+struct map *__map_groups__find_by_name(struct map_groups *mg, enum map_type type, const char *name);
+
+static inline struct map *map_groups__find_by_name(struct map_groups *mg, const char *name)
+{
+       return __map_groups__find_by_name(mg, MAP__FUNCTION, name);
+}
 
 bool __map__is_kernel(const struct map *map);
 
index e1dbc9821617025c04086bae0cfdeaf3f3a7f025..d5e2516d59818b6a913e31cdfdc8d4b900046aa2 100644 (file)
@@ -341,7 +341,7 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso)
                char module_name[128];
 
                snprintf(module_name, sizeof(module_name), "[%s]", module);
-               map = map_groups__find_by_name(&host_machine->kmaps, MAP__FUNCTION, module_name);
+               map = map_groups__find_by_name(&host_machine->kmaps, module_name);
                if (map) {
                        dso = map->dso;
                        goto found;
index 2de770511e705dbc8caa7a69f1398548f102720d..75f578f3ed8efc7b34c8c36f7b6ce648882b08b3 100644 (file)
@@ -1042,7 +1042,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
                        snprintf(dso_name, sizeof(dso_name),
                                 "%s%s", dso->short_name, section_name);
 
-                       curr_map = map_groups__find_by_name(kmaps, map->type, dso_name);
+                       curr_map = __map_groups__find_by_name(kmaps, map->type, dso_name);
                        if (curr_map == NULL) {
                                u64 start = sym.st_value;
 
index 2b6292cff7192489762a276ed2fb1c29b12075c5..0bf4cf76f36a7488c611fc358559ca074e46d998 100644 (file)
@@ -792,8 +792,7 @@ static int dso__split_kallsyms(struct dso *dso, struct map *map, u64 delta)
                                                        curr_map->type);
                                }
 
-                               curr_map = map_groups__find_by_name(kmaps,
-                                                       map->type, module);
+                               curr_map = __map_groups__find_by_name(kmaps, map->type, module);
                                if (curr_map == NULL) {
                                        pr_debug("%s/proc/{kallsyms,modules} "
                                                 "inconsistency while looking "
@@ -1667,8 +1666,7 @@ out:
        return ret;
 }
 
-struct map *map_groups__find_by_name(struct map_groups *mg,
-                                    enum map_type type, const char *name)
+struct map *__map_groups__find_by_name(struct map_groups *mg, enum map_type type, const char *name)
 {
        struct maps *maps = &mg->maps[type];
        struct map *map;