diff options
author | Jiong Wang <jiong.wang@netronome.com> | 2018-03-01 21:01:22 -0500 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-03-01 21:29:49 -0500 |
commit | b6c1cedb4935a99d315827b990b23230b0eb13f5 (patch) | |
tree | ab0563997516af5ad94d5d79fd3f48e916a51d52 /tools/bpf/bpftool/prog.c | |
parent | efcef17a6d6575dacca22bce69e139354c5a2170 (diff) |
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 @@ | |||
47 | #include <bpf.h> | 47 | #include <bpf.h> |
48 | #include <libbpf.h> | 48 | #include <libbpf.h> |
49 | 49 | ||
50 | #include "cfg.h" | ||
50 | #include "main.h" | 51 | #include "main.h" |
51 | #include "xlated_dumper.h" | 52 | #include "xlated_dumper.h" |
52 | 53 | ||
@@ -415,6 +416,7 @@ static int do_dump(int argc, char **argv) | |||
415 | unsigned int buf_size; | 416 | unsigned int buf_size; |
416 | char *filepath = NULL; | 417 | char *filepath = NULL; |
417 | bool opcodes = false; | 418 | bool opcodes = false; |
419 | bool visual = false; | ||
418 | unsigned char *buf; | 420 | unsigned char *buf; |
419 | __u32 *member_len; | 421 | __u32 *member_len; |
420 | __u64 *member_ptr; | 422 | __u64 *member_ptr; |
@@ -453,6 +455,9 @@ static int do_dump(int argc, char **argv) | |||
453 | } else if (is_prefix(*argv, "opcodes")) { | 455 | } else if (is_prefix(*argv, "opcodes")) { |
454 | opcodes = true; | 456 | opcodes = true; |
455 | NEXT_ARG(); | 457 | NEXT_ARG(); |
458 | } else if (is_prefix(*argv, "visual")) { | ||
459 | visual = true; | ||
460 | NEXT_ARG(); | ||
456 | } | 461 | } |
457 | 462 | ||
458 | if (argc) { | 463 | if (argc) { |
@@ -536,6 +541,11 @@ static int do_dump(int argc, char **argv) | |||
536 | } | 541 | } |
537 | 542 | ||
538 | disasm_print_insn(buf, *member_len, opcodes, name); | 543 | disasm_print_insn(buf, *member_len, opcodes, name); |
544 | } else if (visual) { | ||
545 | if (json_output) | ||
546 | jsonw_null(json_wtr); | ||
547 | else | ||
548 | dump_xlated_cfg(buf, *member_len); | ||
539 | } else { | 549 | } else { |
540 | kernel_syms_load(&dd); | 550 | kernel_syms_load(&dd); |
541 | if (json_output) | 551 | if (json_output) |
@@ -596,7 +606,7 @@ static int do_help(int argc, char **argv) | |||
596 | 606 | ||
597 | fprintf(stderr, | 607 | fprintf(stderr, |
598 | "Usage: %s %s { show | list } [PROG]\n" | 608 | "Usage: %s %s { show | list } [PROG]\n" |
599 | " %s %s dump xlated PROG [{ file FILE | opcodes }]\n" | 609 | " %s %s dump xlated PROG [{ file FILE | opcodes | visual }]\n" |
600 | " %s %s dump jited PROG [{ file FILE | opcodes }]\n" | 610 | " %s %s dump jited PROG [{ file FILE | opcodes }]\n" |
601 | " %s %s pin PROG FILE\n" | 611 | " %s %s pin PROG FILE\n" |
602 | " %s %s load OBJ FILE\n" | 612 | " %s %s load OBJ FILE\n" |