diff options
author | Jiong Wang <jiong.wang@netronome.com> | 2018-03-02 03:01:22 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-03-02 03:29:49 +0100 |
commit | b6c1cedb4935a99d315827b990b23230b0eb13f5 (patch) | |
tree | ab0563997516af5ad94d5d79fd3f48e916a51d52 /tools/bpf/bpftool/prog.c | |
parent | tools: bpftool: generate .dot graph from CFG information (diff) | |
download | linux-b6c1cedb4935a99d315827b990b23230b0eb13f5.tar.xz linux-b6c1cedb4935a99d315827b990b23230b0eb13f5.zip |
tools: bpftool: new command-line option and documentation for 'visual'
This patch adds new command-line option for visualizing the xlated eBPF
sequence.
Documentations are updated accordingly.
Usage:
bpftool prog dump xlated id 2 visual
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
-rw-r--r-- | tools/bpf/bpftool/prog.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index c5afee9838e6..f7a810897eac 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -47,6 +47,7 @@ #include <bpf.h> #include <libbpf.h> +#include "cfg.h" #include "main.h" #include "xlated_dumper.h" @@ -415,6 +416,7 @@ static int do_dump(int argc, char **argv) unsigned int buf_size; char *filepath = NULL; bool opcodes = false; + bool visual = false; unsigned char *buf; __u32 *member_len; __u64 *member_ptr; @@ -453,6 +455,9 @@ static int do_dump(int argc, char **argv) } else if (is_prefix(*argv, "opcodes")) { opcodes = true; NEXT_ARG(); + } else if (is_prefix(*argv, "visual")) { + visual = true; + NEXT_ARG(); } if (argc) { @@ -536,6 +541,11 @@ static int do_dump(int argc, char **argv) } disasm_print_insn(buf, *member_len, opcodes, name); + } else if (visual) { + if (json_output) + jsonw_null(json_wtr); + else + dump_xlated_cfg(buf, *member_len); } else { kernel_syms_load(&dd); if (json_output) @@ -596,7 +606,7 @@ static int do_help(int argc, char **argv) fprintf(stderr, "Usage: %s %s { show | list } [PROG]\n" - " %s %s dump xlated PROG [{ file FILE | opcodes }]\n" + " %s %s dump xlated PROG [{ file FILE | opcodes | visual }]\n" " %s %s dump jited PROG [{ file FILE | opcodes }]\n" " %s %s pin PROG FILE\n" " %s %s load OBJ FILE\n" |