MaeBPF.Diagnostics (maebpf v0.1.0)

Copy Markdown View Source

Source-mapped Linux eBPF verifier error diagnostics.

Parses instruction indices (N: (op) ..., insn N, insn #N, from A to B) from Linux kernel verifier logs and annotates them with the originating Elixir MaeBPF.Plug module, file:line, and operation description recorded by MaeBPF.Compiler.Pure.compile_ir/2.

Summary

Functions

Formats a Linux kernel eBPF verifier log by mapping instruction offsets back to their originating Elixir MaeBPF.Plug module, source file, and line.

Looks up an instruction offset in a single-program or multi-program source_map (or a use MaeBPF module atom).

Extracts all instruction offsets mentioned in a kernel verifier log string, in order of appearance.

Functions

format_verifier_error(verifier_log, source_map, opts \\ [])

Formats a Linux kernel eBPF verifier log by mapping instruction offsets back to their originating Elixir MaeBPF.Plug module, source file, and line.

source_map may be:

  • A single program map %{insn_idx => %{plug: ..., file: ..., line: ..., desc: ...}}
  • A multi-program map %{prog_c_name => %{insn_idx => ...}} (pass program: name to select a specific program)
  • A use MaeBPF module atom

locate_insn(source_map_or_mod, insn_idx, opts \\ [])

Looks up an instruction offset in a single-program or multi-program source_map (or a use MaeBPF module atom).

Returns {:ok, %{program: prog_name, insn: idx, plug: mod, file: file, line: line, desc: desc}} or :error.

parse_verifier_insns(verifier_log)

Extracts all instruction offsets mentioned in a kernel verifier log string, in order of appearance.