From patchwork Fri Jan 15 11:43:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1426929 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (server2.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 4DHK7k3Nm5z9sRR for ; Fri, 15 Jan 2021 22:43:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5733B39730DA; Fri, 15 Jan 2021 11:43:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id AFFDB3973049 for ; Fri, 15 Jan 2021 11:43:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AFFDB3973049 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Andrew_Stubbs@mentor.com IronPort-SDR: hGz5N18RZ33CIOuSi/6nZ/8yOe5DILduqEj3L+byAxsatcW7B5CxgRbAydUUQOoy0l+BGypK8y HL7J1xMISNX7DpNK57FW5HfQFBOOi39v/YDC4KGhu3UDfSD7+JzuJ9ZBVYR+oZ5sy48osQnQFM /8f3CN14I4sqq4sH2ahUf7UrlcTxSMVVhHfGCHZ/wSfp027mCaHQeXeDW0NYSSBAhIsGIIlCX8 LHH4Vm2f+c+T+DIeCZSqeBPUaCwjmV+rFd8+asvGvDWVtbxLr8sg5md8bReSGDKdr1Tlv3EiDE RwI= X-IronPort-AV: E=Sophos;i="5.79,349,1602576000"; d="scan'208";a="59390888" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 15 Jan 2021 03:43:23 -0800 IronPort-SDR: l1/xrLZFstK/oKv57JQCzBZ3BAiHmE4y8uSPW1rM3uRhhwl18PFoW5xTSVTiCe41NE8v2f2Skz /orSeo/52u6wiUr2ynztf/Taqi0D8gNvZh0bffhNco0c5RxVR1uZwNIu8LxukXvyzOv/l5kZFG ixlp+Dz4qRGwDuw+TiHA4380tg6tKYjiwIuzLleGzMlpNmiZPEp/4V+2K8pjHf9478ihhoiacc WeQvGRxLho7g+6HkIt1AThACY4oJ/Q8lxd26lnlAP88IMa8a+8guNu71oYUHn3VunFQQ7tAAKc 3QU= From: Andrew Stubbs Subject: [committed][OG10] Fix offload dwarf info To: "gcc-patches@gcc.gnu.org" Message-ID: <76859c2d-ae26-ac85-ff8a-bea712909d62@codesourcery.com> Date: Fri, 15 Jan 2021 11:43:18 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Language: en-GB X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This patch corrects a problem in which GDB ignores the debug info for offload kernel entry functions because they're represented as nested functions inside a function that does not exist on the accelerator device (only on the host). The fix is to add a notional code range to the non-existent parent function. Setting it the same as the inner function is good enough because GDB selects the innermost. I'll submit this the mainline when stage 1 opens. Committed to devel/omp/gcc-10 for now. Andrew Fix offload dwarf info Add a notional code range to the notional parent function of offload kernel functions. This is enough to prevent GDB discarding them. gcc/ChangeLog: * dwarf2out.c (gen_subprogram_die): Add high/low_pc attributes for parents of offload kernels. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 4d84a9e9607..a4a1b934dc7 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -23079,6 +23079,20 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) /* We have already generated the labels. */ add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end, false); + + /* Offload kernel functions are nested within a parent function + that doesn't actually exist within the offload object. GDB + will ignore the function and everything nested within unless + we give it a notional code range (the values aren't + important, as long as they are valid). */ + if (flag_generate_offload + && lookup_attribute ("omp target entrypoint", + DECL_ATTRIBUTES (decl)) + && subr_die->die_parent + && subr_die->die_parent->die_tag == DW_TAG_subprogram + && !get_AT_low_pc (subr_die->die_parent)) + add_AT_low_high_pc (subr_die->die_parent, fde->dw_fde_begin, + fde->dw_fde_end, false); } else {