joelagnel / adeb

A debian-based shell environment designed for Android and adb
Apache License 2.0
318 stars 98 forks source link

CONFIG_BPF_SYSCALL is undefined #10

Closed Linuxuser4 closed 5 years ago

Linuxuser4 commented 6 years ago

Hi, I am trying to get adeb-BCC working on a Hikey970 android platform. This has 4.9 kernel flashed. I got the BCC compiled in adeb environment. I built the kernel with required configurations enabled in kernel as per the page https://github.com/joelagnel/adeb/blob/master/BCC.md. I made sure CONFIG_BPF_SYSCALL is enabled by putting a kernel print. But, any BCC tool I use including hello_world.py complains that CONFIG_BPF_SYSCALL is not enabled. Below is detailed log. Any pointers would be of great help !

root@localhost:/# /usr/share/bcc/examples/hello_world.py In file included from :3: /virtual/include/bcc/helpers.h:26:2: error: "CONFIG_BPF_SYSCALL is undefined, please check your .config or ask your Linux distro to enable this feature"

error "CONFIG_BPF_SYSCALL is undefined, please check your .config or ask your Linux distro to enable this feature"

^ 1 error generated. Traceback (most recent call last): File "/usr/share/bcc/examples/hello_world.py", line 12, in BPF(text='int kprobesys_clone(void *ctx) { bpf_trace_printk("Hello, World!\n"); return 0; }').trace_print() File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 318, in init__ raise Exception("Failed to compile BPF text") Exception: Failed to compile BPF text root@localhost:/#

joelagnel commented 6 years ago

You need CONFIG_BPF_SYSCALL enabled and your kernel re-built with that, as the error message says.

On Thu, Aug 2, 2018 at 2:52 AM, Linuxuser4 notifications@github.com wrote:

Hi, I am trying to get adeb-BCC working on a Hikey970 android platform. This has 4.9 kernel flashed. I got the BCC compiled in adeb environment. I built the kernel with required configurations enabled in kernel as per the page https://github.com/joelagnel/adeb/blob/master/BCC.md. I made sure CONFIG_BPF_SYSCALL is enabled by putting a kernel print. But, any BCC tool I use including hello_world.py complains that CONFIG_BPF_SYSCALL is not enabled. Below is detailed log. Any pointers would be of great help !

root@localhost:/# /usr/share/bcc/examples/hello_world.py In file included from :3: /virtual/include/bcc/helpers.h:26:2: error: "CONFIG_BPF_SYSCALL is undefined, please check your .config or ask your Linux distro to enable this feature"

error "CONFIG_BPF_SYSCALL is undefined, please check your .config or ask

your Linux distro to enable this feature" ^ 1 error generated. Traceback (most recent call last): File "/usr/share/bcc/examples/hello_world.py", line 12, in BPF(text='int kprobe__sys_clone(void ctx) { bpf_trace_printk("Hello, World!\n"); return 0; }').trace_print() File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 318, in init* raise Exception("Failed to compile BPF text") Exception: Failed to compile BPF text root@localhost:/#

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joelagnel/adeb/issues/10, or mute the thread https://github.com/notifications/unsubscribe-auth/AACSVLzy_qMiPtLnP3DIi6S1jg63LwRpks5uMsvIgaJpZM4Vr-iW .

Linuxuser4 commented 6 years ago

I realized the mistake. Original kernel headers on target did not have CONFIG_BPF_SYSCALL enabled. I then flashed new kernel with CONFIG_BPF_SYSCALL. I had failed to update the kernel headers using adeb prepare. I had to remove adeb and reinstall adeb with new kernel path. This makes sure new kernel headers are updated on target. Even though new kernel is flashed, header also needs to be updated in androdeb in target.

I could get filetop (and a few other) command(s) working, though hello_world.py hangs. If I try to quit, it displays following message. It may not be of much consequence, though I wished this basic command to work. root@localhost:/bcc-master# /usr/share/bcc/examples/hello_world.py ^CTraceback (most recent call last): File "/usr/share/bcc/examples/hello_world.py", line 12, in BPF(text='int kprobesys_clone(void *ctx) { bpf_trace_printk("Hello, World!\n"); return 0; }').trace_print() File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 1119, in trace_print line = self.trace_readline(nonblocking=False) File "/usr/lib/python2.7/dist-packages/bcc/init__.py", line 1099, in trace_readline line = trace.readline(1024).rstrip() KeyboardInterrupt root@localhost:/bcc-master#

Linuxuser4 commented 6 years ago

Also, by default, bcc native compilation on target board failed. I made following 2 changes for successful compilation on target. Thought of letting you know:

  1. A softlink to stdc++ was required since compilation complained of missing stdc++ library. ln -s /usr/lib/gcc/aarch64-linux-gnu/7/libstdc++.so /usr/lib/libstdc++.so

  2. Two include paths needed to be provided to avoid missing header error. These were added in CMakeLists.txt in the base folder: include_directories(/usr/include/c++/7/) include_directories(/usr/include/aarch64-linux-gnu/c++/7/)

joelagnel commented 5 years ago

Feel free to follow up with this on BCC's issue list, or send a patch there if you feel something needs fixing there, your contribution there and here are appreciated! Closing this for now.

CodeForeverZou commented 3 years ago

uname -r get the system kernel version, if different with the built kernel version. you need to build the kernel which same with the 'uname -r'