You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to reproduce open_perf_output.py on my ubuntu, something wrong occured. I can't find anyone else who meets the same problem on Google, so maybe somebody here can help me?
My python version is 3.8.10 and ubuntu version is 20.04. Here is the code:
This error will occur unless I add uapi/linux/ptrace.h and linux/sched.h to the prog. Here is the error info:
`/virtual/main.c:28:35: error: incomplete definition of type 'struct pt_regs'
const char __user *filename = ctx->di; int flags = ctx->si;
~~~^
/virtual/include/bcc/helpers.h:1194:8: note: forward declaration of 'struct pt_regs'
struct pt_regs;
^
/virtual/main.c:28:56: error: incomplete definition of type 'struct pt_regs'
const char __user *filename = ctx->di; int flags = ctx->si;
~~~^
/virtual/include/bcc/helpers.h:1194:8: note: forward declaration of 'struct pt_regs'
struct pt_regs;
^
2 errors generated.
Traceback (most recent call last):
File "/home/wch/Desktop/perf.py", line 42, in <module>
b = BPF(text=prog)
File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 475, in __init__
raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>`
And after I add these headers, the code can be compiled but still can't get the correct result. It will be blocked at b.perf_buffer_poll() . At the same time opensnoop.py can work normally.
What's more, when I change b.attach_kprobe(event=b.get_syscall_fnname("open"), fn_name="trace_syscall_open") to b.attach_kprobe(event=b.get_syscall_fnname("read"), fn_name="trace_syscall_open"), it can work but can't out put the right event.fname.
-------------------------------------------------------------------------3.10---------------------------------------------------------------
I solve this problem by replacing event=b.get_syscall_fnname("open") with event="do_sys_open" , because I find when using b.get_syscall_fnname("open") the result is '__x64_sys_open'. Maybe it can't work when using a wrong parameter?I'm still confused.
The text was updated successfully, but these errors were encountered:
When I try to reproduce open_perf_output.py on my ubuntu, something wrong occured. I can't find anyone else who meets the same problem on Google, so maybe somebody here can help me?
My python version is 3.8.10 and ubuntu version is 20.04. Here is the code:
This error will occur unless I add uapi/linux/ptrace.h and linux/sched.h to the prog. Here is the error info:
And after I add these headers, the code can be compiled but still can't get the correct result. It will be blocked at b.perf_buffer_poll() . At the same time opensnoop.py can work normally.
What's more, when I change b.attach_kprobe(event=b.get_syscall_fnname("open"), fn_name="trace_syscall_open") to b.attach_kprobe(event=b.get_syscall_fnname("read"), fn_name="trace_syscall_open"), it can work but can't out put the right event.fname.
-------------------------------------------------------------------------3.10---------------------------------------------------------------
I solve this problem by replacing
event=b.get_syscall_fnname("open")
withevent="do_sys_open"
, because I find when usingb.get_syscall_fnname("open")
the result is'__x64_sys_open'
. Maybe it can't work when using a wrong parameter?I'm still confused.The text was updated successfully, but these errors were encountered: