()
| 9 | ) |
| 10 | |
| 11 | func DocLoadCollectionSpec() { |
| 12 | // Parse an ELF into a CollectionSpec. |
| 13 | // bpf_prog.o is the result of compiling BPF C code. |
| 14 | spec, err := ebpf.LoadCollectionSpec("bpf_prog.o") |
| 15 | if err != nil { |
| 16 | panic(err) |
| 17 | } |
| 18 | |
| 19 | // Look up the MapSpec and ProgramSpec in the CollectionSpec. |
| 20 | m := spec.Maps["my_map"] |
| 21 | p := spec.Programs["my_prog"] |
| 22 | // Note: We've omitted nil checks for brevity, take a look at |
| 23 | // LoadAndAssign for an automated way of checking for maps/programs. |
| 24 | |
| 25 | // Inspect the map and program type. |
| 26 | fmt.Println(m.Type, p.Type) |
| 27 | |
| 28 | // Print the map's key and value BTF types. |
| 29 | fmt.Println(m.Key, m.Value) |
| 30 | |
| 31 | // Print the program's instructions in a human-readable form, |
| 32 | // similar to llvm-objdump -S. |
| 33 | fmt.Println(p.Instructions) |
| 34 | } |
| 35 | |
| 36 | func DocNewCollection() { |
| 37 | spec, err := ebpf.LoadCollectionSpec("bpf_prog.o") |
nothing calls this directly
no test coverage detected
searching dependent graphs…