Commit 2c7da8c5 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf annotate: Allow annotation for decompressed kernel modules

Decompressing kernel module file for objdump command if needed.
Annotation commands now display annotation for compressed kernel
modules.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-x4jcytk2d5qjmnjvb0w75q3f@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent bc84f464
...@@ -1008,6 +1008,32 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize) ...@@ -1008,6 +1008,32 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
} }
filename = symfs_filename; filename = symfs_filename;
} }
} else if (dso__needs_decompress(dso)) {
char tmp[PATH_MAX];
struct kmod_path m;
int fd;
bool ret;
if (kmod_path__parse_ext(&m, symfs_filename))
goto out_free_filename;
snprintf(tmp, PATH_MAX, "/tmp/perf-kmod-XXXXXX");
fd = mkstemp(tmp);
if (fd < 0) {
free(m.ext);
goto out_free_filename;
}
ret = decompress_to_file(m.ext, symfs_filename, fd);
free(m.ext);
close(fd);
if (!ret)
goto out_free_filename;
strcpy(symfs_filename, tmp);
} }
snprintf(command, sizeof(command), snprintf(command, sizeof(command),
...@@ -1027,7 +1053,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize) ...@@ -1027,7 +1053,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
file = popen(command, "r"); file = popen(command, "r");
if (!file) if (!file)
goto out_free_filename; goto out_remove_tmp;
while (!feof(file)) while (!feof(file))
if (symbol__parse_objdump_line(sym, map, file, privsize, if (symbol__parse_objdump_line(sym, map, file, privsize,
...@@ -1042,6 +1068,10 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize) ...@@ -1042,6 +1068,10 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
delete_last_nop(sym); delete_last_nop(sym);
pclose(file); pclose(file);
out_remove_tmp:
if (dso__needs_decompress(dso))
unlink(symfs_filename);
out_free_filename: out_free_filename:
if (delete_extract) if (delete_extract)
kcore_extract__delete(&kce); kcore_extract__delete(&kce);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment