public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "gandalf at winds dot org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug macros/29606] New: [dwarf-5] Missing line information for evaluating macros Date: Fri, 23 Sep 2022 15:23:51 +0000 [thread overview] Message-ID: <bug-29606-4717@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2022-09-23 15:23 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-23 15:23 gandalf at winds dot org [this message] 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
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=bug-29606-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@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: linkBe 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).