| Summary: | Unable to find static const class member variable after recent commit | ||
|---|---|---|---|
| Product: | gdb | Reporter: | Andrew Burgess <aburgess> |
| Component: | symtab | Assignee: | Tom Tromey <tromey> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | normal | CC: | ssbssa, vries |
| Priority: | P2 | ||
| Version: | HEAD | ||
| Target Milestone: | 18.1 | ||
| See Also: |
https://sourceware.org/bugzilla/show_bug.cgi?id=16994 https://sourceware.org/bugzilla/show_bug.cgi?id=16998 https://sourceware.org/bugzilla/show_bug.cgi?id=33447 https://sourceware.org/bugzilla/show_bug.cgi?id=33533 |
||
| Host: | Target: | ||
| Build: | Last reconfirmed: | ||
| Project(s) to access: | ssh public key: | ||
| Attachments: | New DWARF assembler test. | ||
I see a similar failure in gdb.cp/namespace.exp for the same reason; a static const class member variable described using DW_TAG_member in DWARF4, and GDB can no longer find it, and reports it as optimised out. I've tried out the test-case attached to this PR. I can reproduce the regression. With the v3 patch [1] for PR33415 applied, the regression disappears. Marking this a duplicate of PR33415. [1] https://sourceware.org/pipermail/gdb-patches/2025-November/222477.html *** This bug has been marked as a duplicate of bug 33415 *** |
Created attachment 16428 [details] New DWARF assembler test. After commit: commit 86ac8c546235a67d6a6bb29476a3a9ac8f7a620a (HEAD) Date: Thu Jan 2 15:28:18 2025 -0700 Convert lookup_symbol_in_objfile I noticed that the test gdb.cp/m-static.exp was showing 2 FAILs when using gcc 9.3.1 or 10.5.0. When using 11.5.0 the test completely passes. The difference appears to be that 11.x uses DWARF5 by default, while earlier compilers use DWARF4. And if I apply this patch: ----- START ----- diff --git i/gdb/testsuite/gdb.cp/m-static.exp w/gdb/testsuite/gdb.cp/m-static.exp index 6b108040da5..7cbbef1c7b3 100644 --- i/gdb/testsuite/gdb.cp/m-static.exp +++ w/gdb/testsuite/gdb.cp/m-static.exp @@ -35,6 +35,9 @@ if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } { lappend flags additional_flags=-fno-eliminate-unused-debug-types } +lappend flags additional_flags=-gdwarf-4 + + if {[prepare_for_testing "failed to prepare" $testfile \ [list $srcfile $srcfile2] $flags]} { return -1 ----- END ----- And retest with gcc 11.5.0, I now see 1 FAIL (this is one of the failures I also see with earlier compilers). The problem appears to relate to the way that static const class member variables are represented in the DWARF. With DWARF4 DW_TAG_member is used for both static and non-static member variables, while with DWARF5 DW_TAG_member is used for non-static member variables, and DW_TAG_variable is used for static member variables. The attached patch makes use of GDB's DWARF assembler to create a test representing the issue I'm seeing. This should run with any compiler version (as expected for the DWARF assembler). Do feel free to make use of this test in any fix if this is useful. When running the new test using current HEAD of GDB I see this failure: (gdb) print value $1 = {static one = <optimized out>, two = 1} (gdb) FAIL: gdb.dwarf2/dwarf4-struct-member.exp: check contents of 'value' The <optimized out> is wrong; it should have the value 317. With commit c879f4dc3e317cf6353a45a803ecf00d577a13d8 I see this: (gdb) print value $1 = {static one = 317, two = 1} (gdb) PASS: gdb.dwarf2/dwarf4-struct-member.exp: check contents of 'value' Setting the target milestone as 18 for this bug as this is a regression from GDB 17.