From patchwork Tue Sep 29 23:28:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 259876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3CEFC47420 for ; Tue, 29 Sep 2020 23:28:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5950720897 for ; Tue, 29 Sep 2020 23:28:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="SFxjzvw3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728684AbgI2X2s (ORCPT ); Tue, 29 Sep 2020 19:28:48 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:45864 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726637AbgI2X2s (ORCPT ); Tue, 29 Sep 2020 19:28:48 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.42/8.16.0.42) with SMTP id 08TNPrHo025665 for ; Tue, 29 Sep 2020 16:28:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=facebook; bh=CbaM07ZK+GlVKTQxKPaMAAToEOEbD0ztrAeLlK5glk0=; b=SFxjzvw33+xBA+qiKigHlUAhpmOEw75Y4A+mnDnidoa8VSYMqGUUW98HvRsdIcT1t1+F mmoh7WWCcdNjg6lBdYKIEHZWCfO5HbAGyyav4R7JO33cTT8PnyaDN/OdN76WnUS6vw/o 59YGi6kGgbiTzWYA0iss2XZhSfVP/Qagqmg= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net with ESMTP id 33t14ygd4q-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 29 Sep 2020 16:28:46 -0700 Received: from intmgw002.08.frc2.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 29 Sep 2020 16:28:45 -0700 Received: by devbig012.ftw2.facebook.com (Postfix, from userid 137359) id 4374B2EC77D1; Tue, 29 Sep 2020 16:28:45 -0700 (PDT) From: Andrii Nakryiko To: , , , CC: , , Andrii Nakryiko Subject: [PATCH bpf-next 0/4] libbpf: add raw BTF type dumping Date: Tue, 29 Sep 2020 16:28:39 -0700 Message-ID: <20200929232843.1249318-1-andriin@fb.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-29_14:2020-09-29,2020-09-29 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=850 priorityscore=1501 phishscore=0 spamscore=0 adultscore=0 bulkscore=0 mlxscore=0 clxscore=1015 impostorscore=0 suspectscore=8 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009290198 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add btf_dump__dump_type_raw() API that emits human-readable low-level BTF type information, same as bpftool output. bpftool is not switched to this API because bpftool still needs to perform all the same BTF type processing logic to do JSON output, so benefits are pretty much zero. Raw BTF type output is extremely useful when debugging issues with BTF. It's also handy to be able to do that in selftests. Raw BTF type output doesn't hide any information like BTF-to-C conversion might (e.g., not emitting BTF_KIND_FUNC, BTF_KIND_VAR and BTF_KIND_DATASEC), so is the most robust way to look at BTF data without going all the way to deciphering binary BTF info. Also, now that BTF can be extended with write APIs, teach btf_dump to work with such modifiable BTFs, including the BTF-to-C convertion APIs. A self-test to validate such incremental BTF-to-C conversion is added in patch #4. Andrii Nakryiko (4): libbpf: make btf_dump work with modifiable BTF libbpf: add raw dumping of BTF types selftests/bpf: add checking of raw type dump in BTF writer APIs selftests selftests/bpf: test "incremental" btf_dump in C format tools/lib/bpf/btf.c | 17 ++ tools/lib/bpf/btf.h | 1 + tools/lib/bpf/btf_dump.c | 243 ++++++++++++++++-- tools/lib/bpf/libbpf.map | 1 + tools/lib/bpf/libbpf_internal.h | 1 + .../selftests/bpf/prog_tests/btf_dump.c | 105 ++++++++ .../selftests/bpf/prog_tests/btf_write.c | 67 ++++- 7 files changed, 410 insertions(+), 25 deletions(-)