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 libunwind: Fixup conversion perf_sample->user_regs to a pointer

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 <irogers@google.com>
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

Fixes: dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250313033121.758978-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Arnaldo Carvalho de Melo and committed by
Namhyung Kim
4e82c88a 02ba09c8

+6 -6
+6 -6
tools/perf/util/unwind-libunwind-local.c
··· 579 579 int ret; 580 580 581 581 /* Don't support write, probably not needed. */ 582 - if (__write || !stack || !ui->sample->user_regs.regs) { 582 + if (__write || !stack || !ui->sample->user_regs || !ui->sample->user_regs->regs) { 583 583 *valp = 0; 584 584 return 0; 585 585 } 586 586 587 - ret = perf_reg_value(&start, &ui->sample->user_regs, 587 + ret = perf_reg_value(&start, perf_sample__user_regs(ui->sample), 588 588 perf_arch_reg_sp(arch)); 589 589 if (ret) 590 590 return ret; ··· 628 628 return 0; 629 629 } 630 630 631 - if (!ui->sample->user_regs.regs) { 631 + if (!ui->sample->user_regs || !ui->sample->user_regs->regs) { 632 632 *valp = 0; 633 633 return 0; 634 634 } ··· 637 637 if (id < 0) 638 638 return -EINVAL; 639 639 640 - ret = perf_reg_value(&val, &ui->sample->user_regs, id); 640 + ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample), id); 641 641 if (ret) { 642 642 if (!ui->best_effort) 643 643 pr_err("unwind: can't read reg %d\n", regnum); ··· 741 741 unw_cursor_t c; 742 742 int ret, i = 0; 743 743 744 - ret = perf_reg_value(&val, &ui->sample->user_regs, 744 + ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample), 745 745 perf_arch_reg_ip(arch)); 746 746 if (ret) 747 747 return ret; ··· 808 808 .best_effort = best_effort 809 809 }; 810 810 811 - if (!data->user_regs.regs) 811 + if (!data->user_regs || !data->user_regs->regs) 812 812 return -EINVAL; 813 813 814 814 if (max_stack <= 0)