Skip to content

Commit

Permalink
bpftool: Fix bug for long instructions in program CFG dumps
Browse files Browse the repository at this point in the history
When dumping the control flow graphs for programs using the 16-byte long
load instruction, we need to skip the second part of this instruction
when looking for the next instruction to process. Otherwise, we end up
printing "BUG_ld_00" from the kernel disassembler in the CFG.

Fixes: efcef17 ("tools: bpftool: generate .dot graph from CFG information")
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/r/20230405132120.59886-3-quentin@isovalent.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Quentin Monnet authored and Alexei Starovoitov committed Apr 6, 2023
1 parent e27f0f1 commit 67cf52c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/bpf/bpftool/xlated_dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,15 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end,
struct bpf_insn *insn_start = buf_start;
struct bpf_insn *insn_end = buf_end;
struct bpf_insn *cur = insn_start;
bool double_insn = false;

for (; cur <= insn_end; cur++) {
if (double_insn) {
double_insn = false;
continue;
}
double_insn = cur->code == (BPF_LD | BPF_IMM | BPF_DW);

printf("% 4d: ", (int)(cur - insn_start + start_idx));
print_bpf_insn(&cbs, cur, true);
if (cur != insn_end)
Expand Down

0 comments on commit 67cf52c

Please sign in to comment.