osandov / drgn

Programmable debugger
Other
1.78k stars 165 forks source link

contrib/bpf_inspect.py: abstract bpf classes #406

Closed Asphaltt closed 5 months ago

Asphaltt commented 5 months ago

Abstract bpf classes and do some enhancement.

I've test it on 6.8 and 5.15 kernels.

Here's the enhanced result:

$ sudo drgn ./contrib/bpf_inspect.py p
     2: BPF_PROG_TYPE_TRACING            hid_tail_call
  2295: BPF_PROG_TYPE_EXT                entry                            tail_call_reachable
  2400: BPF_PROG_TYPE_EXT                entry                            tail_call_reachable

$ sudo drgn ./contrib/bpf_inspect.py m --show-details
  5108: BPF_MAP_TYPE_PROG_ARRAY          prog_array
    owner:    BPF_PROG_TYPE_KPROBE             JITed
    idx[  0]:   4250: BPF_PROG_TYPE_KPROBE             k_tailcall
    poke:       4249: BPF_PROG_TYPE_KPROBE             k_icsk_complete_hashdance        tail_call_reachable
    poke:       4251: BPF_PROG_TYPE_KPROBE             k_tcp_connect                    tail_call_reachable

$ sudo drgn ./contrib/bpf_inspect.py l --show-details
     1: BPF_LINK_TYPE_TRACING
    prog:        2: BPF_PROG_TYPE_TRACING            hid_tail_call
    attach:   __hid_bpf_tail_call
  1211: BPF_LINK_TYPE_TRACING
    prog:     4239: BPF_PROG_TYPE_TRACING            fentry_tc
    attach:   entry1
    target:   4235: BPF_PROG_TYPE_SCHED_CLS          entry1
  1212: BPF_LINK_TYPE_TRACING
    prog:     4240: BPF_PROG_TYPE_TRACING            fexit_tc
    attach:   entry1
    target:   4235: BPF_PROG_TYPE_SCHED_CLS          entry1
  1217: BPF_LINK_TYPE_TRACING
    prog:     4252: BPF_PROG_TYPE_TRACING            fentry_freplace_handler
    attach:   stub_handler
    target:   4251: BPF_PROG_TYPE_KPROBE             k_tcp_connect                    tail_call_reachable
  1218: BPF_LINK_TYPE_TRACING
    prog:     4253: BPF_PROG_TYPE_TRACING            fexit_freplace_handler
    attach:   stub_handler
    target:   4251: BPF_PROG_TYPE_KPROBE             k_tcp_connect                    tail_call_reachable
  1219: BPF_LINK_TYPE_PERF_EVENT
    prog:     4251: BPF_PROG_TYPE_KPROBE             k_tcp_connect                    tail_call_reachable
  1220: BPF_LINK_TYPE_PERF_EVENT
    prog:     4249: BPF_PROG_TYPE_KPROBE             k_icsk_complete_hashdance        tail_call_reachable
osandov commented 5 months ago

Thanks again!