From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 5490A386F0D9 for ; Fri, 17 Jun 2022 17:18:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5490A386F0D9 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25HGWio1029748; Fri, 17 Jun 2022 17:18:30 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmjx9p2vp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jun 2022 17:18:30 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25HHG7cD010990; Fri, 17 Jun 2022 17:18:29 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gpr7rke0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jun 2022 17:18:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TpCVOTOcF4tLYFLjnWGZ4slN/kbu07nA+eSyXA8ckNsXZ8RW6AhhbFXPA5iSB+qt6KOHHtQP+YDM4Ku1S6vQHbhwK0algFoxTPBnZKlct+BTeXe/u+aPuHLE3s9a8Nd6zsq8xfZuyfrACxN56r6AadaxwyvraSbYvY6qLVYahNCajhWxyVfOEJpBO2J8E2nxp8zpoO3QTezr0sPnZ1YYPlmQH3+B9Kjjd/TOJ5nt8qB+Eq34V/Uo0EXh6AwF1Gi3O9ioN0KbT+v6jCgz+H24n2X630y4nkyiJYWdWNYu+2SJAos+J2+vy9j59K5KTFs+zTukWyQ30qqAs7plzwhz+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T5gEb7AhfziAdxFCfyLiwrXWr2ax7QcP7XiF4qpVT0I=; b=jS0WFY6GW7EnGNb9/ehJJKSRQHoUgAzoY368GuqPDQ6EF2ptZPdiNuTg+EhPqKuQLyFoK9X85bOp5lVRguli5uB4keXQhwSQ7uTcMa/c6hFyGz/uULYWw/IOx07tpYJ9X7lb2ENDvl6StwBQ3O6DK4bXL/JsIEcI7CafoadwLpgMW/WVKtV+gzLGrRh4E/6FL2+l9dApiEmVhCcUGiBOq9IlytqfwdH0WvyoZf5hckLOmEzAnDURwFRtOk/dL/otBdVr8xgtrjVoDARX60Kv4eL/3sey1zWlYLFiF8EH8MV3lAGuVUypcPcvJKOeCX4yCMehNZ/nTfb4ANVupY0A6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from BYAPR10MB2888.namprd10.prod.outlook.com (2603:10b6:a03:88::32) by SA2PR10MB4747.namprd10.prod.outlook.com (2603:10b6:806:110::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15; Fri, 17 Jun 2022 17:18:27 +0000 Received: from BYAPR10MB2888.namprd10.prod.outlook.com ([fe80::287e:5ffc:d595:8316]) by BYAPR10MB2888.namprd10.prod.outlook.com ([fe80::287e:5ffc:d595:8316%6]) with mapi id 15.20.5332.020; Fri, 17 Jun 2022 17:18:27 +0000 From: "Jose E. Marchesi" To: Yonghong Song Cc: David Faust , gcc-patches@gcc.gnu.org Subject: kernel sparse annotations vs. compiler attributes and debug_annotate_{type,decl} WAS: Re: [PATCH 0/9] Add debug_annotate attributes References: <20220607214342.19463-1-david.faust@oracle.com> <2ab1d9a1-0077-a1e7-f212-556fcf8c8883@fb.com> <9bd41e20-5c39-0d35-bd6e-c10c65280da7@oracle.com> <52dcfdb6-f1b9-1986-5d10-8d6ac8c6d256@fb.com> Date: Fri, 17 Jun 2022 19:18:15 +0200 In-Reply-To: <52dcfdb6-f1b9-1986-5d10-8d6ac8c6d256@fb.com> (Yonghong Song's message of "Wed, 15 Jun 2022 15:56:18 -0700") Message-ID: <874k0jfbu0.fsf_-_@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0040.apcprd02.prod.outlook.com (2603:1096:3:18::28) To BYAPR10MB2888.namprd10.prod.outlook.com (2603:10b6:a03:88::32) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bebabccf-06a8-4ee2-86db-08da50856427 X-MS-TrafficTypeDiagnostic: SA2PR10MB4747:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ppcx4PYB5RnPIyd66bqKHbw12ciLIGV8XyKRcofbEPWbRTRPHYH8zB8SBUpFlRlhJCXh8xXchEKvJAPcqunIadkPILZik64HwNx98ESCRvBzwImBpVQ2sQVCEOYeDpnlyNxC4Q0Mk2YM958aVI5fVJQgkr+BFLDi1SkV//HodFPmapBZ8n5JfWn7mZxO0A/Udd8xwu+439IAFFG3g/TceNx9m5WJQqb06J9kmBvMMZY1NkzggJcoPkvwpJkhWGHZJbcOHAMKVxP7bZDiy9+G/Rmzq/vRlv8F0HVT3s37y81y+to6soGSDTkhs/S/z9+ANrwZXw4+iF1UZrsIO6d8C/tWqL90BzTOIQj5s0qIR0EuGtfX9dd8qQL3DnNOKBIwshuX3zMY7JMtfKLf80xSDJC5CvNkTyUICtfO7dz9vuwqdfPTVZXSpHSCK67Ud3eAlEO1sAWk6SENEpUcNVtt5I9kJf2ZDqJp3OdPMCHEtB5gi0P8PLSnasZXVjIQaRJvanfs8fsqV2arGpXjU28+0NlDO2sh/UdsU0ru1DJTZcHKdvpw4WCEihh6q2/sMT012Z2EkkLNkAYTi+RuRX86659+YjTfQjl0gCHr3nKZUmXkZbj6JzdbTaX3Y5AaXRtJAQhFw1TkJ12/7zfOSozqKkbtcB8B3grX6HQ0/Q22BOv1ytzqUEY6G/ywFG9RcgelAR3WTL0LHP87lgFOfjNpJImKfWsw1PWsahzEU50zXicx3X4QSmhx5iMtvKaGiDDOKcop1ioP9yZGDwhRRdW8GThg1vQD5ysbV0kNiyWiCMre5r1tkPZk9kQVAsSplaDlhw3zouDHZN1XHuBwVQmk3g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2888.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(366004)(4326008)(52116002)(26005)(86362001)(316002)(8676002)(8936002)(186003)(66556008)(6916009)(53546011)(498600001)(66476007)(6666004)(38350700002)(2616005)(6512007)(38100700002)(6506007)(66946007)(966005)(2906002)(6486002)(5660300002)(83380400001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?k75EkBqzooi+VrpFsgOQWoXjxSKQx5DmaACxHZvq45m3NIxH2HzFuns2LavB?= =?us-ascii?Q?GRlABx/S/HFt/Uttv1kWArxRP2oipWz5qSaVvFNQ2INkSfwwEQTZ87fLp2yp?= =?us-ascii?Q?NIHBzpsyzuLSDDgkACFubGN0WmSsw/RiRMfQSTf4B7yJNK3nDSzr89bV1n1W?= =?us-ascii?Q?rLBo2es2pbzX1ffhjhznLmdI3L/VSxVzBa2E8zBPcnBzCElczVvYKSnMj9KO?= =?us-ascii?Q?M8ZEwkL6pfVU80DEGseNF4BZ++BECxUF9YCYA2fjmdyeeYIznzQ6fYGwPnEx?= =?us-ascii?Q?Zs+Fm93YLj/1GET56PapuM04Vi8W9yA3vOF7453UIT+xuFmBKkvFy2g4VCwv?= =?us-ascii?Q?5WBVuU2rZLoAd4NDzp5kSu5Zro4QLKS/KnzktFfE/ikTHXXWvg3P3/8fFyBm?= =?us-ascii?Q?fAWAxBbOd1QsmBckX3FQw8qszI3dfpS0Km6b6nfXNQxpV2AV3irz6o0kno80?= =?us-ascii?Q?ICS4XSHBWm7jSjdsn/fRQ9L+gyX6AjvUw9WUeVKDlyZWVOOFB71jsUuuStiD?= =?us-ascii?Q?Yqkcv0qIqxPXy+4dFCi8/PXI5iNIeStctNapFGxEeDjQjipg7jVEuDPyJabu?= =?us-ascii?Q?yiXUT22Kge6PcpGZOQHrtz78q6IFZ7HK4L8WDXNFz9jOdd38/qQ3DpX8p9um?= =?us-ascii?Q?TGGJXrG4R8OcQnBApNiFSwhXwJgazrcuKcMCc6oenFDD4zbEjMnCR6R2JKbi?= =?us-ascii?Q?48YGUpCr0aYmSDPF//EIqPALYlk9F+eSAohWd3PlECJm7mloU2o5NcELQBKl?= =?us-ascii?Q?no36zRejQrAdBBntB3UsxXkez6Xe23MU7uWsDxIM4QjrsOcZCnVj0TQ5JztU?= =?us-ascii?Q?JYxssQzQ/0UEHlIfp2ngsHh+IxHVzye0bB0CXRXVGxYGUjNP42AvjtMASu6c?= =?us-ascii?Q?knGeAasZF9qpevx32P+cD5GstUllQAMNLmkFd7swp8vs5DiVMFV41QF50Xr5?= =?us-ascii?Q?hAKf+Jd3+HpzszJSxXdE0Duk6uwJOseFI/Do5D5rt8zHE/h1I7CfJmOcLNLS?= =?us-ascii?Q?jFl4RqUqYMe82MnvWDMfxOPmv8urxdNg2IHYpQ7V21XX/PBU+xVX5NA3vXf3?= =?us-ascii?Q?U1IYackZ21WoezG/uPzcJOmmisdwrABn3JUJLf38evwwgF4kg5uxBcg+yUyr?= =?us-ascii?Q?xPzR4PzLXEbhgTjuWbuznbC6n9nqyBea9GHc4x7YGymdZ5xC/QhO2BAnOKfp?= =?us-ascii?Q?R2IZclPn0RD9MpC+UghWSsNF09yAmTPmbrGlAukakPgZDNniL5dirFFRA3F0?= =?us-ascii?Q?5dSZxDJorpwL9KvpJgIY66qBsRmB4warLbe0GuY3G+q0EgO3hWnR4cfGrn71?= =?us-ascii?Q?x5sMeCV5+C4M3kD6xAqVx564y5Cjgp2QB55mPRZdEWm6w32ENSWdCJHrympi?= =?us-ascii?Q?AZJMHNy8t3B3ojmc68mHoI/iqdMDR6Ec/tdTl0gcIn+wRaKP1dwH9VxI5VWG?= =?us-ascii?Q?D3Wija3L4ffqQ9H3IeMYkclLfVgyZcMg7mhmpc9vwd7W2SDirpF0uMV5w4TK?= =?us-ascii?Q?vcsObSOrUHRYYKLM7fy6atgowsX9u0jG3uFW7q1Cczu2b5rl2eFsnUCr2jY/?= =?us-ascii?Q?UgoMZ1gNjffiCLuSOyYve8S3opf95zqPmYwIbdoA4LxEdLw5HaZbzj47pLkA?= =?us-ascii?Q?VtmSLJaN3DcXrvVKzvAXSn5OrE2bEQDKMvu16jf8OpLyvJKDNP3w6wJOzlE9?= =?us-ascii?Q?Tl39NAGehzZ7xOK++M6EeNmUj5aWChdR8LcQlFqbwouCF3zieWlKrSVrZ/ny?= =?us-ascii?Q?17F0gaN39GajQCKH5d3MrVL3iwL2boQ=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bebabccf-06a8-4ee2-86db-08da50856427 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2888.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 17:18:26.9874 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: V0Cv7GMrQW8NCXO8XB+hz9InfZmtOMAc2+8kwxCVFiz2xw5oQgNJGvU0KBUX9Mrn7Cwy2pJ3Azb5Fb/N5SZDyqKHpXXSJfbd4oc+iMKTCs0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4747 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.883 definitions=2022-06-17_10:2022-06-17, 2022-06-17 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206170076 X-Proofpoint-ORIG-GUID: LQJJE2bTPmGOLBrv94s3MDoSxazmZZdg X-Proofpoint-GUID: LQJJE2bTPmGOLBrv94s3MDoSxazmZZdg X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 17:18:36 -0000 Hi Yonghong. > On 6/15/22 1:57 PM, David Faust wrote: >> >> On 6/14/22 22:53, Yonghong Song wrote: >>> >>> >>> On 6/7/22 2:43 PM, David Faust wrote: >>>> Hello, >>>> >>>> This patch series adds support for: >>>> >>>> - Two new C-language-level attributes that allow to associate (to "annotate" or >>>> to "tag") particular declarations and types with arbitrary strings. As >>>> explained below, this is intended to be used to, for example, characterize >>>> certain pointer types. >>>> >>>> - The conveyance of that information in the DWARF output in the form of a new >>>> DIE: DW_TAG_GNU_annotation. >>>> >>>> - The conveyance of that information in the BTF output in the form of two new >>>> kinds of BTF objects: BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG. >>>> >>>> All of these facilities are being added to the eBPF ecosystem, and support for >>>> them exists in some form in LLVM. >>>> >>>> Purpose >>>> ======= >>>> >>>> 1) Addition of C-family language constructs (attributes) to specify free-text >>>> tags on certain language elements, such as struct fields. >>>> >>>> The purpose of these annotations is to provide additional information about >>>> types, variables, and function parameters of interest to the kernel. A >>>> driving use case is to tag pointer types within the linux kernel and eBPF >>>> programs with additional semantic information, such as '__user' or '__rcu'. >>>> >>>> For example, consider the linux kernel function do_execve with the >>>> following declaration: >>>> >>>> static int do_execve(struct filename *filename, >>>> const char __user *const __user *__argv, >>>> const char __user *const __user *__envp); >>>> >>>> Here, __user could be defined with these annotations to record semantic >>>> information about the pointer parameters (e.g., they are user-provided) in >>>> DWARF and BTF information. Other kernel facilites such as the eBPF verifier >>>> can read the tags and make use of the information. >>>> >>>> 2) Conveying the tags in the generated DWARF debug info. >>>> >>>> The main motivation for emitting the tags in DWARF is that the Linux kernel >>>> generates its BTF information via pahole, using DWARF as a source: >>>> >>>> +--------+ BTF BTF +----------+ >>>> | pahole |-------> vmlinux.btf ------->| verifier | >>>> +--------+ +----------+ >>>> ^ ^ >>>> | | >>>> DWARF | BTF | >>>> | | >>>> vmlinux +-------------+ >>>> module1.ko | BPF program | >>>> module2.ko +-------------+ >>>> ... >>>> >>>> This is because: >>>> >>>> a) Unlike GCC, LLVM will only generate BTF for BPF programs. >>>> >>>> b) GCC can generate BTF for whatever target with -gbtf, but there is no >>>> support for linking/deduplicating BTF in the linker. >>>> >>>> In the scenario above, the verifier needs access to the pointer tags of >>>> both the kernel types/declarations (conveyed in the DWARF and translated >>>> to BTF by pahole) and those of the BPF program (available directly in BTF). >>>> >>>> Another motivation for having the tag information in DWARF, unrelated to >>>> BPF and BTF, is that the drgn project (another DWARF consumer) also wants >>>> to benefit from these tags in order to differentiate between different >>>> kinds of pointers in the kernel. >>>> >>>> 3) Conveying the tags in the generated BTF debug info. >>>> >>>> This is easy: the main purpose of having this info in BTF is for the >>>> compiled eBPF programs. The kernel verifier can then access the tags >>>> of pointers used by the eBPF programs. >>>> >>>> >>>> For more information about these tags and the motivation behind them, please >>>> refer to the following linux kernel discussions: >>>> >>>> https://lore.kernel.org/bpf/20210914223004.244411-1-yhs@fb.com/ >>>> https://lore.kernel.org/bpf/20211012164838.3345699-1-yhs@fb.com/ >>>> https://lore.kernel.org/bpf/20211112012604.1504583-1-yhs@fb.com/ >>>> >>>> >>>> Implementation Overview >>>> ======================= >>>> >>>> To enable these annotations, two new C language attributes are added: >>>> __attribute__((debug_annotate_decl("foo"))) and >>>> __attribute__((debug_annotate_type("bar"))). Both attributes accept a single >>>> arbitrary string constant argument, which will be recorded in the generated >>>> DWARF and/or BTF debug information. They have no effect on code generation. >>>> >>>> Note that we are not using the same attribute names as LLVM (btf_decl_tag and >>>> btf_type_tag, respectively). While these attributes are functionally very >>>> similar, they have grown beyond purely BTF-specific uses, so inclusion of "btf" >>>> in the attribute name seems misleading. >>>> >>>> DWARF support is enabled via a new DW_TAG_GNU_annotation. When generating DWARF, >>>> declarations and types will be checked for the corresponding attributes. If >>>> present, a DW_TAG_GNU_annotation DIE will be created as a child of the DIE for >>>> the annotated type or declaration, one for each tag. These DIEs link the >>>> arbitrary tag value to the item they annotate. >>>> >>>> For example, the following variable declaration: >>>> >>>> #define __typetag1 __attribute__((debug_annotate_type ("typetag1"))) >>>> >>>> #define __decltag1 __attribute__((debug_annotate_decl ("decltag1"))) >>>> #define __decltag2 __attribute__((debug_annotate_decl ("decltag2"))) >>>> >>>> int * __typetag1 x __decltag1 __decltag2; >>> >>> Based on the above example >>> static int do_execve(struct filename *filename, >>> const char __user *const __user *__argv, >>> const char __user *const __user *__envp); >>> >>> Should the above example should be the below? >>> int __typetag1 * x __decltag1 __decltag2 >>> >> This example is not related to the one above. It is just meant to >> show the behavior of both attributes. My apologies for not making >> that clear. > > Okay, it should be fine if the dwarf debug_info is shown. > >> >>>> >>>> Produces the following DWARF information: >>>> >>>> <1><1e>: Abbrev Number: 3 (DW_TAG_variable) >>>> <1f> DW_AT_name : x >>>> <21> DW_AT_decl_file : 1 >>>> <22> DW_AT_decl_line : 7 >>>> <23> DW_AT_decl_column : 18 >>>> <24> DW_AT_type : <0x49> >>>> <28> DW_AT_external : 1 >>>> <28> DW_AT_location : 9 byte block: 3 0 0 0 0 0 0 0 0 (DW_OP_addr: 0) >>>> <32> DW_AT_sibling : <0x49> >>>> <2><36>: Abbrev Number: 1 (User TAG value: 0x6000) >>>> <37> DW_AT_name : (indirect string, offset: 0xd6): debug_annotate_decl >>>> <3b> DW_AT_const_value : (indirect string, offset: 0xcd): decltag2 >>>> <2><3f>: Abbrev Number: 1 (User TAG value: 0x6000) >>>> <40> DW_AT_name : (indirect string, offset: 0xd6): debug_annotate_decl >>>> <44> DW_AT_const_value : (indirect string, offset: 0x0): decltag1 >>>> <2><48>: Abbrev Number: 0 >>>> <1><49>: Abbrev Number: 4 (DW_TAG_pointer_type) >>>> <4a> DW_AT_byte_size : 8 >>>> <4b> DW_AT_type : <0x5d> >>>> <4f> DW_AT_sibling : <0x5d> >>>> <2><53>: Abbrev Number: 1 (User TAG value: 0x6000) >>>> <54> DW_AT_name : (indirect string, offset: 0x9): debug_annotate_type >>>> <58> DW_AT_const_value : (indirect string, offset: 0x1d): typetag1 >>>> <2><5c>: Abbrev Number: 0 >>>> <1><5d>: Abbrev Number: 5 (DW_TAG_base_type) >>>> <5e> DW_AT_byte_size : 4 >>>> <5f> DW_AT_encoding : 5 (signed) >>>> <60> DW_AT_name : int >>>> <1><64>: Abbrev Number: 0 > > This shows the info in .debug_abbrev. What I mean is to > show the related info in .debug_info section which seems more useful to > understand the relationships between different tags. Maybe this is due > to that I am not fully understanding what <1>/<2> means in <1><49> and > <2><53> etc. I think that dump actually shows .debug_info, with the abbrevs expanded... Anyway, it seems to us that the root of this problem is the fact the kernel sparse annotations, such as address_space(__user), are: 1) To be processed by an external kernel-specific tool ( https://sparse.docs.kernel.org/en/latest/annotations.html) and not a C compiler, and therefore, 2) Not quite the same than compiler attributes (despite the way they look.) In particular, they seem to assume an ordering different than of GNU attributes: in some cases given the same written order, they refer to different things!. Which is quite unfortunate :( Now, if I understood properly, you plan to change the definition of __user and __kernel in the kernel sources in order to generate the tag compiler attributes, correct? Is that the reason why LLVM implements what we assume to be the sparse ordering, and not the correct GNU attributes ordering, for the tag attributes? If that is so, we have quite a problem here: I don't think we can change the way GCC handles GNU-like attributes just because the kernel sources want to hook on these __user/__kernel sparse annotations to generate the compiler tags, even if we could mayhaps get GCC to handle debug_annotate_type and debug_annotate_decl differently. Some would say doing so would perpetuate the mistake instead of fixing it... Is my understanding correct? >>> >>> Maybe you can also show what dwarf debug_info looks like >> I am not sure what you mean. This is the .debug_info section as output >> by readelf -w. I did trim some information not relevant to the discussion >> such as the DW_TAG_compile_unit DIE, for brevity. >> >>> >>>> >>>> In the case of BTF, the annotations are recorded in two type kinds recently >>>> added to the BTF specification: BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG. >>>> The above example declaration prodcues the following BTF information: >>>> >>>> [1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED >>>> [2] PTR '(anon)' type_id=3 >>>> [3] TYPE_TAG 'typetag1' type_id=1 >>>> [4] DECL_TAG 'decltag1' type_id=6 component_idx=-1 >>>> [5] DECL_TAG 'decltag2' type_id=6 component_idx=-1 >>>> [6] VAR 'x' type_id=2, linkage=global >>>> [7] DATASEC '.bss' size=0 vlen=1 >>>> type_id=6 offset=0 size=8 (VAR 'x') >>>> >>>> >>> [...]