aboutsummaryrefslogtreecommitdiff
path: root/tools/bpf/bpftool/cfg.h
AgeCommit message (Collapse)AuthorFilesLines
2023-04-05bpftool: Support printing opcodes and source file references in CFGQuentin Monnet1-1/+2
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. The filepaths in the records are absolute. To avoid blocks on the graph to get too wide, we truncate them when they get too long (but we always keep the entire file name). In the unlikely case where the resulting file name is ambiguous, it remains possible to get the full path with a regular dump (no CFG). Signed-off-by: Quentin Monnet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
2023-04-05bpftool: Support inline annotations when dumping the CFG of a programQuentin Monnet1-1/+3
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
2018-12-13tools: bpftool: replace Netronome boilerplate with SPDX license headersJakub Kicinski1-35/+1
Replace the repeated license text with SDPX identifiers. Signed-off-by: Jakub Kicinski <[email protected]> Acked-by: Roman Gushchin <[email protected]> Acked-by: YueHaibing <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Acked-by: Sean Young <[email protected]> Acked-by: Jiri Benc <[email protected]> Acked-by: David Calavera <[email protected]> Acked-by: Andrey Ignatov <[email protected]> Acked-by: Joe Stringer <[email protected]> Acked-by: David Ahern <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Acked-by: Petar Penkov <[email protected]> Acked-by: Sandipan Das <[email protected]> Acked-by: Prashant Bhole <[email protected]> Acked-by: Stephen Hemminger <[email protected]> Acked-by: John Fastabend <[email protected]> Acked-by: Taeung Song <[email protected]> Acked-by: Jiri Olsa <[email protected]> Acked-by: Daniel Borkmann <[email protected]> CC: [email protected] Signed-off-by: Daniel Borkmann <[email protected]>
2018-12-13tools: bpftool: fix SPDX format in headersJakub Kicinski1-1/+1
Documentation/process/license-rules.rst sayeth: 2. Style: The SPDX license identifier is added in form of a comment. The comment style depends on the file type:: C source: // SPDX-License-Identifier: <SPDX License Expression> C header: /* SPDX-License-Identifier: <SPDX License Expression> */ Headers should use C comment style. Signed-off-by: Jakub Kicinski <[email protected]> Acked-by: Roman Gushchin <[email protected]> Acked-by: YueHaibing <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Acked-by: Sean Young <[email protected]> Acked-by: Jiri Benc <[email protected]> Acked-by: David Calavera <[email protected]> Acked-by: Andrey Ignatov <[email protected]> Acked-by: Joe Stringer <[email protected]> Acked-by: David Ahern <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Acked-by: Petar Penkov <[email protected]> Acked-by: Sandipan Das <[email protected]> Acked-by: Prashant Bhole <[email protected]> Acked-by: Stephen Hemminger <[email protected]> Acked-by: John Fastabend <[email protected]> Acked-by: Taeung Song <[email protected]> Acked-by: Jiri Olsa <[email protected]> Acked-by: Daniel Borkmann <[email protected]> CC: [email protected] Signed-off-by: Daniel Borkmann <[email protected]>
2018-03-01tools: bpftool: detect sub-programs from the eBPF sequenceJiong Wang1-0/+43
This patch detect all sub-programs from the eBPF sequence and keep the information in the new CFG data structure. The detection algorithm is basically the same as the one in verifier except we need to use insn->off instead of insn->imm to get the pc-relative call offset. Because verifier has modified insn->off/insn->imm during finishing the verification. Also, we don't need to do some sanity checks as verifier has done them. Signed-off-by: Jiong Wang <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]>