revert: Re: [patch] Fix DWARF-3+ DW_AT_accessibility default assumption

Jan Kratochvil
2011-03-09T07:12:28Z

On Tue, 08 Mar 2011 18:55:50 +0100, Jan Kratochvil wrote:
> Checked in. Dealing with testsuite results on FSF GDB was difficult.
> http://sourceware.org/ml/gdb-cvs/2011-03/msg00115.html

Reverted. It broke compatibility with `gcc-4.5 -gdwarf-3'.

gcc-4.5 violates DWARF:
<1><2d>: Abbrev Number: 2 (DW_TAG_class_type)
<2e> DW_AT_name : C
<30> DW_AT_byte_size : 4
<2><37>: Abbrev Number: 3 (DW_TAG_member)
<38> DW_AT_name : (indirect string, offset: 0x0): public_
<3e> DW_AT_type : <0x44>
<42> DW_AT_data_member_location: 0

DWARF-4 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.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45124

There will probably need to be a DW_AT_producer check.

Sorry,
Jan

http://sourceware.org/ml/gdb-cvs/2011-03/msg00128.html

--- src/gdb/ChangeLog 2011/03/09 06:24:05 1.12775
+++ src/gdb/ChangeLog 2011/03/09 07:07:53 1.12776
@@ -1,3 +1,11 @@
+2011-03-09 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Revert:
+ 2011-03-08 Jan Kratochvil <jan.kratochvil@redhat.com>
+ Fix DWARF-3+ DW_AT_accessibility default assumption.
+ * dwarf2read.c (dwarf2_add_field): Fix new_field->accessibility for
+ cu->header.version >= 3.
+
2011-03-09 Yao Qi <yao@codesourcery.com>

* common/Makefile.in: Remove.
--- src/gdb/dwarf2read.c 2011/03/08 17:54:44 1.507
+++ src/gdb/dwarf2read.c 2011/03/09 07:07:55 1.508
@@ -6238,25 +6238,13 @@
}
fip->nfields++;

- if (cu->header.version < 3)
- {
- /* The default DWARF 2 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;
- }
+ /* 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
- {
- /* DWARF 3 specifies the default accessibility explicitly. */
-
- if (die->parent->tag == DW_TAG_class_type)
- new_field->accessibility = DW_ACCESS_private;
- else
- new_field->accessibility = DW_ACCESS_public;
- }
+ new_field->accessibility = DW_ACCESS_private;
new_field->virtuality = DW_VIRTUALITY_none;

attr = dwarf2_attr (die, DW_AT_accessibility, cu);