public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/29034] New: Can't print macros defined on the command-line with binaries built with clang
@ 2022-04-07  0:54 simark at simark dot ca
  2022-04-08  0:01 ` [Bug macros/29034] " tromey at sourceware dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: simark at simark dot ca @ 2022-04-07  0:54 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29034

            Bug ID: 29034
           Summary: Can't print macros defined on the command-line with
                    binaries built with clang
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: simark at simark dot ca
  Target Milestone: ---

With a gcc-compiled binary, I can print a macro defined on the command line:

  $ gcc test.c -g3 -O0 -DONE=1
  $ ./gdb -nx -q --data-directory=data-directory a.out -ex start -ex "p ONE"
-batch
  ...
  $1 = 1

Not with clang:

    $ clang --version
clang version 13.0.1
    $ clang test.c -g3 -O0 -fdebug-macro -DONE=1 
    $ ./gdb -nx -q --data-directory=data-directory a.out -ex start -ex "p ONE"
-batch
    ...
    No symbol "ONE" in current context.

I think this is due to the fact that clang puts the macros defined on the
command-line too late in the macro table, after the main file.  So they are not
"in scope" when stopped somewhere in the main file or any file included by it
(so, anywhere really).

I opened this LLVM bug:

https://github.com/llvm/llvm-project/issues/54506

This bug is mostly to have a paper trail and be able to use a KFAIL in the
testsuite.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug macros/29034] Can't print macros defined on the command-line with binaries built with clang
  2022-04-07  0:54 [Bug gdb/29034] New: Can't print macros defined on the command-line with binaries built with clang simark at simark dot ca
@ 2022-04-08  0:01 ` tromey at sourceware dot org
  2022-04-08  0:07 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at sourceware dot org @ 2022-04-08  0:01 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29034

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|gdb                         |macros
                 CC|                            |tromey at sourceware dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug macros/29034] Can't print macros defined on the command-line with binaries built with clang
  2022-04-07  0:54 [Bug gdb/29034] New: Can't print macros defined on the command-line with binaries built with clang simark at simark dot ca
  2022-04-08  0:01 ` [Bug macros/29034] " tromey at sourceware dot org
@ 2022-04-08  0:07 ` tromey at sourceware dot org
  2022-04-18 19:17 ` blarsen at redhat dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at sourceware dot org @ 2022-04-08  0:07 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29034

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |26909


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=26909
[Bug 26909] [meta] Debug Clang-built code
-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug macros/29034] Can't print macros defined on the command-line with binaries built with clang
  2022-04-07  0:54 [Bug gdb/29034] New: Can't print macros defined on the command-line with binaries built with clang simark at simark dot ca
  2022-04-08  0:01 ` [Bug macros/29034] " tromey at sourceware dot org
  2022-04-08  0:07 ` tromey at sourceware dot org
@ 2022-04-18 19:17 ` blarsen at redhat dot com
  2022-11-03 13:14 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: blarsen at redhat dot com @ 2022-04-18 19:17 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29034

B. Larsen <blarsen at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blarsen at redhat dot com

--- Comment #1 from B. Larsen <blarsen at redhat dot com> ---
*** Bug 29063 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug macros/29034] Can't print macros defined on the command-line with binaries built with clang
  2022-04-07  0:54 [Bug gdb/29034] New: Can't print macros defined on the command-line with binaries built with clang simark at simark dot ca
                   ` (2 preceding siblings ...)
  2022-04-18 19:17 ` blarsen at redhat dot com
@ 2022-11-03 13:14 ` cvs-commit at gcc dot gnu.org
  2024-01-19 13:20 ` aburgess at redhat dot com
  2024-05-16 10:29 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-03 13:14 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29034

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Bruno Larsen <blarsen@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e7e7469e7a31bd5a406a03aa83a1cd648f5ef30d

commit e7e7469e7a31bd5a406a03aa83a1cd648f5ef30d
Author: Bruno Larsen <blarsen@redhat.com>
Date:   Wed Apr 20 14:41:11 2022 -0300

    gdb: Fix issue with Clang CLI macros

    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
    Approved-By: Simon Marchi <simon.marchi@efficios.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug macros/29034] Can't print macros defined on the command-line with binaries built with clang
  2022-04-07  0:54 [Bug gdb/29034] New: Can't print macros defined on the command-line with binaries built with clang simark at simark dot ca
                   ` (3 preceding siblings ...)
  2022-11-03 13:14 ` cvs-commit at gcc dot gnu.org
@ 2024-01-19 13:20 ` aburgess at redhat dot com
  2024-05-16 10:29 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: aburgess at redhat dot com @ 2024-01-19 13:20 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29034

Andrew Burgess <aburgess at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aburgess at redhat dot com

--- Comment #3 from Andrew Burgess <aburgess at redhat dot com> ---
Given we now have a work around for this issue in GDB, could we close this bug?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug macros/29034] Can't print macros defined on the command-line with binaries built with clang
  2022-04-07  0:54 [Bug gdb/29034] New: Can't print macros defined on the command-line with binaries built with clang simark at simark dot ca
                   ` (4 preceding siblings ...)
  2024-01-19 13:20 ` aburgess at redhat dot com
@ 2024-05-16 10:29 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2024-05-16 10:29 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29034

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vries at gcc dot gnu.org

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Andrew Burgess from comment #3)
> Given we now have a work around for this issue in GDB, could we close this
> bug?

AFAIU, what remains to be done is to wait for lldb to fix this issue, and to
limit the workaround to the broken versions.

I'm not sure if that is enough reason to keep this PR open.

The issue is already documented in the code like this:
...
              /* Clang, until the current version, misplaces some macro         
                 definitions - such as ones defined in the command line,        
                 putting them after the last DW_MACRO_end_file instead of       
                 before the first DW_MACRO_start_file.  Since at the time       
                 of writing there is no clang version with this bug fixed,      
                 we check for any clang producer.  This should be changed       
                 to producer_is_clang_lt_XX when possible. */
...

I propose to close the PR.  If we really want a PR open for this, we could file
a spin-off one, with for instance a tag in the subject "blocked on llvm" or
some such.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-16 10:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07  0:54 [Bug gdb/29034] New: Can't print macros defined on the command-line with binaries built with clang simark at simark dot ca
2022-04-08  0:01 ` [Bug macros/29034] " tromey at sourceware dot org
2022-04-08  0:07 ` tromey at sourceware dot org
2022-04-18 19:17 ` blarsen at redhat dot com
2022-11-03 13:14 ` cvs-commit at gcc dot gnu.org
2024-01-19 13:20 ` aburgess at redhat dot com
2024-05-16 10:29 ` vries at gcc dot gnu.org

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).