http://sourceware.org/ml/gdb-patches/2011-01/msg00507.html Subject: [patch] Fix DWARF-3+ DW_AT_accessibility default assumption Hi, GDB regresses on default compiler option -gdwarf-3 on gcc-4.6+ as this gcc started to omit DW_AT_accessibility for the default value case. Normal upstream gcc still has -gdwarf-2 default (Fedora uses -gdwarf-3 default). No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu. (There are other regressions to be fixed due to gcc45->gcc46.) I will check it in in some time. Thanks, Jan -FAIL: gdb.cp/casts.exp: dynamic_cast simple downcast -FAIL: gdb.cp/casts.exp: dynamic_cast simple downcast to intermediate class -FAIL: gdb.cp/casts.exp: dynamic_cast unique downcast -FAIL: gdb.cp/casts.exp: dynamic_cast to sibling -FAIL: gdb.cp/classes.exp: ptype class default_private_class // wrong access specifier for field: public -FAIL: gdb.cp/classes.exp: ptype class explicit_private_class // wrong access specifier for field: public -FAIL: gdb.cp/classes.exp: ptype class mixed_protection_class // wrong access specifier for field: public -FAIL: gdb.cp/virtfunc.exp: ptype A // wrong access specifier for field: public -FAIL: gdb.cp/virtfunc.exp: ptype B // wrong access specifier for field: public -FAIL: gdb.cp/virtfunc.exp: ptype a // wrong access specifier for field: public -FAIL: gdb.cp/virtfunc.exp: ptype b // wrong access specifier for field: public -FAIL: gdb.cp/virtfunc.exp: ptype pAa // wrong access specifier for field: public -FAIL: gdb.cp/virtfunc.exp: ptype pAe // wrong access specifier for field: public -FAIL: gdb.cp/virtfunc.exp: ptype pBe // wrong access specifier for field: public -FAIL: gdb.mi/gdb792.exp: list children of class A -FAIL: gdb.mi/gdb792.exp: list children of A.public -FAIL: gdb.mi/gdb792.exp: list children of A.private -FAIL: gdb.mi/gdb792.exp: list children of A.protected -FAIL: gdb.mi/gdb792.exp: list children of A.protected.b -FAIL: gdb.mi/gdb792.exp: list children of A.protected.b.public -FAIL: gdb.mi/gdb792.exp: list children of A.protected.b.private -FAIL: gdb.mi/gdb792.exp: list children of class C -FAIL: gdb.python/py-value.exp: python print bool(gdb.parse_and_eval('base').dynamic_cast(gdb.lookup_type('Derived').pointer())) gdb/ 2011-01-25 Jan Kratochvil Fix DWARF-3+ DW_AT_accessibility default assumption. * dwarf2read.c (dwarf2_add_field): Fix new_field->accessibility for cu->header.version >= 3. --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6186,13 +6186,25 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, } fip->nfields++; - /* 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; + 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; + } else - new_field->accessibility = DW_ACCESS_private; + { + /* 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->virtuality = DW_VIRTUALITY_none; attr = dwarf2_attr (die, DW_AT_accessibility, cu);