Bug 45124 - No DW_AT_accessibility for public DIEs in DW_TAG_class_type
Summary: No DW_AT_accessibility for public DIEs in DW_TAG_class_type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords: wrong-debug
Depends on:
Blocks: 48049
  Show dependency treegraph
 
Reported: 2010-07-29 08:31 UTC by Jakub Jelinek
Modified: 2011-03-09 16:13 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-07-29 08:55:14


Attachments
gcc46-pr45124.patch (717 bytes, patch)
2010-07-29 08:58 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2010-07-29 08:31:51 UTC
Dwarf 3 and 4 state that if DW_AT_accessibility is missing, the default is
DW_ACCESS_private in DW_TAG_class_type and DW_ACCESS_public otherwise.
Unfortunately dwarf2out.c assumes the default is DW_ACCESS_public always.
Not sure if GDB (or other dwarf consumers) makes the same assumption.
If not, then we can add DW_ACCESS_public DW_AT_accessibility in DW_TAG_class_type for everything that didn't have it till now and drop DW_ACCESS_private accessibility, if yes, then I'm afraid all we can do for the time being is just add DW_ACCESS_public accessibility and keep DW_ACCESS_private accessibility too.
Comment 1 Jakub Jelinek 2010-07-29 08:55:14 UTC
Looking at GDB:
  /* Handle accessibility and virtuality of field.
     The default accessibility for members is public, the default
     accessibility for inheritance is private.  */
  if (die->tag != DW_TAG_inheritance)
    new_field->accessibility = DW_ACCESS_public;
  else
    new_field->accessibility = DW_ACCESS_private;

i.e. it seems to match what GCC (wrongly) does.
I'm afraid we need to live with some extra DW_AT_accessibility attributes for compatibility.
Comment 2 Jakub Jelinek 2010-07-29 08:58:07 UTC
Created attachment 21346 [details]
gcc46-pr45124.patch

Untested fix.
Comment 3 Jakub Jelinek 2010-09-20 16:48:50 UTC
Subject: Bug 45124

Author: jakub
Date: Mon Sep 20 16:48:29 2010
New Revision: 164442

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=164442
Log:
	PR debug/45124
	* dwarf2out.c (add_accessibility_attribute): Assume
	DW_ACCESS_private as the default for dwarf_version > 2
	and DW_TAG_class_type parent.
	(gen_inheritance_die): Assume DW_ACCESS_public as the default
	for dwarf_version > 2 and parent other than DW_TAG_class_type.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c

Comment 4 Jakub Jelinek 2010-09-20 16:51:31 UTC
Fixed.
Comment 5 Jan Kratochvil 2011-01-24 10:41:17 UTC
DWARF3 leaves the meaning for struct/union unspecified:
An inheritance entry may have a DW_AT_accessibility attribute. If no accessibility attribute is present, private access is assumed for an entry of a class and public access is assumed for an entry of an interface.

DWARF4 specifies:
An inheritance entry may have a DW_AT_accessibility attribute. If no accessibility attribute is present, private access is assumed for an entry of a class and public access is assumed for an entry of an interface, struct or union.

DWARF2 had:
An inheritance entry may have a DW_AT_accessibility attribute. If no accessibility attribute is present, private access is assumed.

So I guess DWARF3 was meant like what DWARF4 says and GDB should be changed for both DWARF3 and DWARF4.