From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH bpf-next v2 2/3] bpf: btf: add btf print functionality Date: Tue, 3 Jul 2018 15:38:43 -0700 Message-ID: <20180703153843.7a3425af@cakuba.netronome.com> References: <20180702183913.669030439@fb.com> <20180702191324.570616684@fb.com> <20180702220659.6baa77ba@cakuba.netronome.com> <20180703214559.GA4448@w1t1fb> <20180703152331.151d1c4b@cakuba.netronome.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Daniel Borkmann , Alexei Starovoitov , Yonghong Song , "Quentin Monnet" , "David S. Miller" , , , To: Okash Khawaja , Martin KaFai Lau Return-path: In-Reply-To: <20180703152331.151d1c4b@cakuba.netronome.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On Tue, 3 Jul 2018 15:23:31 -0700, Jakub Kicinski wrote: > > > > + else > > > > + jsonw_printf(jw, "%hhd", *((char *)data)); > > > > > > ... I think you need to always print a string, and express it as > > > \u00%02hhx for non-printable. > > Okay that makes sense > > Yeah, IDK, char can be used as a byte as well as a string. In eBPF > it may actually be more likely to just be used as a raw byte buffer... Actually, what is the definition/purpose of BTF_INT_CHAR? There seems to be no BTF_INT_SHORT and BTF_INT_SIGNED can simply be of size 8... Is normal int only used for bitfields of size 8 and BTF_INT_CHAR for char variables? The kernel seems to be rejecting combinations of those flags, is unsigned char going to not be marked as char then? > Either way I think it may be nice to keep it consistent, at least for > the JSON output could we do either always ints or always characters?