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

2023-07-05 Thread Namhyung Kim
On Mon, Jul 3, 2023 at 10:04 PM Athira Rajeev
 wrote:
>
> Object code reading test fails intermittently with below logs:
>
>Reading object code for memory address: 0xc00801dd34fc
>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

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

Thanks,
Namhyung


> to find the address range with objdump. Fix the objdump option so
> as to disasseble all sections to check the address range.
>
> Signed-off-by: Athira Rajeev 
> ---
>  tools/perf/tests/code-reading.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
> index ed3815163d1b..02132478856a 100644
> --- a/tools/perf/tests/code-reading.c
> +++ b/tools/perf/tests/code-reading.c
> @@ -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
>


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

2023-07-03 Thread Athira Rajeev
Object code reading test fails intermittently with below logs:

   Reading object code for memory address: 0xc00801dd34fc
   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.

Signed-off-by: Athira Rajeev 
---
 tools/perf/tests/code-reading.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index ed3815163d1b..02132478856a 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -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