From patchwork Thu Jul 8 22:22:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1502782 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=vjwb7pos; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GLW6B1CfJz9sWd for ; Fri, 9 Jul 2021 08:23:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CBFE393AC06 for ; Thu, 8 Jul 2021 22:23:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CBFE393AC06 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1625783021; bh=ivxdhUBAQhhVFM1eWjEi/uWoKH5GcPZ/siIXxcIOnVQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vjwb7posVvy06EQTKaNk3T+7bXRh2baYhoiHGqqPbVRm/qirJusXh0vOgCeQoUz+z 7iUjaG5MXEa7uqa6F22npwhtoNf3/R7WBylsiEqNJBwZF21ptWYA/DCxTJYjphAy2v lI63jGGYaLK9Hn60LrLPPnzg2ISD2/mLtDPdfuz0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 77D1F3858006 for ; Thu, 8 Jul 2021 22:22:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77D1F3858006 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 168MEU7e008086 for ; Thu, 8 Jul 2021 22:22:54 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39n4yd4694-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 08 Jul 2021 22:22:54 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 168MAQeC094209 for ; Thu, 8 Jul 2021 22:22:53 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by aserp3020.oracle.com with ESMTP id 39jfqdt84j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 08 Jul 2021 22:22:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cu3dxsPt1cEoqOIKMAPFsfd52+4X2jCZZHr0QZY0gSz723aTzDipSBH+LOEmN3cLuQZbTPhUx3nNUASZVlbdGa9t9wCZKD7sBKpgt0F0djqw0zHTsu+rKLFLSkrHa4nWo09LIcfDIxmDfpBq3uG8w0fYOiFVFUBW54W/5nYleL15Gl53V0HRnAzBOLZgPUhT50/fJ452hh3yuTvrT2bY4f8M67vSNoBk862dDRDcTyEKKUPHtymAC46HfOFFlNP+hLSxbNq6UFMF0t4fHtt6xxNQE+IiEC8pv0pBI89rDglrcdIyQiPsFCulRagvTehQb4D+7QoEZCe6yWP+I9H2ww== 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-SenderADCheck; bh=ivxdhUBAQhhVFM1eWjEi/uWoKH5GcPZ/siIXxcIOnVQ=; b=VQ+xDMiDF8qzN6TQkiRDebgIF0ej3iA50/CW9n0GJgMwhjJWZZ0mJ7WJUqCKzLH5+G2cbdVeLaO/aZgHXaSNKwf3tLe1iWYh7YAAvKwZ9LhBB6n4VwU+6cYktfHryNX6ocif3wRaS7pXASUMSyv3x5d74FkR5/DwW7DY7NhJckEtkMkW61tm1VKkscnSt1IORdVWr4rLkGdyicb8c0A1pei/86VLthFPZhM8TlzuYLcPxzFA4+8P60LxMB5TScRWixAfPvuGso/mCfkUJY2JOB/rYRbDheAv4BHg7hJgsN3qDsSpvUyOorEV2v4AhOzBAdvInihswsMA+ojf0t/D2Q== 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 MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5409.namprd10.prod.outlook.com (2603:10b6:5:357::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.28; Thu, 8 Jul 2021 22:22:48 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::1076:c9ce:4957:e3f3]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::1076:c9ce:4957:e3f3%5]) with mapi id 15.20.4195.029; Thu, 8 Jul 2021 22:22:48 +0000 To: gcc-patches@gcc.gnu.org Subject: [RFC,PATCH] Allow means for targets to out out of CTF/BTF support Date: Thu, 8 Jul 2021 15:22:32 -0700 Message-Id: <1625782952-13143-1-git-send-email-indu.bhagat@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-ClientProxiedBy: MW4PR03CA0023.namprd03.prod.outlook.com (2603:10b6:303:8f::28) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ibhagatpc.hitronhub.home (24.80.24.133) by MW4PR03CA0023.namprd03.prod.outlook.com (2603:10b6:303:8f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Thu, 8 Jul 2021 22:22:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f524870d-ea0d-4bd9-7f49-08d9425eead8 X-MS-TrafficTypeDiagnostic: CO6PR10MB5409: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aHSbTY7s+MluwJxo0RVEpgtrbomVimzMOYo6afXJvKH2RR/6IdpbnZyaGbLZkHMfhtNP7gyAYQu7W+1NDIwWMw0HcjOFHxnazd14Gt27AKCgdtw0PREPzeFabRgbN6MYbfsK7Xvh06khcx8RADiEBFt94CIOt/vEGh6WVWb8w9rmu5zKQmq8OLNO9mtGy9iZ7wou1YgyDWJNR2GhTGPpqOwKfPE2MemEYmQO7Yvtg4szMQ+bkmkMLZFhQgW/sJxWWMHAOszxY7PPCcteFXh3w8GdXh+j5tBwfs0iyxvbGSuJi2jeudCdiDZzRFEYBsVsYx8K9AOznk4FoakfhMNmyCttBIhKwucUiVqR5InRUKM+sHDmsVPMy4tHEerVM4idTz67oLVWMebaD8ydU9fHhTsehsvZafU5/bhWRsh6Z47gNk3SGl/YZVMby1VdzqBZb8MZqRqkM7upD46KALdg+N2dvujIJUWZftz/V4dR8qs68/3yPc5nzF6D6LaYcAQ0Hg0pIiWxwk/vCrcjArMkzctJMpOVjpdY+K8+lkHAJvFHVaG6MrNluSbGzF6NPCdpAG/eoGEB2+L5UXC/IHMwaq3mlHRToFqAxDqfcyXsMPRya5lw1QF9cfte5NebNDajAPtUIUxdRK9jnob9s+eO4zF7HG1c6csE0hGg4hukD3/kEBmIcfFs8y3UeqRLPA2UCA94LtmDvNQOw4Nro+djSihKgJmsKGh37dPuGOpxxuPxznHdYcUuiFrjh7qthBnpWn01ZNehT2kNHHEwd/dmZ/AUv0lZZFUIi76rAoCFDctSirZE+TQnp4+J/HWLrxMUidfEZiFtHPAh2aUylcgRCw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(39860400002)(396003)(366004)(136003)(346002)(66556008)(6916009)(478600001)(52116002)(5660300002)(186003)(38100700002)(8936002)(6666004)(66476007)(38350700002)(316002)(2906002)(26005)(6486002)(956004)(8676002)(86362001)(36756003)(44832011)(2616005)(6512007)(83380400001)(6506007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gou8FNIyMWiFP32kBHC8PEH4yydGEf3IoDvawcqFbqq46NmmUDDw4ALF3tVDIsWCVBEmuALQL7XceS6Wqln1K89I6fMfTtNjXc7381Vwu+o7m1Td44LeoQSUq1Ulm805/RHt4cOA3khIHu9ZuKY7NM7R9VZ2TaOsg2NhiswU3lCU5ObWAjD3ABA8z7bV/QAF6w8gl45On6Jz3T01/dS1yxp8A0I3DjGEM5hgvu9SgwLFc1Jk1BVi9cSrlwPl3Wi7f2yQaPmkYaDE8N4ElkXgWOQxd7VNPTMiyWIDM0Fxdyj/VFN6VLgxjRMLephJwYEF73IcwKRERUza8EIy+H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exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2021 22:22:48.5201 (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: /jUrc0WwNn3IChV/6rSFu8tj6zRbT1e+SlXXML9nwagCf9zhywetHvbp6YCqCGpF3h76kQ71w+zwILxxTjh/+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5409 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10039 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107080114 X-Proofpoint-GUID: Q58I3QMzFgNo-2yv7BiBS3YMwX_w-he1 X-Proofpoint-ORIG-GUID: Q58I3QMzFgNo-2yv7BiBS3YMwX_w-he1 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Indu Bhagat via Gcc-patches From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hello, It was brought up when discussing PR debug/101283 (Several tests fail on Darwin with -gctf/gbtf) that it will be good to provide means for targets to opt out of CTF/BTF support. By and large, it seems to me that CTF/BTF debug formats can be safely enabled for all ELF-based targets by default in GCC. So, at a high level: - By default, CTF/BTF formats can be enabled for all ELF-based targets. - By default, CTF/BTF formats can be disabled for all non ELF-based targets. - If the user passed a -gctf but CTF is not enabled for the target, GCC issues an error to the user (as is done currently with other debug formats) - "target system does not support the 'ctf' debug format". This is a makeshift patch which fulfills the above requirements and is based on the approach taken for DWARF via DWARF2_DEBUGGING_INFO (I still have to see if I need some specific handling in common_handle_option in opts.c). On minimal testing, the patch works as desired on x86_64-pc-linux-gnu and a darwin-based target. My question is - Looking around in config.gcc etc., it seems defining in elfos.h gives targets/platforms means to override it by virtue of the recommended order of # includes in $tm_file. What I cannot say for certain is if this is true in practice ? On first look, I believe this could work fine. What do you think ? If you think this approach could work, I will continue on this track and test/refine the patch. Thanks Indu ------------- gcc/ChangeLog: * config/elfos.h (CTF_DEBUGGING_INFO): New definition. (BTF_DEBUGGING_INFO): Likewise. * toplev.c: Guard initialization of debug hooks. gcc/testsuite/ChangeLog: * gcc.dg/debug/btf/btf.exp: Do not run BTF testsuite if target does not support BTF format. * gcc.dg/debug/ctf/ctf.exp: Do not run CTF testsuite if target does not support CTF format. --- gcc/config/elfos.h | 8 ++++++++ gcc/testsuite/gcc.dg/debug/btf/btf.exp | 11 +++++++++-- gcc/testsuite/gcc.dg/debug/ctf/ctf.exp | 11 +++++++++-- gcc/toplev.c | 11 +++++++++-- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h index 7a736cc..e5cb487 100644 --- a/gcc/config/elfos.h +++ b/gcc/config/elfos.h @@ -68,6 +68,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define DWARF2_DEBUGGING_INFO 1 +/* All ELF targets can support CTF. */ + +#define CTF_DEBUGGING_INFO 1 + +/* All ELF targets can support BTF. */ + +#define BTF_DEBUGGING_INFO 1 + /* The GNU tools operate better with dwarf2, and it is required by some psABI's. Since we don't have any native tools to be compatible with, default to dwarf2. */ diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf.exp b/gcc/testsuite/gcc.dg/debug/btf/btf.exp index e173515..a3e680c 100644 --- a/gcc/testsuite/gcc.dg/debug/btf/btf.exp +++ b/gcc/testsuite/gcc.dg/debug/btf/btf.exp @@ -39,8 +39,15 @@ if ![info exists DEFAULT_CFLAGS] then { dg-init # Main loop. -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \ - "" $DEFAULT_CFLAGS +set comp_output [gcc_target_compile \ + "$srcdir/$subdir/../trivial.c" "trivial.S" assembly \ + "additional_flags=-gbtf"] +if { ! [string match "*: target system does not support the * debug format*" \ + $comp_output] } { + remove-build-file "trivial.S" + dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \ + "" $DEFAULT_CFLAGS +} # All done. dg-finish diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp b/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp index 0b650ed..c53cd8b 100644 --- a/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp +++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf.exp @@ -39,8 +39,15 @@ if ![info exists DEFAULT_CFLAGS] then { dg-init # Main loop. -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \ - "" $DEFAULT_CFLAGS +set comp_output [gcc_target_compile \ + "$srcdir/$subdir/../trivial.c" "trivial.S" assembly \ + "additional_flags=-gctf"] +if { ! [string match "*: target system does not support the * debug format*" \ + $comp_output] } { + remove-build-file "trivial.S" + dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\] ]] \ + "" $DEFAULT_CFLAGS +} # All done. dg-finish diff --git a/gcc/toplev.c b/gcc/toplev.c index 43f1f7d..8103812 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1463,8 +1463,15 @@ process_options (void) debug_hooks = &xcoff_debug_hooks; #endif #ifdef DWARF2_DEBUGGING_INFO - else if (dwarf_debuginfo_p () - || dwarf_based_debuginfo_p ()) + else if (dwarf_debuginfo_p ()) + debug_hooks = &dwarf2_debug_hooks; +#endif +#ifdef CTF_DEBUGGING_INFO + else if (write_symbols & CTF_DEBUG) + debug_hooks = &dwarf2_debug_hooks; +#endif +#ifdef BTF_DEBUGGING_INFO + else if (btf_debuginfo_p ()) debug_hooks = &dwarf2_debug_hooks; #endif #ifdef VMS_DEBUGGING_INFO