Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338960
b: refs/heads/master
c: 48ed0ec
h: refs/heads/master
v: v3
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Nov 5, 2012
1 parent 3793165 commit d5d023c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b84800a31502ab75c0032192de01e61a0d517f38
refs/heads/master: 48ed0ece1b8063313284812ef048b26c3c4250af
40 changes: 33 additions & 7 deletions trunk/tools/perf/arch/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,54 @@ 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;

/*
* 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");
Expand All @@ -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"))
Expand All @@ -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;
Expand Down

0 comments on commit d5d023c

Please sign in to comment.