From 7d0ccb613385c0bbba25479f37003944772d3b90 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Thu, 12 Nov 2009 19:05:28 +0000 Subject: [PATCH] 2009-11-12 Paul Brook Daniel Jacobowitz * dwarf2read.c (struct field_info): Add baseclasses. (dwarf2_add_field): Add base classes to a separate list. (dwarf2_attach_fields_to_type): Merge base classes and fields. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2read.c | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5133e360020..f8fadf6f251 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2009-11-12 Paul Brook + Daniel Jacobowitz + + * dwarf2read.c (struct field_info): Add baseclasses. + (dwarf2_add_field): Add base classes to a separate list. + (dwarf2_attach_fields_to_type): Merge base classes and fields. + 2009-11-12 Daniel Jacobowitz * dwarf2read.c (process_psymtab_comp_unit): Initialize per_cu backlink diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index e856a4b3282..8ba61b1a688 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -639,9 +639,9 @@ struct field_info int virtuality; struct field field; } - *fields; + *fields, *baseclasses; - /* Number of fields. */ + /* Number of fields (including baseclasses). */ int nfields; /* Number of baseclasses. */ @@ -4357,8 +4357,17 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, new_field = (struct nextfield *) xmalloc (sizeof (struct nextfield)); make_cleanup (xfree, new_field); memset (new_field, 0, sizeof (struct nextfield)); - new_field->next = fip->fields; - fip->fields = new_field; + + if (die->tag == DW_TAG_inheritance) + { + new_field->next = fip->baseclasses; + fip->baseclasses = new_field; + } + else + { + new_field->next = fip->fields; + fip->fields = new_field; + } fip->nfields++; /* Handle accessibility and virtuality of field. @@ -4581,8 +4590,21 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, up in the same order in the array in which they were added to the list. */ while (nfields-- > 0) { - TYPE_FIELD (type, nfields) = fip->fields->field; - switch (fip->fields->accessibility) + struct nextfield *fieldp; + + if (fip->fields) + { + fieldp = fip->fields; + fip->fields = fieldp->next; + } + else + { + fieldp = fip->baseclasses; + fip->baseclasses = fieldp->next; + } + + TYPE_FIELD (type, nfields) = fieldp->field; + switch (fieldp->accessibility) { case DW_ACCESS_private: SET_TYPE_FIELD_PRIVATE (type, nfields); @@ -4599,13 +4621,13 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, /* Unknown accessibility. Complain and treat it as public. */ { complaint (&symfile_complaints, _("unsupported accessibility %d"), - fip->fields->accessibility); + fieldp->accessibility); } break; } if (nfields < fip->nbaseclasses) { - switch (fip->fields->virtuality) + switch (fieldp->virtuality) { case DW_VIRTUALITY_virtual: case DW_VIRTUALITY_pure_virtual: @@ -4613,7 +4635,6 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type, break; } } - fip->fields = fip->fields->next; } } -- 2.30.2