New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpftool: Add inline annotations when dumping program CFGs #4817
Conversation
Upstream branch: 55fbae0 |
49e25e4
to
fe39b7b
Compare
Upstream branch: 496f4f1 |
f60ea3a
to
5a560cc
Compare
fe39b7b
to
64a47ba
Compare
Upstream branch: e993607 |
5a560cc
to
61fc0ae
Compare
64a47ba
to
88b3244
Compare
Upstream branch: 8d27596 |
61fc0ae
to
4fd3daa
Compare
88b3244
to
38702e7
Compare
Upstream branch: 8d27596 |
4fd3daa
to
56375f7
Compare
38702e7
to
10fd22a
Compare
Upstream branch: 8cfee11 |
56375f7
to
0bfaa8a
Compare
10fd22a
to
83306f4
Compare
Upstream branch: 5f5a7d8 |
0bfaa8a
to
032b612
Compare
Upstream branch: 5f5a7d8 |
032b612
to
de9b0e9
Compare
83306f4
to
bc844fe
Compare
Upstream branch: f1cb927 |
de9b0e9
to
6c8fc13
Compare
bc844fe
to
f8769a2
Compare
Upstream branch: 7283137 |
6c8fc13
to
bde71f2
Compare
f8769a2
to
93667d1
Compare
The documentation states that when line_info is available when dumping a program, the source line will be displayed "by default". There is no notion of "default" here: the line is always displayed if available, there is no way currently to turn it off. In the next sentence, the documentation states that if "linum" is used on the command line, the relevant filename, line, and column will be displayed "on top of the source line". This is incorrect, as they are currently displayed on the right side of the source line (or on top of the eBPF instruction, not the source). This commit fixes the documentation to address these points. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Acked-by: Stanislav Fomichev <sdf@google.com>
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> Acked-by: Stanislav Fomichev <sdf@google.com>
We support dumping the control flow graph of loaded programs to the DOT format with bpftool, but so far this feature wouldn't display the source code lines available through BTF along with the eBPF bytecode. Let's add support for these annotations, to make it easier to read the graph. In prog.c, we move the call to dump_xlated_cfg() in order to pass and use the full struct dump_data, instead of creating a minimal one in draw_bb_node(). We pass the pointer to this struct down to dump_xlated_for_graph() in xlated_dumper.c, where most of the logics is added. We deal with BTF mostly like we do for plain or JSON output, except that we cannot use a "nr_skip" value to skip a given number of linfo records (we don't process the BPF instructions linearly, and apart from the root of the graph we don't know how many records we should skip, so we just store the last linfo and make sure the new one we find is different before printing it). When printing the source instructions to the label of a DOT graph node, there are a few subtleties to address. We want some special newline markers, and there are some characters that we must escape. To deal with them, we introduce a new dedicated function btf_dump_linfo_dotlabel() in btf_dumper.c. We'll reuse this function in a later commit to format the filepath, line, and column references as well. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Acked-by: Stanislav Fomichev <sdf@google.com>
Upstream branch: d08ab82 |
When dumping a program, the keywords "opcodes" (for printing the raw opcodes), "linum" (for displaying the filename, line number, column number along with the source code), and "visual" (for generating the control flow graph for translated programs) are mutually exclusive. But there's no reason why they should be. Let's make it possible to pass several of them at once. The "file FILE" option, which makes bpftool output a binary image to a file, remains incompatible with the others. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Acked-by: Stanislav Fomichev <sdf@google.com>
Add support for displaying opcodes or/and file references (filepath, line and column numbers) when dumping the control flow graphs of loaded BPF programs with bpftool. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Acked-by: Stanislav Fomichev <sdf@google.com>
bde71f2
to
b8dd62c
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=734111 expired. Closing PR. |
Pull request for series with
subject: bpftool: Add inline annotations when dumping program CFGs
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=733732