perf disassemble: Simplify logic for picking the filename to disassemble
Lots of changes to support kcore, compressed modules, build-id files left us with some spaguetti code, simplify it a bit, more to come. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-h70p7x451li3f2fhs44vzmm8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
c12944f7fa
commit
3caee094d1
|
@ -1166,7 +1166,6 @@ int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize)
|
||||||
{
|
{
|
||||||
struct dso *dso = map->dso;
|
struct dso *dso = map->dso;
|
||||||
char *filename;
|
char *filename;
|
||||||
bool free_filename = true;
|
|
||||||
char command[PATH_MAX * 2];
|
char command[PATH_MAX * 2];
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char symfs_filename[PATH_MAX];
|
char symfs_filename[PATH_MAX];
|
||||||
|
@ -1183,31 +1182,30 @@ int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
filename = dso__build_id_filename(dso, NULL, 0);
|
filename = dso__build_id_filename(dso, NULL, 0);
|
||||||
if (filename)
|
if (filename) {
|
||||||
symbol__join_symfs(symfs_filename, filename);
|
symbol__join_symfs(symfs_filename, filename);
|
||||||
|
free(filename);
|
||||||
if (filename == NULL) {
|
} else {
|
||||||
if (dso->has_build_id)
|
if (dso->has_build_id)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
goto fallback;
|
goto fallback;
|
||||||
} else if (dso__is_kcore(dso) ||
|
}
|
||||||
readlink(symfs_filename, command, sizeof(command)) < 0 ||
|
|
||||||
strstr(command, DSO__NAME_KALLSYMS) ||
|
if (dso__is_kcore(dso) ||
|
||||||
access(symfs_filename, R_OK)) {
|
readlink(symfs_filename, command, sizeof(command)) < 0 ||
|
||||||
free(filename);
|
strstr(command, DSO__NAME_KALLSYMS) ||
|
||||||
|
access(symfs_filename, R_OK)) {
|
||||||
fallback:
|
fallback:
|
||||||
/*
|
/*
|
||||||
* If we don't have build-ids or the build-id file isn't in the
|
* If we don't have build-ids or the build-id file isn't in the
|
||||||
* cache, or is just a kallsyms file, well, lets hope that this
|
* cache, or is just a kallsyms file, well, lets hope that this
|
||||||
* DSO is the same as when 'perf record' ran.
|
* DSO is the same as when 'perf record' ran.
|
||||||
*/
|
*/
|
||||||
filename = (char *)dso->long_name;
|
symbol__join_symfs(symfs_filename, dso->long_name);
|
||||||
symbol__join_symfs(symfs_filename, filename);
|
|
||||||
free_filename = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__,
|
pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__,
|
||||||
filename, sym->name, map->unmap_ip(map, sym->start),
|
symfs_filename, sym->name, map->unmap_ip(map, sym->start),
|
||||||
map->unmap_ip(map, sym->end));
|
map->unmap_ip(map, sym->end));
|
||||||
|
|
||||||
pr_debug("annotating [%p] %30s : [%p] %30s\n",
|
pr_debug("annotating [%p] %30s : [%p] %30s\n",
|
||||||
|
@ -1222,11 +1220,6 @@ fallback:
|
||||||
delete_extract = true;
|
delete_extract = true;
|
||||||
strlcpy(symfs_filename, kce.extract_filename,
|
strlcpy(symfs_filename, kce.extract_filename,
|
||||||
sizeof(symfs_filename));
|
sizeof(symfs_filename));
|
||||||
if (free_filename) {
|
|
||||||
free(filename);
|
|
||||||
free_filename = false;
|
|
||||||
}
|
|
||||||
filename = symfs_filename;
|
|
||||||
}
|
}
|
||||||
} else if (dso__needs_decompress(dso)) {
|
} else if (dso__needs_decompress(dso)) {
|
||||||
char tmp[PATH_MAX];
|
char tmp[PATH_MAX];
|
||||||
|
@ -1235,14 +1228,14 @@ fallback:
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
if (kmod_path__parse_ext(&m, symfs_filename))
|
if (kmod_path__parse_ext(&m, symfs_filename))
|
||||||
goto out_free_filename;
|
goto out;
|
||||||
|
|
||||||
snprintf(tmp, PATH_MAX, "/tmp/perf-kmod-XXXXXX");
|
snprintf(tmp, PATH_MAX, "/tmp/perf-kmod-XXXXXX");
|
||||||
|
|
||||||
fd = mkstemp(tmp);
|
fd = mkstemp(tmp);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
free(m.ext);
|
free(m.ext);
|
||||||
goto out_free_filename;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = decompress_to_file(m.ext, symfs_filename, fd);
|
ret = decompress_to_file(m.ext, symfs_filename, fd);
|
||||||
|
@ -1254,7 +1247,7 @@ fallback:
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
goto out_free_filename;
|
goto out;
|
||||||
|
|
||||||
strcpy(symfs_filename, tmp);
|
strcpy(symfs_filename, tmp);
|
||||||
}
|
}
|
||||||
|
@ -1270,7 +1263,7 @@ fallback:
|
||||||
map__rip_2objdump(map, sym->end),
|
map__rip_2objdump(map, sym->end),
|
||||||
symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
|
symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
|
||||||
symbol_conf.annotate_src ? "-S" : "",
|
symbol_conf.annotate_src ? "-S" : "",
|
||||||
symfs_filename, filename);
|
symfs_filename, symfs_filename);
|
||||||
|
|
||||||
pr_debug("Executing: %s\n", command);
|
pr_debug("Executing: %s\n", command);
|
||||||
|
|
||||||
|
@ -1332,11 +1325,9 @@ out_remove_tmp:
|
||||||
|
|
||||||
if (dso__needs_decompress(dso))
|
if (dso__needs_decompress(dso))
|
||||||
unlink(symfs_filename);
|
unlink(symfs_filename);
|
||||||
out_free_filename:
|
|
||||||
if (delete_extract)
|
if (delete_extract)
|
||||||
kcore_extract__delete(&kce);
|
kcore_extract__delete(&kce);
|
||||||
if (free_filename)
|
|
||||||
free(filename);
|
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue