From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D11D23857B8D; Fri, 23 Sep 2022 15:23:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D11D23857B8D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663946632; bh=rU7ZLCI+Ped5P3WhFCxvUCuMThNjZXI1MT+y4IfsdzM=; h=From:To:Subject:Date:From; b=oGtzfM7RQOuA6MTc/8+VNHFv0ULgsaj1KaLWhxpksQuf+NFL06do7OIslf/aLeiTO 2+hSjyoKzEojeAdHTyG5wZesQa0o9WTPbyOOj8szzCyBVe+h2IVLPKdnNKuqT1i0uu EEBHtF8zqrTLaGyKMEn2h8fstOJtXBBTXZgwpnQU= From: "gandalf at winds dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: macros X-Bugzilla-Version: 12.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gandalf at winds dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29606 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=3D14355&action=3Ded= it 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 w= e'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" produc= es 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 macr= o.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=20 GNU gdb (Gentoo 12.1 vanilla) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later 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: . Find the GDB manual and other documentation resources online at: . 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=20 [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 =3D 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 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: . Find the GDB manual and other documentation resources online at: . 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=20 [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 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=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapp= er Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-12.2.0/work/gcc-12.2.0/configure --host=3Dx86_64-pc-linux-gnu --build=3Dx86_64-pc-linux-gnu --prefix=3D/usr --bindir=3D/usr/x86_64-pc-linux-gnu/gcc-bin/12.2.0 --includedir=3D/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include --datadir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/12.2.0 --mandir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/12.2.0/man --infodir=3D/usr/share/gcc-data/x86_64-pc-linux-gnu/12.2.0/info --with-gxx-include-dir=3D/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/g+= +-v12 --with-python-dir=3D/share/gcc-data/x86_64-pc-linux-gnu/12.2.0/python --enable-languages=3Dc,c++ --enable-obsolete --enable-secureplt --disable-w= error --with-system-zlib --disable-nls --disable-libunwind-exceptions --enable-checking=3Drelease --with-bugurl=3Dhttps://bugs.gentoo.org/ --with-pkgversion=3D'Gentoo 12.2.0 p1' --disable-esp --enable-libstdcxx-time --disable-libstdcxx-pch --enable-shared --enable-threads=3Dposix --enable-__cxa_atexit --enable-clocale=3Dgnu --enable-multilib --with-multilib-list=3Dm32,m64 --disable-fixed-point --enable-targets=3Dall --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-libsaniti= zer --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)=20 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=3D107012 This might be a duplicate of bug 27966. Thanks! --=20 You are receiving this mail because: You are on the CC list for the bug.=