]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
perf annotate: Use perf_env when obtaining the arch name
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 11 Dec 2017 15:52:17 +0000 (12:52 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 27 Dec 2017 15:15:51 +0000 (12:15 -0300)
Paving the way to reuse these routines in other areas, like when
generating errno tables.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-rh1qv051vb8gfdcswskrn53h@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/annotate.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h

index bc34b28373f499d960260c0bd1d58c9e0479ba88..eac45ccd5c322ac287de624124a392587b1269e4 100644 (file)
@@ -1420,16 +1420,19 @@ fallback:
        return 0;
 }
 
-static const char *annotate__norm_arch(const char *arch_name)
+static const char *perf_env__arch(struct perf_env *env)
 {
        struct utsname uts;
+       char *arch_name;
 
-       if (!arch_name) { /* Assume we are annotating locally. */
+       if (!env) { /* Assume local operation */
                if (uname(&uts) < 0)
                        return NULL;
                arch_name = uts.machine;
-       }
-       return normalize_arch((char *)arch_name);
+       } else
+               arch_name = env->arch;
+
+       return normalize_arch(arch_name);
 }
 
 static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
@@ -1630,14 +1633,10 @@ int symbol__annotate(struct symbol *sym, struct map *map,
                .evsel          = evsel,
        };
        struct perf_env *env = perf_evsel__env(evsel);
-       const char *arch_name = NULL;
+       const char *arch_name = perf_env__arch(env);
        struct arch *arch;
        int err;
 
-       if (evsel)
-               arch_name = perf_evsel__env_arch(evsel);
-
-       arch_name = annotate__norm_arch(arch_name);
        if (!arch_name)
                return -1;
 
index 541897049c6cdfec7ed106eed38accb89fe8ae93..4718f0a460df18231f4f35999b162174495a4c62 100644 (file)
@@ -2835,13 +2835,6 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
                         perf_evsel__name(evsel));
 }
 
-char *perf_evsel__env_arch(struct perf_evsel *evsel)
-{
-       if (evsel && evsel->evlist && evsel->evlist->env)
-               return evsel->evlist->env->arch;
-       return NULL;
-}
-
 struct perf_env *perf_evsel__env(struct perf_evsel *evsel)
 {
        if (evsel && evsel->evlist)
index 0e961ce60a9ccdb2ff8fd92b9d163acc2c8a8e56..846e416445254f6090a1280305106a6c581b715a 100644 (file)
@@ -446,7 +446,6 @@ typedef int (*attr__fprintf_f)(FILE *, const char *, const char *, void *);
 int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
                             attr__fprintf_f attr__fprintf, void *priv);
 
-char *perf_evsel__env_arch(struct perf_evsel *evsel);
 struct perf_env *perf_evsel__env(struct perf_evsel *evsel);
 
 #endif /* __PERF_EVSEL_H */