1e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng#include <stdio.h> 2e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng#include <sys/utsname.h> 3e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng#include "common.h" 4e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng#include "../util/debug.h" 5e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 6e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengconst char *const arm_triplets[] = { 7e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "arm-eabi-", 8e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "arm-linux-androideabi-", 9e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "arm-unknown-linux-", 10e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "arm-unknown-linux-gnu-", 11e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "arm-unknown-linux-gnueabi-", 12e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng NULL 13e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng}; 14e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 15ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes#if defined(ANDROID_PATCHES) 16ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughesconst char *const arm64_triplets[] = { 17ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes "aarch64-linux-android-", 18ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes NULL 19ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes}; 20ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes#endif 21ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes 22e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengconst char *const powerpc_triplets[] = { 23e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "powerpc-unknown-linux-gnu-", 24e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "powerpc64-unknown-linux-gnu-", 25e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng NULL 26e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng}; 27e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 28e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengconst char *const s390_triplets[] = { 29e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "s390-ibm-linux-", 30e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng NULL 31e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng}; 32e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 33e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengconst char *const sh_triplets[] = { 34e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "sh-unknown-linux-gnu-", 35e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "sh64-unknown-linux-gnu-", 36e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng NULL 37e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng}; 38e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 39e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengconst char *const sparc_triplets[] = { 40e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "sparc-unknown-linux-gnu-", 41e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "sparc64-unknown-linux-gnu-", 42e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng NULL 43e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng}; 44e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 45e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengconst char *const x86_triplets[] = { 46e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "x86_64-pc-linux-gnu-", 47e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "x86_64-unknown-linux-gnu-", 48e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "i686-pc-linux-gnu-", 49e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "i586-pc-linux-gnu-", 50e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "i486-pc-linux-gnu-", 51e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "i386-pc-linux-gnu-", 52e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "i686-linux-android-", 53e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "i686-android-linux-", 54e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng NULL 55e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng}; 56e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 57e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengconst char *const mips_triplets[] = { 58e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "mips-unknown-linux-gnu-", 59e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "mipsel-linux-android-", 60e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng NULL 61e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng}; 62e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 63e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengstatic bool lookup_path(char *name) 64e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng{ 65e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng bool found = false; 66e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng char *path, *tmp; 67e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng char buf[PATH_MAX]; 68e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng char *env = getenv("PATH"); 69e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 70e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!env) 71e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return false; 72e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 73e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng env = strdup(env); 74e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!env) 75e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return false; 76e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 77e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path = strtok_r(env, ":", &tmp); 78e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng while (path) { 79e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng scnprintf(buf, sizeof(buf), "%s/%s", path, name); 80e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (access(buf, F_OK) == 0) { 81e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng found = true; 82e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng break; 83e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng } 84e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path = strtok_r(NULL, ":", &tmp); 85e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng } 86e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng free(env); 87e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return found; 88e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng} 89e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 90e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengstatic int lookup_triplets(const char *const *triplets, const char *name) 91e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng{ 92e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng int i; 93e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng char buf[PATH_MAX]; 94e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 95e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng for (i = 0; triplets[i] != NULL; i++) { 96e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng scnprintf(buf, sizeof(buf), "%s%s", triplets[i], name); 97e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (lookup_path(buf)) 98e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return i; 99e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng } 100e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return -1; 101e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng} 102e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 103e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng/* 104e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng * Return architecture name in a normalized form. 105e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng * The conversion logic comes from the Makefile. 106e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng */ 107e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengstatic const char *normalize_arch(char *arch) 108e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng{ 109e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strcmp(arch, "x86_64")) 110e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "x86"; 111e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6') 112e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "x86"; 113e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5)) 114e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "sparc"; 115ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes#if defined(ANDROID_PATCHES) 116ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes if (!strcmp(arch, "aarch64") || !strcmp(arch, "arm64")) 117ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes return "arm64"; 118ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes#endif 119e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110")) 120e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "arm"; 121e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strncmp(arch, "s390", 4)) 122e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "s390"; 123e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strncmp(arch, "parisc", 6)) 124e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "parisc"; 125e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3)) 126e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "powerpc"; 127e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strncmp(arch, "mips", 4)) 128e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "mips"; 129e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strncmp(arch, "sh", 2) && isdigit(arch[2])) 130e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return "sh"; 131e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 132e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return arch; 133e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng} 134e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 135e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengstatic int perf_session_env__lookup_binutils_path(struct perf_session_env *env, 136e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng const char *name, 137e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng const char **path) 138e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng{ 139e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng int idx; 140e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng const char *arch, *cross_env; 141e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng struct utsname uts; 142e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng const char *const *path_list; 143e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng char *buf = NULL; 144e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 145e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng arch = normalize_arch(env->arch); 146e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 147e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (uname(&uts) < 0) 148e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out; 149e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 150e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng /* 151e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng * We don't need to try to find objdump path for native system. 152e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng * Just use default binutils path (e.g.: "objdump"). 153e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng */ 154e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strcmp(normalize_arch(uts.machine), arch)) 155e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out; 156e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 157e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng cross_env = getenv("CROSS_COMPILE"); 158e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (cross_env) { 159e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (asprintf(&buf, "%s%s", cross_env, name) < 0) 160e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out_error; 161e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (buf[0] == '/') { 162e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (access(buf, F_OK) == 0) 163e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out; 164e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out_error; 165e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng } 166e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (lookup_path(buf)) 167e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out; 168e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng free(buf); 169e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng buf = NULL; 170e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng } 171e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 172e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (!strcmp(arch, "arm")) 173e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path_list = arm_triplets; 174ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes#if defined(ANDROID_PATCHES) 175ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes else if (!strcmp(arch, "arm64")) 176ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes path_list = arm64_triplets; 177ae2ee57891a4c0e9b45946c78bcb4c17338c2da0Elliott Hughes#endif 178e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng else if (!strcmp(arch, "powerpc")) 179e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path_list = powerpc_triplets; 180e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng else if (!strcmp(arch, "sh")) 181e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path_list = sh_triplets; 182e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng else if (!strcmp(arch, "s390")) 183e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path_list = s390_triplets; 184e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng else if (!strcmp(arch, "sparc")) 185e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path_list = sparc_triplets; 186e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng else if (!strcmp(arch, "x86")) 187e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path_list = x86_triplets; 188e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng else if (!strcmp(arch, "mips")) 189e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng path_list = mips_triplets; 190e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng else { 191e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng ui__error("binutils for %s not supported.\n", arch); 192e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out_error; 193e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng } 194e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 195e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng idx = lookup_triplets(path_list, name); 196e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (idx < 0) { 197e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng ui__error("Please install %s for %s.\n" 198e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "You can add it to PATH, set CROSS_COMPILE or " 199e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng "override the default using --%s.\n", 200e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng name, arch, name); 201e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out_error; 202e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng } 203e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 204e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (asprintf(&buf, "%s%s", path_list[idx], name) < 0) 205e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng goto out_error; 206e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 207e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengout: 208e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng *path = buf; 209e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return 0; 210e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengout_error: 211e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng free(buf); 212e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng *path = NULL; 213e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return -1; 214e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng} 215e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 216e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengint perf_session_env__lookup_objdump(struct perf_session_env *env) 217e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng{ 218e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng /* 219e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng * For live mode, env->arch will be NULL and we can use 220e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng * the native objdump tool. 221e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng */ 222e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng if (env->arch == NULL) 223e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return 0; 224e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng 225e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng return perf_session_env__lookup_binutils_path(env, "objdump", 226e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng &objdump_path); 227e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng} 228