summaryrefslogtreecommitdiff
path: root/tools/perf/arch/common.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-11-13 19:05:09 +0100
committerIngo Molnar <mingo@kernel.org>2012-11-13 19:13:41 +0100
commitccf59d8da119ab03dcbdf95fb5e5adcef6ba51f2 (patch)
treed390f9230edac3d9c42a8ad8b030182890b6e609 /tools/perf/arch/common.c
parent95d18aa2b6c05351181934b3bc34ce038cc7b637 (diff)
parent27f94d52394003d444a383eaf8d4824daf32432e (diff)
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: * Don't show scripts menu for 'perf top', fix from Feng Tang * Add framework for automated perf_event_attr tests, where tools with different command line options will be run from a 'perf test', via python glue, and the perf syscall will be intercepted to verify that the perf_event_attr fields set by the tool are those expected, from Jiri Olsa * Use normalized arch name for searching objdump path. This fixes cases where the system's objdump (e.g. x86_64) supports the architecture in the perf.data file (e.g. i686), but is not the same, fix from Namhyung Kim. * Postpone objdump check until annotation requested, from Namhyung Kim. * Add a 'link' method for hists, so that we can have the leader with buckets for all the entries in all the hists. This new method is now used in the default 'diff' output, making the sum of the 'baseline' column be 100%, eliminating blind spots. Now we need to use this for 'diff' with > 2 perf.data files and for multi event 'report' and 'annotate'. * libtraceevent fixes for compiler warnings trying to make perf it build on some distros, like fedora 14, 32-bit, some of the warnings really pointed to real bugs. * Remove temp dir on failure in 'perf test', fix from Jiri Olsa. * Fixes for handling data, stack mmaps, from Namhyung Kim. * Fix live annotation bug related to recent objdump lookup patches, from Namhyung Kim * Don't try to follow jump target on PLT symbols in the annotation browser, fix from Namhyung Kim. * Fix leak on hist_entry delete, from Namhyung Kim. * Fix a CPU_ALLOC related build error on builtin-test, from Zheng Liu. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/arch/common.c')
-rw-r--r--tools/perf/arch/common.c47
1 files changed, 40 insertions, 7 deletions
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index 2367b253f039..3e975cb6232e 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -93,16 +93,46 @@ static int lookup_triplets(const char *const *triplets, const char *name)
return -1;
}
+/*
+ * Return architecture name in a normalized form.
+ * The conversion logic comes from the Makefile.
+ */
+static const char *normalize_arch(char *arch)
+{
+ if (!strcmp(arch, "x86_64"))
+ return "x86";
+ if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6')
+ return "x86";
+ if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5))
+ return "sparc";
+ if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110"))
+ return "arm";
+ if (!strncmp(arch, "s390", 4))
+ return "s390";
+ if (!strncmp(arch, "parisc", 6))
+ return "parisc";
+ if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3))
+ return "powerpc";
+ if (!strncmp(arch, "mips", 4))
+ return "mips";
+ if (!strncmp(arch, "sh", 2) && isdigit(arch[2]))
+ return "sh";
+
+ return arch;
+}
+
static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
const char *name,
const char **path)
{
int idx;
- char *arch, *cross_env;
+ const char *arch, *cross_env;
struct utsname uts;
const char *const *path_list;
char *buf = NULL;
+ arch = normalize_arch(env->arch);
+
if (uname(&uts) < 0)
goto out;
@@ -110,7 +140,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
* We don't need to try to find objdump path for native system.
* Just use default binutils path (e.g.: "objdump").
*/
- if (!strcmp(uts.machine, env->arch))
+ if (!strcmp(normalize_arch(uts.machine), arch))
goto out;
cross_env = getenv("CROSS_COMPILE");
@@ -127,8 +157,6 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
free(buf);
}
- arch = env->arch;
-
if (!strcmp(arch, "arm"))
path_list = arm_triplets;
else if (!strcmp(arch, "powerpc"))
@@ -139,9 +167,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
path_list = s390_triplets;
else if (!strcmp(arch, "sparc"))
path_list = sparc_triplets;
- else if (!strcmp(arch, "x86") || !strcmp(arch, "i386") ||
- !strcmp(arch, "i486") || !strcmp(arch, "i586") ||
- !strcmp(arch, "i686"))
+ else if (!strcmp(arch, "x86"))
path_list = x86_triplets;
else if (!strcmp(arch, "mips"))
path_list = mips_triplets;
@@ -173,6 +199,13 @@ out_error:
int perf_session_env__lookup_objdump(struct perf_session_env *env)
{
+ /*
+ * For live mode, env->arch will be NULL and we can use
+ * the native objdump tool.
+ */
+ if (env->arch == NULL)
+ return 0;
+
return perf_session_env__lookup_binutils_path(env, "objdump",
&objdump_path);
}