perf libunwind: Fixup conversion perf_sample->user_regs to a pointer
Arnaldo Carvalho de Melo
maintainerPATCH 1/1 perf libunwind: Fixup conversion perf_sample->user_regs to a pointer
From: Arnaldo Carvalho de Melo <[email protected]>
The dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional") misses the changes to a file, resulting in this problem:
$ make LIBUNWIND=1 -C tools/perf O=/tmp/build/perf-tools-next install-bin
<SNIP>
CC /tmp/build/perf-tools-next/util/unwind-libunwind-local.o
CC /tmp/build/perf-tools-next/util/unwind-libunwind.o
<SNIP>
util/unwind-libunwind-local.c: In function ‘access_mem’:
util/unwind-libunwind-local.c:582:56: error: ‘ui->sample->user_regs’ is a pointer; did you mean to use ‘->’?
582 | if (__write || !stack || !ui->sample->user_regs.regs) {
| ^
| ->
util/unwind-libunwind-local.c:587:38: error: passing argument 2 of ‘perf_reg_value’ from incompatible pointer type [-Wincompatible-pointer-types]
587 | ret = perf_reg_value(&start, &ui->sample->user_regs,
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| struct regs_dump **
<SNIP>
⬢ [acme@toolbox perf-tools-next]$ git bisect bad
dc6d2bc2d893a878e7b58578ff01b4738708deb4 is the first bad commit
commit dc6d2bc2d893a878e7b58578ff01b4738708deb4 (HEAD)
Author: Ian Rogers <[email protected]>
Date: Mon Jan 13 11:43:45 2025 -0800 perf sample: Make user_regs and intr_regs optional
Detected using:
make -C tools/perf build-test
--- tools/perf/util/unwind-libunwind-local.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/util/unwind-libunwind-local.c +6 -6
@@ -579,12 +579,12 @@ static int access_mem(unw_addr_space_t __maybe_unused as,int ret;/* Don't support write, probably not needed. */ -if (__write || !stack || !ui->sample->user_regs.regs) { +if (__write || !stack || !ui->sample->user_regs->regs) { *valp =0 ;return 0 ; } - ret =perf_reg_value (&start, &ui->sample->user_regs, + ret =perf_reg_value (&start,perf_sample__user_regs (ui->sample),perf_arch_reg_sp (arch));if (ret)return ret;
@@ -628,7 +628,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,return 0 ; } -if (!ui->sample->user_regs.regs) { +if (!ui->sample->user_regs->regs) { *valp =0 ;return 0 ; }
@@ -637,7 +637,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,if (id <0 )return -EINVAL ; - ret =perf_reg_value (&val, &ui->sample->user_regs, id); + ret =perf_reg_value (&val,perf_sample__user_regs (ui->sample), id);if (ret) {if (!ui->best_effort)pr_err ("unwind: can't read reg %d\n" , regnum);
@@ -741,7 +741,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,unw_cursor_t c;int ret, i =0 ; - ret =perf_reg_value (&val, &ui->sample->user_regs, + ret =perf_reg_value (&val,perf_sample__user_regs (ui->sample),perf_arch_reg_ip (arch));if (ret)return ret;
@@ -808,7 +808,7 @@ static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg, .best_effort = best_effort }; -if (!data->user_regs.regs) +if (!data->user_regs->regs)return -EINVAL ;if (max_stack <=0 )
Signature · 1 line
2.47.0
Quoted 46 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
The
dc6d2bc2d893a878("perf sample: Makeuser_regsandintr_regsoptional") misses the changes to a file, resulting in this problem:$ make LIBUNWIND=1 -C tools/perf O=/tmp/build/perf-tools-next install-bin <SNIP> CC /tmp/build/perf-tools-next/util/unwind-libunwind-local.o CC /tmp/build/perf-tools-next/util/unwind-libunwind.o <SNIP> util/unwind-libunwind-local.c: In function ‘access_mem’: util/unwind-libunwind-local.c:582:56: error: ‘ui->sample->user_regs’ is a pointer; did you mean to use ‘->’? 582 | if (__write || !stack || !ui->sample->user_regs.regs) { | ^ | -> util/unwind-libunwind-local.c:587:38: error: passing argument 2 of ‘perf_reg_value’ from incompatible pointer type [-Wincompatible-pointer-types] 587 | ret = perf_reg_value(&start, &ui->sample->user_regs, | ^~~~~~~~~~~~~~~~~~~~~~ | | | struct regs_dump ** <SNIP> ⬢ [acme@toolbox perf-tools-next]$ git bisect bad dc6d2bc2d893a878e7b58578ff01b4738708deb4 is the first bad commit commit dc6d2bc2d893a878e7b58578ff01b4738708deb4 (HEAD) Author: Ian Rogers <[email protected]> Date: Mon Jan 13 11:43:45 2025 -0800perf sample: Make
user_regsandintr_regsoptionalDetected using:
make -C
tools/perfbuild-testFixes dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional")Cc Adrian Hunter <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Andi Kleen <[email protected]>Cc Charlie Jenkins <[email protected]>Cc Ian Rogers <[email protected]>Cc Ingo Molnar <[email protected]>Cc James Clark <[email protected]>Cc John Garry <[email protected]>Cc Kan Liang <[email protected]>Cc Leo Yan <[email protected]>Cc Mark Rutland <[email protected]>
Quoted 8 lines
Cc Michael Petlan <[email protected]>Cc Namhyung Kim <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Tavian Barnes <[email protected]>Cc Veronika Molnarova <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Sorry for the breakage, thanks for fixing this!
Thanks,
Ian
Quoted 62 lines
--- tools/perf/util/unwind-libunwind-local.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)tools/perf/util/unwind-libunwind-local.c +6
-7@@ -579,12 +579,12 @@ static int access_mem(unw_addr_space_t __maybe_unused as,int ret;/* Don't support write, probably not needed. */ -if (__write || !stack || !ui->sample->user_regs.regs) { +if (__write || !stack || !ui->sample->user_regs->regs) { *valp =0 ;return 0 ; } - ret =perf_reg_value (&start, &ui->sample->user_regs, + ret =perf_reg_value (&start,perf_sample__user_regs (ui->sample),perf_arch_reg_sp (arch));if (ret)return ret;@@ -628,7 +628,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,return 0 ; } -if (!ui->sample->user_regs.regs) { +if (!ui->sample->user_regs->regs) { *valp =0 ;return 0 ; }@@ -637,7 +637,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,if (id <0 )return -EINVAL ; - ret =perf_reg_value (&val, &ui->sample->user_regs, id); + ret =perf_reg_value (&val,perf_sample__user_regs (ui->sample), id);if (ret) {if (!ui->best_effort)pr_err ("unwind: can't read reg %d\n" , regnum);@@ -741,7 +741,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,unw_cursor_t c;int ret, i =0 ; - ret =perf_reg_value (&val, &ui->sample->user_regs, + ret =perf_reg_value (&val,perf_sample__user_regs (ui->sample),perf_arch_reg_ip (arch));if (ret)return ret;@@ -808,7 +808,7 @@ static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg, .best_effort = best_effort }; -if (!data->user_regs.regs) +if (!data->user_regs->regs)return -EINVAL ;if (max_stack <=0 ) --2.47.0
Namhyung Kim
maintainerQuoted 62 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
The
dc6d2bc2d893a878("perf sample: Makeuser_regsandintr_regsoptional") misses the changes to a file, resulting in this problem:$ make LIBUNWIND=1 -C tools/perf O=/tmp/build/perf-tools-next install-bin <SNIP> CC /tmp/build/perf-tools-next/util/unwind-libunwind-local.o CC /tmp/build/perf-tools-next/util/unwind-libunwind.o <SNIP> util/unwind-libunwind-local.c: In function ‘access_mem’: util/unwind-libunwind-local.c:582:56: error: ‘ui->sample->user_regs’ is a pointer; did you mean to use ‘->’? 582 | if (__write || !stack || !ui->sample->user_regs.regs) { | ^ | -> util/unwind-libunwind-local.c:587:38: error: passing argument 2 of ‘perf_reg_value’ from incompatible pointer type [-Wincompatible-pointer-types] 587 | ret = perf_reg_value(&start, &ui->sample->user_regs, | ^~~~~~~~~~~~~~~~~~~~~~ | | | struct regs_dump ** <SNIP> ⬢ [acme@toolbox perf-tools-next]$ git bisect bad dc6d2bc2d893a878e7b58578ff01b4738708deb4 is the first bad commit commit dc6d2bc2d893a878e7b58578ff01b4738708deb4 (HEAD) Author: Ian Rogers <[email protected]> Date: Mon Jan 13 11:43:45 2025 -0800perf sample: Make
user_regsandintr_regsoptionalDetected using:
make -C
tools/perfbuild-testFixes dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional")Cc Adrian Hunter <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Andi Kleen <[email protected]>Cc Charlie Jenkins <[email protected]>Cc Ian Rogers <[email protected]>Cc Ingo Molnar <[email protected]>Cc James Clark <[email protected]>Cc John Garry <[email protected]>Cc Kan Liang <[email protected]>Cc Leo Yan <[email protected]>Cc Mark Rutland <[email protected]>Cc Michael Petlan <[email protected]>Cc Namhyung Kim <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Tavian Barnes <[email protected]>Cc Veronika Molnarova <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/perf/util/unwind-libunwind-local.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)tools/perf/util/unwind-libunwind-local.c +0
-0
tools/perf/util/unwind-libunwind-local.c static int access_mem(unw_addr_space_t __maybe_unused as, · line 582
Quoted 5 lines
tools/perf/util/unwind-libunwind-local.c +1
-1@@ -579,12 +579,12 @@ static int access_mem(unw_addr_space_t __maybe_unused as,int ret;/* Don't support write, probably not needed. */ -if (__write || !stack || !ui->sample->user_regs.regs) { +if (__write || !stack || !ui->sample->user_regs->regs) {
The sample->user_regs can be NULL and I guess it's only allocated when it has some regs. Then probably it should be like:
if (__write || !stack || !ui->sample->user_regs) {Quoted 10 lines
tools/perf/util/unwind-libunwind-local.c +1
-1*valp =0 ;return 0 ; } - ret =perf_reg_value (&start, &ui->sample->user_regs, + ret =perf_reg_value (&start,perf_sample__user_regs (ui->sample),perf_arch_reg_sp (arch));if (ret)return ret;
tools/perf/util/unwind-libunwind-local.c static int access_reg(unw_addr_space_t __maybe_unused as, · line 631
Quoted 5 lines
tools/perf/util/unwind-libunwind-local.c +1
-1@@ -628,7 +628,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,return 0 ; } -if (!ui->sample->user_regs.regs) { +if (!ui->sample->user_regs->regs) {
Ditto.
Quoted 22 lines
tools/perf/util/unwind-libunwind-local.c +2
-2*valp =0 ;return 0 ; }@@ -637,7 +637,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,if (id <0 )return -EINVAL ; - ret =perf_reg_value (&val, &ui->sample->user_regs, id); + ret =perf_reg_value (&val,perf_sample__user_regs (ui->sample), id);if (ret) {if (!ui->best_effort)pr_err ("unwind: can't read reg %d\n" , regnum);@@ -741,7 +741,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,unw_cursor_t c;int ret, i =0 ; - ret =perf_reg_value (&val, &ui->sample->user_regs, + ret =perf_reg_value (&val,perf_sample__user_regs (ui->sample),perf_arch_reg_ip (arch));if (ret)return ret;
tools/perf/util/unwind-libunwind-local.c static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg, · line 811
Quoted 5 lines
tools/perf/util/unwind-libunwind-local.c +1
-1@@ -808,7 +808,7 @@ static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg, .best_effort = best_effort }; -if (!data->user_regs.regs) +if (!data->user_regs->regs)
Ditto.
Thanks,
Namhyung
Quoted 6 lines
tools/perf/util/unwind-libunwind-local.c +0
-0return -EINVAL ;if (max_stack <=0 )Signature · 1 line
2.47.0