Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp178971imm; Tue, 3 Jul 2018 16:35:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeMQIRS4auS9r3dZq6KtG4c+QdyYf7wMimxNuPvWzK0ldWV9CUqcYMbnDou/j1+b+7xb6eW X-Received: by 2002:a63:4924:: with SMTP id w36-v6mr12518506pga.143.1530660920844; Tue, 03 Jul 2018 16:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530660920; cv=none; d=google.com; s=arc-20160816; b=BzTJU6a4zj9pzYL6JcYZTArdBj+16al/kv1OvLxBfXPrZAZLGb6e1buB5GqB4FpKnt 2RjF5ytaQOdyMQTegb5e0UbOBM7h01jqb/379Lul5amoyxM3hB61EmtXw9fmNV6IzHkV GLaAus2YarWwx33sxmotLfzzqzXUDEnS904aPMvOaXusiqFrSPV61wEfdemhT48aL7bM JCmov8pH9VM829wqvrrNTvsMa3mv7pOePVOgf/zmCAFOEkHH1CpjE93vDaXN/RyXUejw VpMxZLZZFmVMellFLkjWtOFj/+Qtzkf20zt/trmRjkrhyVUOUmt7kbbv9IXH3HFZQ63Y 9ZRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=9bx0mpWUD8NauG0TzJxmbdCDMQqxAV2xz4GYZw1q2Bc=; b=paiocCyXBW2J8J1ug/Sk/xfihYZjnAk+UgAAehM2X10T6yQRhozg6CBdlpJE24ABrb RiS01/phnjnBhd49siuGcv5ODB8K2w0T279HfAWRAi0w9xU43rZtv1Ux1obgi9SuTuUT gZKJ36A5yeDkrDeNHkI8VLJzqIg+sqFBQfFrfhe+KTEUDf2vuiUttPQhOdHJEidpMx+A ozLlhptiulPZDr90mG8RL6RN9dHcKYL/NiGFCPyG+axNDj2ElN3FVyXkbOUU4mDG/Qir /AGcLYVnMQCToMeryinp3hlKM3X5d+V/ZBIsyI8vrQFiCHXMU37SKi9cBSRs71VVgRyF f/pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=IV5UH5t7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g67-v6si2181914plb.73.2018.07.03.16.35.06; Tue, 03 Jul 2018 16:35:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=IV5UH5t7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753342AbeGCXeV (ORCPT + 99 others); Tue, 3 Jul 2018 19:34:21 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:36668 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752691AbeGCXeU (ORCPT ); Tue, 3 Jul 2018 19:34:20 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63NWmVI031211; Tue, 3 Jul 2018 16:33:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=9bx0mpWUD8NauG0TzJxmbdCDMQqxAV2xz4GYZw1q2Bc=; b=IV5UH5t7TQF6Iu/zAONHRD5TYzruFG4tEtOvzIxPYs53gUcFPqdEASKWePe/NMs462Uq oueZtnJYIH7LifWCFbS6QSZmAZLPD1HIGsaz32OPpM38sDIkRgAzDJJac2zbMzV3IvfX 0Fao+Neslgd4xQG0JHdzwiVtSUpKZ7lR47Y= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 2k0dn48upe-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 03 Jul 2018 16:33:59 -0700 Received: from kafai-mbp.dhcp.thefacebook.com (192.168.52.123) by mail.thefacebook.com (192.168.16.19) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 3 Jul 2018 16:33:54 -0700 Date: Tue, 3 Jul 2018 16:33:50 -0700 From: Martin KaFai Lau To: Jakub Kicinski CC: Okash Khawaja , Daniel Borkmann , "Alexei Starovoitov" , Yonghong Song , Quentin Monnet , "David S. Miller" , , , Subject: Re: [PATCH bpf-next v2 2/3] bpf: btf: add btf print functionality Message-ID: <20180703233350.aa33jyzrc6hmaelq@kafai-mbp.dhcp.thefacebook.com> References: <20180702183913.669030439@fb.com> <20180702191324.570616684@fb.com> <20180702220659.6baa77ba@cakuba.netronome.com> <20180703214559.GA4448@w1t1fb> <20180703152331.151d1c4b@cakuba.netronome.com> <20180703153843.7a3425af@cakuba.netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180703153843.7a3425af@cakuba.netronome.com> User-Agent: NeoMutt/20180512 X-Originating-IP: [192.168.52.123] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-03_10:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 03, 2018 at 03:38:43PM -0700, Jakub Kicinski wrote: > 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? BTF_INT_ENOCODING (CHAR/SIGNED/BOOL) is for formatting (e.g. pretty print). It is mainly how CTF is using it also. Hence, BTF_INT_ENCODINGs is not a 1:1 mapping to C integer types. The size of an interger is described by BTF_INT_BITS instead. > > > 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? >