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

Configure Feed

Select the types of activity you want to include in your feed.

perf tools: Fix compilation error on arm64

Since the commit dc6d2bc2d893 ("perf sample: Make user_regs and
intr_regs optional"), the building for Arm64 reports error:

arch/arm64/util/unwind-libdw.c: In function ‘libdw__arch_set_initial_registers’:
arch/arm64/util/unwind-libdw.c:11:32: error: initialization of ‘struct regs_dump *’ from incompatible pointer type ‘struct regs_dump **’ [-Werror=incompatible-pointer-types]
11 | struct regs_dump *user_regs = &ui->sample->user_regs;
| ^
cc1: all warnings being treated as errors
make[6]: *** [/home/niayan01/linux/tools/build/Makefile.build:85: arch/arm64/util/unwind-libdw.o] Error 1
make[5]: *** [/home/niayan01/linux/tools/build/Makefile.build:138: util] Error 2
arch/arm64/tests/dwarf-unwind.c: In function ‘test__arch_unwind_sample’:
arch/arm64/tests/dwarf-unwind.c:48:27: error: initialization of ‘struct regs_dump *’ from incompatible pointer type ‘struct regs_dump **’ [-Werror=incompatible-pointer-types]
48 | struct regs_dump *regs = &sample->user_regs;
| ^

To fix the issue, use the helper perf_sample__user_regs() to retrieve
the user_regs.

Fixes: dc6d2bc2d893 ("perf sample: Make user_regs and intr_regs optional")
Signed-off-by: Leo Yan <leo.yan@arm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250214111025.14478-1-leo.yan@arm.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Leo Yan and committed by
Namhyung Kim
d18c882f 7c1e94f5

+2 -2
+1 -1
tools/perf/arch/arm64/tests/dwarf-unwind.c
··· 45 45 int test__arch_unwind_sample(struct perf_sample *sample, 46 46 struct thread *thread) 47 47 { 48 - struct regs_dump *regs = &sample->user_regs; 48 + struct regs_dump *regs = perf_sample__user_regs(sample); 49 49 u64 *buf; 50 50 51 51 buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
+1 -1
tools/perf/arch/arm64/util/unwind-libdw.c
··· 8 8 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) 9 9 { 10 10 struct unwind_info *ui = arg; 11 - struct regs_dump *user_regs = &ui->sample->user_regs; 11 + struct regs_dump *user_regs = perf_sample__user_regs(ui->sample); 12 12 Dwarf_Word dwarf_regs[PERF_REG_ARM64_MAX], dwarf_pc; 13 13 14 14 #define REG(r) ({ \