Re: [PATCH 1/2] perf probe: Fix wrong register name for arm64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just noticed that this patch fixes commit e47392bf9c06 (v4.8+). So,
Ccing stable@xxxxxxxxxxxxxxx
[e47392bf9c06 perf uprobe: Skip prologue if program compiled without
optimization]

After e47392bf9c06 on ARM64:
# cat > test.c << EOF
> #include <stdio.h>
>
> int main(int argc, void **argv)
> {
>         printf("argc =%d\n", argc);
> }
> EOF
# gcc -g  -o test test.c
# perf probe -x ./test -a 'main argc'
Target program is compiled without optimization. Skipping prologue.
Probe on address 0x400600 to force probing at the function entry.

Failed to write event: Invalid argument
  Error: Failed to add events.

If this patch is applied on top of e47392bf9c06:
perf probe -x ./test -a 'main argc'
Target program is compiled without optimization. Skipping prologue.
Probe on address 0x400600 to force probing at the function entry.

Added new event:
  probe_test:main      (on main in
/home/panand/work/test_code/uprobe_test/test with argc)

You can now use it in all perf tools, such as:

        perf record -e probe_test:main -aR sleep 1

~Pratyush

On Tue, Jan 24, 2017 at 4:00 PM, He Kuang <hekuang@xxxxxxxxxx> wrote:
> The register name of arm64 architecture is x0-x31 not r0-r31, this
> patch changes this typo.
>
> Before this patch:
>
>   # perf probe --definition 'sys_write count'
>   p:probe/sys_write _text+1502872 count=%r2:s64
>
>   # echo 'p:probe/sys_write _text+1502872 count=%r2:s64' > \
>     /sys/kernel/debug/tracing/kprobe_events
>   Parse error at argument[0]. (-22)
>
> After this patch:
>
>   # perf probe --definition 'sys_write count'
>   p:probe/sys_write _text+1502872 count=%x2:s64
>
>   # echo 'p:probe/sys_write _text+1502872 count=%x2:s64' > \
>     /sys/kernel/debug/tracing/kprobe_events
>   # echo 1 >/sys/kernel/debug/tracing/events/probe/enable
>   # cat /sys/kernel/debug/tracing/trace
>   ...
>   sh-422   [000] d... 650.495930: sys_write: (SyS_write+0x0/0xc8) count=22
>   sh-422   [000] d... 651.102389: sys_write: (SyS_write+0x0/0xc8) count=26
>   sh-422   [000] d... 651.358653: sys_write: (SyS_write+0x0/0xc8) count=86
>
> Signed-off-by: He Kuang <hekuang@xxxxxxxxxx>
> ---
>  tools/perf/arch/arm64/include/dwarf-regs-table.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/arch/arm64/include/dwarf-regs-table.h b/tools/perf/arch/arm64/include/dwarf-regs-table.h
> index 2675936..36e375f 100644
> --- a/tools/perf/arch/arm64/include/dwarf-regs-table.h
> +++ b/tools/perf/arch/arm64/include/dwarf-regs-table.h
> @@ -2,12 +2,12 @@
>  /* This is included in perf/util/dwarf-regs.c */
>
>  static const char * const aarch64_regstr_tbl[] = {
> -       "%r0", "%r1", "%r2", "%r3", "%r4",
> -       "%r5", "%r6", "%r7", "%r8", "%r9",
> -       "%r10", "%r11", "%r12", "%r13", "%r14",
> -       "%r15", "%r16", "%r17", "%r18", "%r19",
> -       "%r20", "%r21", "%r22", "%r23", "%r24",
> -       "%r25", "%r26", "%r27", "%r28", "%r29",
> +       "%x0", "%x1", "%x2", "%x3", "%x4",
> +       "%x5", "%x6", "%x7", "%x8", "%x9",
> +       "%x10", "%x11", "%x12", "%x13", "%x14",
> +       "%x15", "%x16", "%x17", "%x18", "%x19",
> +       "%x20", "%x21", "%x22", "%x23", "%x24",
> +       "%x25", "%x26", "%x27", "%x28", "%x29",
>         "%lr", "%sp",
>  };
>  #endif
> --
> 1.8.5.2
>



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]