Skip to content

Commit 94df104

Browse files
namhyungacmel
authored andcommitted
perf tests: Decompress kernel module before objdump
If a kernel modules is compressed, it should be decompressed before running objdump to parse binary data correctly. This fixes a failure of object code reading test for me. Signed-off-by: Namhyung Kim <[email protected]> Acked-by: Adrian Hunter <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: David Ahern <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Wang Nan <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 8ba29ad commit 94df104

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tools/perf/tests/code-reading.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
229229
unsigned char buf2[BUFSZ];
230230
size_t ret_len;
231231
u64 objdump_addr;
232+
const char *objdump_name;
233+
char decomp_name[KMOD_DECOMP_LEN];
232234
int ret;
233235

234236
pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr);
@@ -289,9 +291,25 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
289291
state->done[state->done_cnt++] = al.map->start;
290292
}
291293

294+
objdump_name = al.map->dso->long_name;
295+
if (dso__needs_decompress(al.map->dso)) {
296+
if (dso__decompress_kmodule_path(al.map->dso, objdump_name,
297+
decomp_name,
298+
sizeof(decomp_name)) < 0) {
299+
pr_debug("decompression failed\n");
300+
return -1;
301+
}
302+
303+
objdump_name = decomp_name;
304+
}
305+
292306
/* Read the object code using objdump */
293307
objdump_addr = map__rip_2objdump(al.map, al.addr);
294-
ret = read_via_objdump(al.map->dso->long_name, objdump_addr, buf2, len);
308+
ret = read_via_objdump(objdump_name, objdump_addr, buf2, len);
309+
310+
if (dso__needs_decompress(al.map->dso))
311+
unlink(objdump_name);
312+
295313
if (ret > 0) {
296314
/*
297315
* The kernel maps are inaccurate - assume objdump is right in

0 commit comments

Comments
 (0)