public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26525] New: DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable.
@ 2020-08-23 11:13 mark at klomp dot org
  2020-08-24 19:52 ` [Bug c++/26525] " tromey at sourceware dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: mark at klomp dot org @ 2020-08-23 11:13 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 26525
           Summary: DWARF5 class variables are not data members,
                    DW_TAG_member, but DW_TAG_variable.
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: mark at klomp dot org
  Target Milestone: ---

Before DWARF5 there was no description of class variables (static data members)
and gcc would emit a DW_TAG_member for the class variables as if the were
non-static data members.

DWARF5, section 5.7.7 Class Variable Entries, says they are represented by a
DW_TAG_variable.

GCC has the following in dwarf2out.c:

  /* For static data members, the declaration in the class is supposed          
     to have DW_TAG_member tag in DWARF{3,4} and we emit it for compatibility   
     also in DWARF2; the specification should still be DW_TAG_variable          
     referencing the DW_TAG_member DIE.  */
  if (declaration && class_scope_p (context_die) && dwarf_version < 5)
    var_die = new_die (DW_TAG_member, context_die, decl);
  else
    var_die = new_die (DW_TAG_variable, context_die, decl);

  if (origin != NULL)
    add_abstract_origin_attribute (var_die, origin);

This means that when building with -gdwarf-5 there no longer is a DW_TAG_member
for static data members, but an DW_TAG_variable (which can be optimized away
when not referenced). This causes the following testsuite failures:

FAIL: gdb.base/ptype-offsets.exp: ptype/o static_member
FAIL: gdb.cp/constexpr-field.exp: print y
FAIL: gdb.cp/m-static.exp: static const int initialized nowhere (print field)
FAIL: gdb.cp/m-static.exp: ptype test4.nowhere
FAIL: gdb.cp/m-static.exp: print test4.nowhere.nowhere
FAIL: gdb.cp/m-static.exp: static const int initialized nowhere (whole struct)
FAIL: gdb.cp/m-static.exp: static const int initialized in class definition
FAIL: gdb.cp/m-static.exp: static const float initialized in class definition
FAIL: gdb.cp/m-static.exp: info variable everywhere
FAIL: gdb.cp/namespace.exp: print C::OtherFileClass::cOtherFileClassVar
FAIL: gdb.cp/namespace.exp: print ::C::OtherFileClass::cOtherFileClassVar
FAIL: gdb.cp/namespace.exp: ptype ::C::OtherFileClass typedefs
FAIL: gdb.cp/namespace.exp: ptype OtherFileClass typedefs
FAIL: gdb.cp/pr-574.exp: PR gdb/574
FAIL: gdb.cp/pr9167.exp: p b
FAIL: gdb.cp/templates.exp: ptype T5<int>
FAIL: gdb.cp/templates.exp: ptype t5i

-- 
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 c++/26525] DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable.
  2020-08-23 11:13 [Bug c++/26525] New: DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable mark at klomp dot org
@ 2020-08-24 19:52 ` tromey at sourceware dot org
  2020-08-24 20:04 ` tromey at sourceware dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2020-08-24 19:52 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Mark Wielaard from comment #0)

> FAIL: gdb.base/ptype-offsets.exp: ptype/o static_member

The member isn't defined; this works:

diff --git a/gdb/testsuite/gdb.base/ptype-offsets.cc
b/gdb/testsuite/gdb.base/ptype-offsets.cc
index ddb009f1ae5..b686c9bdc3a 100644
--- a/gdb/testsuite/gdb.base/ptype-offsets.cc
+++ b/gdb/testsuite/gdb.base/ptype-offsets.cc
@@ -185,6 +185,8 @@ struct static_member
   int abc;
 };

+static_member static_member::Empty;
+
 int
 main (int argc, char *argv[])
 {


> FAIL: gdb.cp/constexpr-field.exp: print y

This one is weird, the constexpr fields aren't described in the DWARF.
Maybe a test change is needed, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90526#c1

> FAIL: gdb.cp/m-static.exp: static const int initialized nowhere (print field)
> FAIL: gdb.cp/m-static.exp: ptype test4.nowhere
> FAIL: gdb.cp/m-static.exp: print test4.nowhere.nowhere
> FAIL: gdb.cp/m-static.exp: static const int initialized nowhere (whole
> struct)
> FAIL: gdb.cp/m-static.exp: static const int initialized in class definition
> FAIL: gdb.cp/m-static.exp: static const float initialized in class definition
> FAIL: gdb.cp/m-static.exp: info variable everywhere

The "nowhere" failures are because this member is declared but not defined,
and gdb expects it to be <optimized out>.  So arguably a compiler perhaps but
also just a weird test.

I didn't look at the rest.  I think the basic feature is probably fine and
we're just seeing a difference between the test suite's expectations and what
gcc has started doing in some corner cases.

-- 
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 c++/26525] DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable.
  2020-08-23 11:13 [Bug c++/26525] New: DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable mark at klomp dot org
  2020-08-24 19:52 ` [Bug c++/26525] " tromey at sourceware dot org
@ 2020-08-24 20:04 ` tromey at sourceware dot org
  2020-08-24 20:22 ` mark at klomp dot org
  2020-08-26 14:46 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2020-08-24 20:04 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
Seems like Jakub thinks this is a gcc bug:
https://gcc.gnu.org/pipermail/gcc-patches/2020-August/552502.html

-- 
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 c++/26525] DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable.
  2020-08-23 11:13 [Bug c++/26525] New: DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable mark at klomp dot org
  2020-08-24 19:52 ` [Bug c++/26525] " tromey at sourceware dot org
  2020-08-24 20:04 ` tromey at sourceware dot org
@ 2020-08-24 20:22 ` mark at klomp dot org
  2020-08-26 14:46 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: mark at klomp dot org @ 2020-08-24 20:22 UTC (permalink / raw)
  To: gdb-prs

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jakub at redhat dot com,
                   |                            |jason at redhat dot com
         Resolution|---                         |INVALID

--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
(In reply to Tom Tromey from comment #2)
> Seems like Jakub thinks this is a gcc bug:
> https://gcc.gnu.org/pipermail/gcc-patches/2020-August/552502.html

And his proposed gcc patch turns all the FAILs from description into PASSes
(when building the gdb testsuite with -gdwarf-5 as default). So I'll close 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

* [Bug c++/26525] DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable.
  2020-08-23 11:13 [Bug c++/26525] New: DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable mark at klomp dot org
                   ` (2 preceding siblings ...)
  2020-08-24 20:22 ` mark at klomp dot org
@ 2020-08-26 14:46 ` tromey at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2020-08-26 14:46 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Thank you for trying this out, it was very helpful.

-- 
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:[~2020-08-26 14:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-23 11:13 [Bug c++/26525] New: DWARF5 class variables are not data members, DW_TAG_member, but DW_TAG_variable mark at klomp dot org
2020-08-24 19:52 ` [Bug c++/26525] " tromey at sourceware dot org
2020-08-24 20:04 ` tromey at sourceware dot org
2020-08-24 20:22 ` mark at klomp dot org
2020-08-26 14:46 ` 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).