perf test: Add option to change objdump binary
authorJames Clark <james.clark@arm.com>
Mon, 6 Nov 2023 15:10:48 +0000 (15:10 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 9 Nov 2023 16:49:33 +0000 (13:49 -0300)
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"

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: James Clark <james.clark@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Fangrui Song <maskray@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Tom Rix <trix@redhat.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20231106151051.129440-2-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/builtin-test.c
tools/perf/tests/code-reading.c
tools/perf/tests/tests.h

index cb6f1dd00dc483a495fdb465067aa33ae6a6be1e..a8d17dd5058880c91347a8140acbb71d4b610352 100644 (file)
@@ -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 };
index d6e845c579023100c30dee55be99e3bed4fa2355..8620146d0378389b73332217273cb31ae4310cc9 100644 (file)
@@ -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;
index b394f3ac2d667bacb2d9e16aca78715c65ab5ed3..dad3d7414142d1befc3d6eebe48d81a39ace153a 100644 (file)
@@ -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 */