aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2012-11-02 01:50:04 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-11-05 12:03:58 -0500
commit48ed0ece1b8063313284812ef048b26c3c4250af (patch)
tree8ff3851d73b25874bc695477e3d85944f84e5acd /tools
parentb84800a31502ab75c0032192de01e61a0d517f38 (diff)
perf tools: Use normalized arch name for searching objdump path
David reported that perf report for i686 target data on x86_64 host failed to work because it tried to find out cross-compiled objdump. However objdump for x86_64 is compatible to i686 so that it doesn't need to do it at all. To prevent similar artifacts, normalize arch name when comparing host and file architectures. Reported-by: David Ahern <dsahern@gmail.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Reviewed-by: David Ahern <dsahern@gmail.com> Tested-by: David Ahern <dsahern@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Irina Tirdea <irina.tirdea@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1351835406-15208-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/arch/common.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index 2367b253f039..5683529135b1 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)
93 return -1; 93 return -1;
94} 94}
95 95
96/*
97 * Return architecture name in a normalized form.
98 * The conversion logic comes from the Makefile.
99 */
100static const char *normalize_arch(char *arch)
101{
102 if (!strcmp(arch, "x86_64"))
103 return "x86";
104 if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6')
105 return "x86";
106 if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5))
107 return "sparc";
108 if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110"))
109 return "arm";
110 if (!strncmp(arch, "s390", 4))
111 return "s390";
112 if (!strncmp(arch, "parisc", 6))
113 return "parisc";
114 if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3))
115 return "powerpc";
116 if (!strncmp(arch, "mips", 4))
117 return "mips";
118 if (!strncmp(arch, "sh", 2) && isdigit(arch[2]))
119 return "sh";
120
121 return arch;
122}
123
96static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, 124static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
97 const char *name, 125 const char *name,
98 const char **path) 126 const char **path)
99{ 127{
100 int idx; 128 int idx;
101 char *arch, *cross_env; 129 const char *arch, *cross_env;
102 struct utsname uts; 130 struct utsname uts;
103 const char *const *path_list; 131 const char *const *path_list;
104 char *buf = NULL; 132 char *buf = NULL;
105 133
134 arch = normalize_arch(env->arch);
135
106 if (uname(&uts) < 0) 136 if (uname(&uts) < 0)
107 goto out; 137 goto out;
108 138
@@ -110,7 +140,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
110 * We don't need to try to find objdump path for native system. 140 * We don't need to try to find objdump path for native system.
111 * Just use default binutils path (e.g.: "objdump"). 141 * Just use default binutils path (e.g.: "objdump").
112 */ 142 */
113 if (!strcmp(uts.machine, env->arch)) 143 if (!strcmp(normalize_arch(uts.machine), arch))
114 goto out; 144 goto out;
115 145
116 cross_env = getenv("CROSS_COMPILE"); 146 cross_env = getenv("CROSS_COMPILE");
@@ -127,8 +157,6 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
127 free(buf); 157 free(buf);
128 } 158 }
129 159
130 arch = env->arch;
131
132 if (!strcmp(arch, "arm")) 160 if (!strcmp(arch, "arm"))
133 path_list = arm_triplets; 161 path_list = arm_triplets;
134 else if (!strcmp(arch, "powerpc")) 162 else if (!strcmp(arch, "powerpc"))
@@ -139,9 +167,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
139 path_list = s390_triplets; 167 path_list = s390_triplets;
140 else if (!strcmp(arch, "sparc")) 168 else if (!strcmp(arch, "sparc"))
141 path_list = sparc_triplets; 169 path_list = sparc_triplets;
142 else if (!strcmp(arch, "x86") || !strcmp(arch, "i386") || 170 else if (!strcmp(arch, "x86"))
143 !strcmp(arch, "i486") || !strcmp(arch, "i586") ||
144 !strcmp(arch, "i686"))
145 path_list = x86_triplets; 171 path_list = x86_triplets;
146 else if (!strcmp(arch, "mips")) 172 else if (!strcmp(arch, "mips"))
147 path_list = mips_triplets; 173 path_list = mips_triplets;