[PATCH V3 0/3] eBPF support

Daniel Xu dxu@dxuuu.xyz
Fri Jul 3 20:37:40 GMT 2020


Hi Jose,

On Fri Jul 3, 2020 at 5:46 AM PDT, Jose E. Marchesi via Gdb-patches wrote:
> [Changes from V2:
> - Urgh, V2 contained a patch still too big for mailman. In this
> version I am splitting the simulator part in two commits. Thunks
> for fully generated configure files are still removed.]
>
> Hi good peoples!
>
> This patch series adds support for the eBPF virtual architecture to
> GDB [1].
>
> The first patch contains the basic bits to GDB in order to support the
> bpf-unknown-none target. Breakpointing and instruction
> single-stepping works, but the debugging support in eBPF is still very
> minimal. This is mainly due to the many limitations imposed by the
> architecture (disjoint stack, maximum stack size, etc). We are
> working to overcome these limitations, by introducing a variant called
> xbpf, already supported in GCC with the -mxbpf option, whose purpose
> is to ease debugging and to be used in other contexts different than
> the Linux kernel, less restrictive.
>
> The second patch adds a basic CGEN-based instruction simulator for
> eBPF. It can run many eBPF programs and works well with GDB. A
> testsuite covering the supported instructions is also included. We
> will be expanding it in order to emulate the several kernel contexts
> in which eBPF programs can run, so eBPF developers can use GDB to
> debug their programs without having to load them in a running kernel.
> Currently the only kernel helper implemented in the simulator is
> printk, which is used by the tests.
>
> We of course commit to maintain and evolve this stuff :)
>
> [1] Support for eBPF has been already added to both binutils and GCC.

This is quite exciting for bpf developers.

Are there any instructions on how to test this out? Here's what I've
tried so far after I applied your patches:

    (gdb) file ~/dev/libbpf-rs/target/bpf/runqslower.bpf.o
    Reading symbols from ~/dev/libbpf-rs/target/bpf/runqslower.bpf.o...

    (gdb) run
    Starting program: /home/daniel/dev/libbpf-rs/target/bpf/runqslower.bpf.o
    zsh:1: permission denied: /home/daniel/dev/libbpf-rs/target/bpf/runqslower.bpf.o
    During startup program exited with code 126.

    (gdb) info file
    Symbols from "/home/daniel/dev/libbpf-rs/target/bpf/runqslower.bpf.o".
    Local exec file:
            `/home/daniel/dev/libbpf-rs/target/bpf/runqslower.bpf.o', file type elf64-little.
            Entry point: 0x0
            0x00000000 - 0x00000000 is .text
            0x00000000 - 0x00000080 is tp_btf/sched_wakeup
            0x00000080 - 0x00000100 is tp_btf/sched_wakeup_new
            0x00000100 - 0x00000348 is tp_btf/sched_switch
            0x00000348 - 0x000003a0 is .maps
            0x000003a0 - 0x000003a4 is license

The program I'm trying to "debug" can be found here:
https://github.com/libbpf/libbpf-rs/tree/master/example

[...]

Thanks,
Daniel


More information about the Gdb-patches mailing list