perf probe: Trying to read a 'ctx' named local variable
Hi Masami,
Trying to use perf to debug perf I stumbled on this:
[root@quaco ~]# perf probe -x ~/bin/perf -L sigtrap_handler <sigtrap_handler@/home/acme/git/perf-tools/tools/perf/tests/sigtrap.c:0>
0 sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused)
{
if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED))
3 ctx.first_siginfo = *info;
4 __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED);
}
static void *test_thread(void *arg)[root@quaco ~]# perf probe -x ~/bin/perf sigtrap_handler:4 "ctx.signal_count" Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature @ctx
Error: Failed to add events.
[root@quaco ~]#
[root@quaco ~]# uname -a
Linux quaco 6.3.8-100.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 15 01:51:54 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux [root@quaco ~]# rpm -qa | grep kernel-debuginfo kernel-debuginfo-common-x86_64-6.3.8-100.fc37.x86_64
kernel-debuginfo-6.3.8-100.fc37.x86_64
[root@quaco ~]#
Signature · 1 line
- Arnaldo
Quoted 15 lines · On Mon, 17 Jul 2023 15:06:10 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Hi Masami,
Trying to use perf to debug perf I stumbled on this:
[root@quaco ~]# perf probe -x ~/bin/perf -L
sigtrap_handler<sigtrap_handler@/home/acme/git/perf-tools/tools/perf/tests/sigtrap.c:0>0 sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused) { if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED)) 3 ctx.first_siginfo = *info; 4 __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED); } static void *test_thread(void *arg)
Quoted 5 lines
[root@quaco ~]# perf probe -x ~/bin/perf sigtrap_handler:4 "ctx.signal_count" Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature @ctx
Error: Failed to add events.
[root@quaco ~]#
Ah, this is a wrong usage (I'm also trapped the same thing). Correctly, it should pass it as a single parameter.
perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count"
This is for adding several events at the same time. But now it becomes just a trap. Can I change the syntax from
perf probe [OPTIONS] <PROBE-DEFINITION> [PROBE-DEFINITION...]
To,
perf probe [OPTIONS] <PROBE-POINT> [ARGS...]
?
We can keep --add having optional parameter as below.
perf probe [OPTIONS] --add <PROBE-DEFINITION>
Thank you,
Quoted 11 lines
[root@quaco ~]# uname -a
Linux quaco 6.3.8-100.fc37.x86_64 #1 SMPPREEMPT_DYNAMICThu Jun 15 01:51:54 UTC 2023x86_64x86_64x86_64GNU/Linux [root@quaco ~]# rpm -qa | grep kernel-debuginfo kernel-debuginfo-common-x86_64-6.3.8-100.fc37.x86_64
kernel-debuginfo-6.3.8-100.fc37.x86_64
[root@quaco ~]#Signature · 1 line
- Arnaldo
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Em Tue, Jul 18, 2023 at 08:54:51AM +0900, Masami Hiramatsu escreveu:
Quoted 24 lines
Quoted 15 lines · On Mon, 17 Jul 2023 15:06:10 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Hi Masami,
Trying to use perf to debug perf I stumbled on this:
[root@quaco ~]# perf probe -x ~/bin/perf -L
sigtrap_handler<sigtrap_handler@/home/acme/git/perf-tools/tools/perf/tests/sigtrap.c:0>0 sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused) { if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED)) 3 ctx.first_siginfo = *info; 4 __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED); } static void *test_thread(void *arg)Quoted 5 lines
[root@quaco ~]# perf probe -x ~/bin/perf sigtrap_handler:4 "ctx.signal_count" Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature @ctx
Error: Failed to add events.
[root@quaco ~]#
Quoted 4 lines
Ah, this is a wrong usage (I'm also trapped the same thing). Correctly, it should pass it as a single parameter.
perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count"
[root@five ~]# perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count" Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature @ctx
Error: Failed to add events.
[root@five ~]#
Didn't work?
- Arnaldo
Quoted 32 lines
This is for adding several events at the same time. But now it becomes just a trap. Can I change the syntax from
perf probe [OPTIONS] <PROBE-DEFINITION> [PROBE-DEFINITION...]
To,
perf probe [OPTIONS] <PROBE-POINT> [ARGS...]
?
We can keep --add having optional parameter as below.
perf probe [OPTIONS] --add <PROBE-DEFINITION>
Thank you,
Quoted 11 lines
[root@quaco ~]# uname -a
Linux quaco 6.3.8-100.fc37.x86_64 #1 SMPPREEMPT_DYNAMICThu Jun 15 01:51:54 UTC 2023x86_64x86_64x86_64GNU/Linux [root@quaco ~]# rpm -qa | grep kernel-debuginfo kernel-debuginfo-common-x86_64-6.3.8-100.fc37.x86_64
kernel-debuginfo-6.3.8-100.fc37.x86_64
[root@quaco ~]#Signature · 1 line
- ArnaldoSignature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
- Arnaldo
Quoted 30 lines · On Thu, 20 Jul 2023 11:40:42 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Tue, Jul 18, 2023 at 08:54:51AM +0900, Masami Hiramatsu escreveu:
Quoted 24 lines
Quoted 15 lines · On Mon, 17 Jul 2023 15:06:10 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Hi Masami,
Trying to use perf to debug perf I stumbled on this:
[root@quaco ~]# perf probe -x ~/bin/perf -L
sigtrap_handler<sigtrap_handler@/home/acme/git/perf-tools/tools/perf/tests/sigtrap.c:0>0 sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __maybe_unused) { if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED)) 3 ctx.first_siginfo = *info; 4 __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED); } static void *test_thread(void *arg)Quoted 5 lines
[root@quaco ~]# perf probe -x ~/bin/perf sigtrap_handler:4 "ctx.signal_count" Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature @ctx
Error: Failed to add events.
[root@quaco ~]#Quoted 4 lines
Ah, this is a wrong usage (I'm also trapped the same thing). Correctly, it should pass it as a single parameter.
perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count"
Quoted 7 lines
[root@five ~]# perf probe -x ~/bin/perf "sigtrap_handler:4 ctx.signal_count" Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature @ctx
Error: Failed to add events.
[root@five ~]#Didn't work?
Ah, I got it. The error message is wrong.
/sys/kernel/debug/tracing# cat error_log
[122869.758693] trace_uprobe: error: Symbol is not available with uprobe
Command: p:probe_perf/sigtrap_handler_L4 /usr/local/bin/perf:0xfc8e9 signal_count=@ctx+4:s32
^"ctx" is not a local variable in this context and @ctx (global variable) is not accessible from uprobe events.
Hmm, it must be checked while parsing the debuginfo.
Thank you,
Quoted 39 lines
- Arnaldo
Quoted 32 lines
This is for adding several events at the same time. But now it becomes just a trap. Can I change the syntax from
perf probe [OPTIONS] <PROBE-DEFINITION> [PROBE-DEFINITION...]
To,
perf probe [OPTIONS] <PROBE-POINT> [ARGS...]
?
We can keep --add having optional parameter as below.
perf probe [OPTIONS] --add <PROBE-DEFINITION>
Thank you,
Quoted 11 lines
[root@quaco ~]# uname -a
Linux quaco 6.3.8-100.fc37.x86_64 #1 SMPPREEMPT_DYNAMICThu Jun 15 01:51:54 UTC 2023x86_64x86_64x86_64GNU/Linux [root@quaco ~]# rpm -qa | grep kernel-debuginfo kernel-debuginfo-common-x86_64-6.3.8-100.fc37.x86_64
kernel-debuginfo-6.3.8-100.fc37.x86_64
[root@quaco ~]#Signature · 1 line
- ArnaldoSignature · 1 line
Masami Hiramatsu (Google) <[email protected]>Signature · 1 line
- Arnaldo
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>