perf test: Add option to change objdump binary
PATCH 1/1 perf test: Add option to change objdump binary
All of the other Perf subcommands that use objdump have an option to specify the binary, so add the same option to perf test.
This is useful if you have built the kernel with a different toolchain to the system one, where the system objdump may fail to disassemble vmlinux.
Now this can be fixed with something like this:
$ perf test --objdump llvm-objdump "object code reading"
--- tools/perf/tests/builtin-test.c | 3 +++ tools/perf/tests/code-reading.c | 2 +- tools/perf/tests/tests.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +3 -0
@@ -32,6 +32,7 @@static bool dont_fork;const char *dso_to_test; +const char *test_objdump_path ="objdump" ;/* * List of architecture specific tests. Not a weak symbol as the array length is
@@ -529,6 +530,8 @@ int cmd_test(int argc, const char **argv) "Do not fork for testcase"),OPT_STRING ('w' ,"workload" , &workload,"work" ,"workload to run for testing" ),OPT_STRING (0 ,"dso" , &dso_to_test,"dso" ,"dso to test" ), +OPT_STRING (0 ,"objdump" , &test_objdump_path,"path" , +"objdump binary to use for disassembly and annotations" ), OPT_END() };const char *const test_subcommands[] = {"list" ,NULL };
tools/perf/tests/code-reading.c +1 -1
@@ -185,7 +185,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,int ret; fmt ="%s -z -d --start-address=0x%" PRIx64" --stop-address=0x%" PRIx64" %s" ; - ret =snprintf (cmd,sizeof (cmd), fmt,"objdump" , addr, addr + len, + ret =snprintf (cmd,sizeof (cmd), fmt, test_objdump_path, addr, addr + len, filename);if (ret <=0 || (size_t )ret >=sizeof (cmd))return -1 ;
tools/perf/tests/tests.h +1 -0
@@ -207,5 +207,6 @@ DECLARE_WORKLOAD(brstack);DECLARE_WORKLOAD (datasym);extern const char *dso_to_test; +extern const char *test_objdump_path;#endif /* TESTS_H */
Signature · 1 line
2.34.1
Quoted 8 lines · James Clark
All of the other Perf subcommands that use objdump have an option to specify the binary, so add the same option to perf test.
This is useful if you have built the kernel with a different toolchain to the system one, where the system objdump may fail to disassemble vmlinux.
Quoted 5 lines
Now this can be fixed with something like this:
$ perf test --objdump llvm-objdump "object code reading"Signed-off-by James Clark <[email protected]>
There is also "perf config" for things like this.
Thanks,
Ian
Quoted 13 lines · Ian Rogers
Quoted 12 lines · James Clark
All of the other Perf subcommands that use objdump have an option to specify the binary, so add the same option to perf test.
This is useful if you have built the kernel with a different toolchain to the system one, where the system objdump may fail to disassemble vmlinux.
Now this can be fixed with something like this:
$ perf test --objdump llvm-objdump "object code reading"
Quoted 8 lines
Quoted 1 line
Signed-off-by James Clark <[email protected]>There is also "perf config" for things like this.
Reviewed-by Ian Rogers <[email protected]>Thanks,
Ian
That seems a bit better for this use case so I added it in V2.
Thanks for the review.
James
Arnaldo Carvalho de Melo
maintainerEm Tue, Nov 07, 2023 at 09:37:32AM +0000, James Clark escreveu:
Quoted 18 lines · Ian Rogers
Quoted 15 lines · James Clark
Quoted 13 lines
All of the other Perf subcommands that use objdump have an option to specify the binary, so add the same option to perf test.
This is useful if you have built the kernel with a different toolchain to the system one, where the system objdump may fail to disassemble vmlinux.
Now this can be fixed with something like this:
$ perf test --objdump llvm-objdump "object code reading"Signed-off-by James Clark <[email protected]>
Quoted 8 lines
Quoted 6 lines
There is also "perf config" for things like this.
Reviewed-by Ian Rogers <[email protected]>Thanks,
IanThat seems a bit better for this use case so I added it in V2.
Have you posted it?
Quoted 3 lines
Thanks for the review.
James
Signature · 1 line
- Arnaldo
Arnaldo Carvalho de Melo
maintainerEm Wed, Nov 08, 2023 at 05:48:52PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 9 lines
Em Tue, Nov 07, 2023 at 09:37:32AM +0000, James Clark escreveu:
Quoted 6 lines · Ian Rogers
Quoted 3 lines
There is also "perf config" for things like this.
Reviewed-by Ian Rogers <[email protected]>That seems a bit better for this use case so I added it in V2.
Have you posted it?
Yeah, b4 found it, nevermind.
- Arnaldo