# `MaeBPF.Diagnostics`
[🔗](https://github.com/cocoa-xu/MaeBPF/blob/v0.1.0/maebpf/lib/maebpf/diagnostics.ex#L1)

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`.

# `format_verifier_error`

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`

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`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
