perf tools: Fix compilation error on arm64
authorLeo Yan <leo.yan@arm.com>
Fri, 14 Feb 2025 11:10:25 +0000 (11:10 +0000)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 14 Feb 2025 19:12:12 +0000 (11:12 -0800)
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>
tools/perf/arch/arm64/tests/dwarf-unwind.c
tools/perf/arch/arm64/util/unwind-libdw.c

index b2603d0d3737a1af3f7fbd6eb0e1de171782fdfb..440d00f0de14155613bc3474c1c8b402b11cbe4b 100644 (file)
@@ -45,7 +45,7 @@ static int sample_ustack(struct perf_sample *sample,
 int test__arch_unwind_sample(struct perf_sample *sample,
                struct thread *thread)
 {
-       struct regs_dump *regs = &sample->user_regs;
+       struct regs_dump *regs = perf_sample__user_regs(sample);
        u64 *buf;
 
        buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
index e056d50ab42e33c5ee117c804c352a7d40b5a822..b89b0a7e5ad919fed23643d219fbdc3d84deff1e 100644 (file)
@@ -8,7 +8,7 @@
 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
 {
        struct unwind_info *ui = arg;
-       struct regs_dump *user_regs = &ui->sample->user_regs;
+       struct regs_dump *user_regs = perf_sample__user_regs(ui->sample);
        Dwarf_Word dwarf_regs[PERF_REG_ARM64_MAX], dwarf_pc;
 
 #define REG(r) ({                                              \