From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway30.websitewelcome.com (gateway30.websitewelcome.com [192.185.179.30]) by sourceware.org (Postfix) with ESMTPS id A5E1E3959C64 for ; Tue, 8 Jun 2021 15:26:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A5E1E3959C64 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 0165BD97B for ; Tue, 8 Jun 2021 10:26:34 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id qdcflCsaCMRV2qdcflOdlY; Tue, 08 Jun 2021 10:26:33 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=kwA+wUgdwo7dbfNCpd0r8rBC7qRXweFF8b65gVyLXPc=; b=hEY5Sf9dKexdRWpk0yTr0bMxpN dw9ZGmjz/gWBB1xTjM63XvjVsDSMqkBtNcT75LMOlgWAXUBiq+MdCBVus9bcfjNOMChCjNbyNFQJc WlwXwhheOJ5fqUetKabtHt9k3; Received: from 97-122-81-113.hlrn.qwest.net ([97.122.81.113]:35074 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lqdcf-000aM3-JM; Tue, 08 Jun 2021 09:26:33 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/2] Consolidate CU language setting Date: Tue, 8 Jun 2021 09:26:29 -0600 Message-Id: <20210608152630.4155280-2-tom@tromey.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210608152630.4155280-1-tom@tromey.com> References: <20210608152630.4155280-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.81.113 X-Source-L: No X-Exim-ID: 1lqdcf-000aM3-JM X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-113.hlrn.qwest.net (localhost.localdomain) [97.122.81.113]:35074 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3032.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jun 2021 15:26:38 -0000 The DWARF reader currently sets the CU's language in two different spots. It is primarily done in prepare_one_comp_unit, but read_file_scope also checks the producer and may change the language based on the result. This patch consolidates all language-setting into prepare_one_comp_unit. set_cu_language is changed not to set language_defn; instead that is done in prepare_one_comp_unit after the correct language enum value is chosen. This fixes a minor latent bug, which is that read_file_scope could set the language enum value to language_opencl, but then neglected to reset language_defn in this case. 2021-06-06 Tom Tromey * dwarf2/read.c (read_file_scope): Don't call set_cu_language. (set_cu_language): Don't set language_defn. (prepare_one_comp_unit): Check producer and set language_defn. --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2/read.c | 34 ++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 96009f1418f..b1a0b8bce88 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -10509,16 +10509,6 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) file_and_directory fnd = find_file_and_directory (die, cu); - /* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not - standardised yet. As a workaround for the language detection we fall - back to the DW_AT_producer string. */ - if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL") != NULL) - cu->language = language_opencl; - - /* Similar hack for Go. */ - if (cu->producer && strstr (cu->producer, "GNU Go ") != NULL) - set_cu_language (DW_LANG_Go, cu); - cu->start_symtab (fnd.name, fnd.comp_dir, lowpc); /* Decode line number information if present. We do this before @@ -20407,7 +20397,6 @@ set_cu_language (unsigned int lang, struct dwarf2_cu *cu) cu->language = language_minimal; break; } - cu->language_defn = language_def (cu->language); } /* Return the named attribute or NULL if not there. */ @@ -24413,17 +24402,30 @@ prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die, { struct attribute *attr; + cu->producer = dwarf2_string_attr (comp_unit_die, DW_AT_producer, cu); + /* Set the language we're debugging. */ attr = dwarf2_attr (comp_unit_die, DW_AT_language, cu); if (attr != nullptr) set_cu_language (attr->constant_value (0), cu); - else + else if (cu->producer != nullptr + && strstr (cu->producer, "IBM XL C for OpenCL") != NULL) { - cu->language = pretend_language; - cu->language_defn = language_def (cu->language); + /* The XLCL doesn't generate DW_LANG_OpenCL because this + attribute is not standardised yet. As a workaround for the + language detection we fall back to the DW_AT_producer + string. */ + cu->language = language_opencl; } - - cu->producer = dwarf2_string_attr (comp_unit_die, DW_AT_producer, cu); + else if (cu->producer != nullptr + && strstr (cu->producer, "GNU Go ") != NULL) + { + /* Similar hack for Go. */ + cu->language = language_go; + } + else + cu->language = pretend_language; + cu->language_defn = language_def (cu->language); } /* See read.h. */ -- 2.26.3