OSDN Git Service

bpftool: Print as a string for char array
authorMartin KaFai Lau <kafai@fb.com>
Wed, 18 Mar 2020 17:16:43 +0000 (10:16 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 20 Mar 2020 14:51:35 +0000 (15:51 +0100)
commit30255d317579e93ca3ecf7f4ab953094123e4a8c
tree1fbd68bd94c0fbd9b237b27e7d599245e44c3de7
parentca7e6e45d108f5712aec4407e6c757af59d43d0f
bpftool: Print as a string for char array

A char[] is currently printed as an integer array.
This patch will print it as a string when
1) The array element type is an one byte int
2) The array element type has a BTF_INT_CHAR encoding or
   the array element type's name is "char"
3) All characters is between (0x1f, 0x7f) and it is terminated
   by a null character.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20200318171643.129021-1-kafai@fb.com
tools/bpf/bpftool/btf_dumper.c