Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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"

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>

authored by

James Clark and committed by
Arnaldo Carvalho de Melo
33ce9fc4 b861fd7e

+5 -1
+3
tools/perf/tests/builtin-test.c
··· 32 32 33 33 static bool dont_fork; 34 34 const char *dso_to_test; 35 + const char *test_objdump_path = "objdump"; 35 36 36 37 /* 37 38 * List of architecture specific tests. Not a weak symbol as the array length is ··· 530 529 "Do not fork for testcase"), 531 530 OPT_STRING('w', "workload", &workload, "work", "workload to run for testing"), 532 531 OPT_STRING(0, "dso", &dso_to_test, "dso", "dso to test"), 532 + OPT_STRING(0, "objdump", &test_objdump_path, "path", 533 + "objdump binary to use for disassembly and annotations"), 533 534 OPT_END() 534 535 }; 535 536 const char * const test_subcommands[] = { "list", NULL };
+1 -1
tools/perf/tests/code-reading.c
··· 185 185 int ret; 186 186 187 187 fmt = "%s -z -d --start-address=0x%"PRIx64" --stop-address=0x%"PRIx64" %s"; 188 - ret = snprintf(cmd, sizeof(cmd), fmt, "objdump", addr, addr + len, 188 + ret = snprintf(cmd, sizeof(cmd), fmt, test_objdump_path, addr, addr + len, 189 189 filename); 190 190 if (ret <= 0 || (size_t)ret >= sizeof(cmd)) 191 191 return -1;
+1
tools/perf/tests/tests.h
··· 207 207 DECLARE_WORKLOAD(datasym); 208 208 209 209 extern const char *dso_to_test; 210 + extern const char *test_objdump_path; 210 211 211 212 #endif /* TESTS_H */