From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 5137638576B2 for ; Wed, 2 Nov 2022 12:36:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5137638576B2 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.64] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 1295C1E0CB; Wed, 2 Nov 2022 08:36:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1667392597; bh=D6CZyw03ZM2PeT7rk6NAiN7YbS+/Ext/lWB+NA6CfKI=; h=Date:Subject:To:References:From:In-Reply-To:From; b=pRocOFktUchT67CeBUzS8dlrPMRcLfOKkE7CHDWNQL4J2Dz1RaPSmGZqSj6/fHMTi 6kyJlL52JKtoCdVejGqD2HewJnqHi3CoWTzM1UAgJUK/c58XIANCIFKJxaiUZjPdqo PydTAbUjjDJxVm2tPhwzgY11zFIP2haHL5WDhQN4= Message-ID: Date: Wed, 2 Nov 2022 08:36:35 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v3] gdb: Fix issue with Clang CLI macros Content-Language: fr To: Bruno Larsen , gdb-patches@sourceware.org References: <20221018132215.2593111-1-blarsen@redhat.com> From: Simon Marchi In-Reply-To: <20221018132215.2593111-1-blarsen@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/18/22 09:22, Bruno Larsen via Gdb-patches wrote: > Clang up to version 15 (current) adds macros that were defined in the > command line or by "other means", according to the Dwarf specification, > after the last DW_MACRO_end_file, instead of before the first > DW_MACRO_start_file, as the specification dictates. When GDB reads the > macros after the last file is closed, the macros never end up "in scope" > and so we can't print them. This has been submitted as a bug to Clang > developers (https://github.com/llvm/llvm-project/issues/54506), and PR > macros/29034 was opened for GDB to keep track of this. > > Seeing as there is no expected date for it to be fixed, add a workaround > for all current versions of Clang. The workaround detects when > the main file would be closed and if the producer is Clang, and turns > that operation into a noop, so we keep a reference to the current_file > as those macros are read. > > A test case was added to confirm the functionality, and the KFAIL for > running gdb.base/macro-source-path when using clang. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29034 Hi Bruno, The patch is ok, with the nits noted below fixed. Approved-By: Simon Marchi > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index 78f4cc1f60d..b3b2c70b1c3 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -9484,6 +9484,15 @@ producer_is_gcc_lt_4_3 (struct dwarf2_cu *cu) > return cu->producer_is_gcc_lt_4_3; > } > > +bool > +producer_is_clang (struct dwarf2_cu *cu) Add the "See dwarf2/read.h" comment here. > diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h > index 5f01fbc1025..a47e6bf5144 100644 > --- a/gdb/dwarf2/read.h > +++ b/gdb/dwarf2/read.h > @@ -761,4 +761,6 @@ extern void dwarf2_get_section_info (struct objfile *, > asection **, const gdb_byte **, > bfd_size_type *); > > +extern bool producer_is_clang (struct dwarf2_cu *cu); Add a comment to document this function. > diff --git a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp > new file mode 100644 > index 00000000000..ea701468cdb > --- /dev/null > +++ b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp > @@ -0,0 +1,98 @@ > +# This testcase is part of GDB, the GNU debugger. > + > +# Copyright 2022 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# Clang has this bug where it puts the macros defined on the command-line > +# after the main file portion (see PR 29034) and: I'm not sure if the "and" a the end is supposed to be there or not, it reads weird. Simon