Skip to contentSkip to conversation

tools/perf/tests: Fix objdump in Object code reading test to look for all sections

PATCH In review Athira Rajeev 2 participants 2 messages Jul 4, 2023 – Jul 5, 2023 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/perf/tests: Fix objdump in Object code reading test to look for all sections

Object code reading test fails intermittently with below logs:

Reading object code for memory address: 0xc008000001dd34fc
File is: /lib/modules/6.3.0-rc7+/kernel/fs/xfs/xfs.ko
On file address is: 0x11359c
Objdump command is: objdump -z -d --start-address=0x1134fc --stop-address=0x11357c /lib/modules/6.3.0-rc7+/kernel/fs/xfs/xfs.ko objdump read too few bytes: 128
test child finished with -1
---- end ----
Object code reading: FAILED!

This issue happens ramdomly depending on the sample ip captured during the test run. In some cases, the same ip falls in the xfs module. The test does an objdump on the xfs.ko file and compares it with the dump from the dso that perf captures. But since the range of ip address falls in debug info section, it fails to find the address range with objdump. Fix the objdump option so as to disasseble all sections to check the address range.

---
 tools/perf/tests/code-reading.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/code-reading.c +1 -1
index ed3815163d1b..02132478856a 100644
@@ -184,7 +184,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,
 	FILE *f;
 	int ret;
 
-	fmt = "%s -z -d --start-address=0x%"PRIx64" --stop-address=0x%"PRIx64" %s";
+	fmt = "%s -z -D --start-address=0x%"PRIx64" --stop-address=0x%"PRIx64" %s";
 	ret = snprintf(cmd, sizeof(cmd), fmt, "objdump", addr, addr + len,
 		       filename);
 	if (ret <= 0 || (size_t)ret >= sizeof(cmd))
Signature · 1 line
2.35.3
maintainer
#1 lore raw
Quoted 12 lines · Athira Rajeev

Object code reading test fails intermittently with below logs:

Reading object code for memory address: 0xc008000001dd34fc
File is: /lib/modules/6.3.0-rc7+/kernel/fs/xfs/xfs.ko
On file address is: 0x11359c
Objdump command is: objdump -z -d --start-address=0x1134fc --stop-address=0x11357c /lib/modules/6.3.0-rc7+/kernel/fs/xfs/xfs.ko objdump read too few bytes: 128
test child finished with -1
---- end ----
Object code reading: FAILED!

Quoted 5 lines

This issue happens ramdomly depending on the sample ip captured during the test run. In some cases, the same ip falls in the xfs module. The test does an objdump on the xfs.ko file and compares it with the dump from the dso that perf captures. But since the range of ip address falls in debug info section, it fails

This is strange. Why did it fall into the debug section?

Thanks,
Namhyung

Quoted 24 lines

to find the address range with objdump. Fix the objdump option so as to disasseble all sections to check the address range.

---
 tools/perf/tests/code-reading.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/code-reading.c +1 -2
index ed3815163d1b..02132478856a 100644
@@ -184,7 +184,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,
        FILE *f;
        int ret;
 
-       fmt = "%s -z -d --start-address=0x%"PRIx64" --stop-address=0x%"PRIx64" %s";
+       fmt = "%s -z -D --start-address=0x%"PRIx64" --stop-address=0x%"PRIx64" %s";
        ret = snprintf(cmd, sizeof(cmd), fmt, "objdump", addr, addr + len,
                       filename);
        if (ret <= 0 || (size_t)ret >= sizeof(cmd))
--

2.35.3