public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Bruno Larsen <blarsen@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3] gdb: Fix issue with Clang CLI macros
Date: Wed, 2 Nov 2022 08:36:35 -0400	[thread overview]
Message-ID: <d528248b-2a48-18e1-b966-d02ae67a17e3@simark.ca> (raw)
In-Reply-To: <20221018132215.2593111-1-blarsen@redhat.com>

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 <simon.marchi@efficios.com>
> 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 <http://www.gnu.org/licenses/>.
> +
> +# 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

  parent reply	other threads:[~2022-11-02 12:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 13:22 Bruno Larsen
2022-11-02  8:19 ` [PING][PATCH " Bruno Larsen
2022-11-02 12:36 ` Simon Marchi [this message]
2022-11-03 12:58   ` [PATCH " Bruno Larsen
2022-11-03 13:07     ` Simon Marchi
2022-11-03 13:08       ` Bruno Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d528248b-2a48-18e1-b966-d02ae67a17e3@simark.ca \
    --to=simark@simark.ca \
    --cc=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).