This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] dwarf2_add_field: static const members w/o DW_AT_external
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Date: Tue, 29 Jun 2010 23:14:17 -0700 (PDT)
- Subject: [commit] dwarf2_add_field: static const members w/o DW_AT_external
Hi.
This is a patch to my fix of:
http://sourceware.org/ml/gdb-patches/2010-06/msg00677.html
gcc 4.4.0 (plus some local patches) was emitting a die for a
static const member that didn't have DW_AT_external and this
crashed new_symbol.
This takes a conservative route and only records static const members
that are marked DW_AT_external.
2010-06-29 Doug Evans <dje@google.com>
PR gdb/11702
* dwarf2read.c (dwarf2_add_field): Only create a symbol if
DW_AT_external is present.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.408
diff -u -p -r1.408 dwarf2read.c
--- dwarf2read.c 29 Jun 2010 16:53:09 -0000 1.408
+++ dwarf2read.c 30 Jun 2010 05:30:02 -0000
@@ -4528,11 +4528,6 @@ dwarf2_add_field (struct field_info *fip
fp = &new_field->field;
- /* NOTE: According to the dwarf standard, static data members are
- indicated by having DW_AT_external.
- The check here for ! die_is_declaration is historical.
- This test is replicated in new_symbol. */
-
if (die->tag == DW_TAG_member && ! die_is_declaration (die, cu))
{
/* Data member other than a C++ static data member. */
@@ -4649,7 +4644,12 @@ dwarf2_add_field (struct field_info *fip
return;
attr = dwarf2_attr (die, DW_AT_const_value, cu);
- if (attr)
+ if (attr
+ /* Only create a symbol if this is an external value.
+ new_symbol checks this and puts the value in the global symbol
+ table, which we want. If it is not external, new_symbol
+ will try to put the value in cu->list_in_scope which is wrong. */
+ && dwarf2_flag_true_p (die, DW_AT_external, cu))
{
/* A static const member, not much different than an enum as far as
we're concerned, except that we can support more types. */
@@ -8850,10 +8850,8 @@ new_symbol (struct die_info *die, struct
static const members. */
if (die->tag == DW_TAG_member)
{
- /* NOTE: This test seems wrong according to the dwarf standard.
- static data members are represented by DW_AT_external.
- However, dwarf2_add_field is currently calling
- die_is_declaration to check, so we do the same. */
+ /* dwarf2_add_field uses die_is_declaration,
+ so we do the same. */
gdb_assert (die_is_declaration (die, cu));
gdb_assert (attr);
}