public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug macros/29606] New: [dwarf-5] Missing line information for evaluating macros
@ 2022-09-23 15:23 gandalf at winds dot org
  2022-09-23 15:24 ` [Bug macros/29606] " gandalf at winds dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gandalf at winds dot org @ 2022-09-23 15:23 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 29606
           Summary: [dwarf-5] Missing line information for evaluating
                    macros
           Product: gdb
           Version: 12.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: macros
          Assignee: unassigned at sourceware dot org
          Reporter: gandalf at winds dot org
  Target Milestone: ---

Created attachment 14355
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14355&action=edit
objdump output for dwarf-4

GCC 12 now defaults to outputting debug information via dwarf-5. Compared to
dwarf-4 (which works), gdb's interpretation of dwarf-5 seems to show that we're
missing the correct line information, which causes gdb to not be able to
correctly find and evaluate a macro on the command line due to being in the
wrong context. It's not clear whether gcc is not correctly emitting all the
information, or if gdb is not correctly reading all the information.

Breaking at the "main" function and attempting to run "info macro X" produces
the error message, "The symbol `X' has no definition as a C/C++ preprocessor
macro at macro.c:-1".

The same behavior happens when breaking at any other point in a C program, and
not just at "main".

In both examples below, the breakpoint output shows we're at line 5 in macro.c:

$ cat macro.c
#define TEST_MACRO 42

int main()
{
  return 0;
}

### DWARF-4 Example ###

$ gcc -O3 -ggdb3 -gdwarf-4 macro.c -o macro
$ gdb macro 
GNU gdb (Gentoo 12.1 vanilla) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from macro...
(gdb) break main
Breakpoint 1 at 0x401020: file macro.c, line 5.
(gdb) run
Starting program: /g/macro 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, main () at macro.c:5
5         return 0;
(gdb) info macro TEST_MACRO
Defined at /g/macro.c:1
#define TEST_MACRO 42
(gdb) p TEST_MACRO
$1 = 42
(gdb) quit

### DWARF-5 EXAMPLE ###

$ gcc -O3 -ggdb3 -gdwarf-5 macro.c -o macro
$ gdb macro
GNU gdb (Gentoo 12.1 vanilla) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from macro...
(gdb) break main
Breakpoint 1 at 0x401020: file macro.c, line 5.
(gdb) run
Starting program: /g/macro 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, main () at macro.c:5
5         return 0;
(gdb) info macro TEST_MACRO
The symbol `TEST_MACRO' has no definition as a C/C++ preprocessor macro
at /g/macro.c:-1
(gdb) p TEST_MACRO
No symbol "TEST_MACRO" in current context.
(gdb) quit


Software versions:

$ gdb -v
GNU gdb (Gentoo 12.1 vanilla) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-12.2.0/work/gcc-12.2.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/12.2.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12.2.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12.2.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12.2.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/g++-v12
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/12.2.0/python
--enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror
--with-system-zlib --disable-nls --disable-libunwind-exceptions
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 12.2.0 p1' --disable-esp --enable-libstdcxx-time
--disable-libstdcxx-pch --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-multilib
--with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all
--enable-libgomp --disable-libssp --disable-libada --disable-cet
--disable-systemtap --disable-valgrind-annotations --disable-vtable-verify
--disable-libvtv --with-zstd --enable-lto --without-isl --disable-libsanitizer
--disable-default-pie --disable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Gentoo 12.2.0 p1) 

I've attached the output of "objdump -g macro" for both dwarf-4 and dwarf-5.

I also filed this as a gcc bug report, and Jakub thinks it's a gdb problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107012

This might be a duplicate of bug 27966.

Thanks!

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

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

* [Bug macros/29606] [dwarf-5] Missing line information for evaluating macros
  2022-09-23 15:23 [Bug macros/29606] New: [dwarf-5] Missing line information for evaluating macros gandalf at winds dot org
@ 2022-09-23 15:24 ` gandalf at winds dot org
  2022-09-23 15:27 ` simark at simark dot ca
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: gandalf at winds dot org @ 2022-09-23 15:24 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Byron Stanoszek <gandalf at winds dot org> ---
Created attachment 14356
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14356&action=edit
objdump output for dwarf-5

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

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

* [Bug macros/29606] [dwarf-5] Missing line information for evaluating macros
  2022-09-23 15:23 [Bug macros/29606] New: [dwarf-5] Missing line information for evaluating macros gandalf at winds dot org
  2022-09-23 15:24 ` [Bug macros/29606] " gandalf at winds dot org
@ 2022-09-23 15:27 ` simark at simark dot ca
  2022-12-25 20:02 ` tromey at sourceware dot org
  2023-03-17 15:16 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: simark at simark dot ca @ 2022-09-23 15:27 UTC (permalink / raw)
  To: gdb-prs

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

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca

--- Comment #2 from Simon Marchi <simark at simark dot ca> ---
Have you tried with master?  I think this is fixed by this series (already
merged):

https://inbox.sourceware.org/gdb-patches/20220428033542.1636284-1-simon.marchi@polymtl.ca/

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

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

* [Bug macros/29606] [dwarf-5] Missing line information for evaluating macros
  2022-09-23 15:23 [Bug macros/29606] New: [dwarf-5] Missing line information for evaluating macros gandalf at winds dot org
  2022-09-23 15:24 ` [Bug macros/29606] " gandalf at winds dot org
  2022-09-23 15:27 ` simark at simark dot ca
@ 2022-12-25 20:02 ` tromey at sourceware dot org
  2023-03-17 15:16 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2022-12-25 20:02 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org
   Target Milestone|---                         |13.1
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
This works for me with gdb 13:

(gdb) info macro TEST_MACRO
Defined at /home/tromey/gdb/PRS/dwarf-5-macro-29606/macro.c:1
#define TEST_MACRO 42

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

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

* [Bug macros/29606] [dwarf-5] Missing line information for evaluating macros
  2022-09-23 15:23 [Bug macros/29606] New: [dwarf-5] Missing line information for evaluating macros gandalf at winds dot org
                   ` (2 preceding siblings ...)
  2022-12-25 20:02 ` tromey at sourceware dot org
@ 2023-03-17 15:16 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2023-03-17 15:16 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |czgf2v at 163 dot com

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
*** Bug 30239 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] 5+ messages in thread

end of thread, other threads:[~2023-03-17 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 15:23 [Bug macros/29606] New: [dwarf-5] Missing line information for evaluating macros gandalf at winds dot org
2022-09-23 15:24 ` [Bug macros/29606] " gandalf at winds dot org
2022-09-23 15:27 ` simark at simark dot ca
2022-12-25 20:02 ` tromey at sourceware dot org
2023-03-17 15:16 ` tromey at sourceware dot 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).