Skip to content

bpftool: fix line info offsets in CFG dump - #299

Open
sairex53 wants to merge 1 commit into
libbpf:mainfrom
sairex53:codex/issue-178-cfg-linfo-offset
Open

sairex53 wants to merge 1 commit into
libbpf:mainfrom
sairex53:codex/issue-178-cfg-linfo-offset

Conversation

@sairex53

Copy link
Copy Markdown

Summary

When bpftool prog dump xlated renders a visual CFG, line-info lookup for a basic block in a subprogram uses an offset relative to that function. bpf_prog_linfo__lfind() expects an offset relative to the whole program, so the graph can show source annotations from the wrong function.

Pass the original program instruction base through the CFG dumper and use the whole-program offset for line-info lookup and displayed instruction numbers. Keep the function-relative offset used for BTF function-info records.

Fixes #178.

Testing

  • make -C src -j2
  • git diff --check
  • Offline regression harness with two functions and line-info entries at offsets 0 and 4: the patched code selects each function’s annotation; the same scenario fails against the pre-fix code.

Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix inline annotations in generated control-flow graphs for programs with multiple functions

1 participant