Fix incomplete/incorrect type lookup.

- Add accesor to CompoundType to expose the particular compound kind.

- Implement aforementioned accessor in DwarfCompoundType, and ensure
  DwarfTypeFactory populates it appropriately.

- Modify GlobalTypeLookup to make use of the address and compound
  subtype kinds when trying to match a type.

Due to the lack of matching against the subtype, we would previously wind
up matching anonymous compound types against those of their parents, resulting
in the wrong type getting assigned to their value nodes.

Fixes #8190.
This commit is contained in:
Rene Gollent
2011-12-07 21:54:44 -05:00
parent 8cfe0f458c
commit be63c91230
6 changed files with 41 additions and 7 deletions
@@ -374,7 +374,9 @@ DwarfTypeFactory::_CreateTypeInternal(const BString& name,
case DW_TAG_union_type:
case DW_TAG_interface_type:
return _CreateCompoundType(name,
dynamic_cast<DIECompoundType*>(typeEntry), _type);
dynamic_cast<DIECompoundType*>(typeEntry),
(compound_type_kind)dwarf_tag_to_subtype_kind(
typeEntry->Tag()), _type);
case DW_TAG_base_type:
return _CreatePrimitiveType(name,
@@ -451,14 +453,14 @@ DwarfTypeFactory::_CreateTypeInternal(const BString& name,
status_t
DwarfTypeFactory::_CreateCompoundType(const BString& name,
DIECompoundType* typeEntry, DwarfType*& _type)
DIECompoundType* typeEntry, compound_type_kind compoundKind, DwarfType*& _type)
{
TRACE_LOCALS("DwarfTypeFactory::_CreateCompoundType(\"%s\", %p)\n",
name.String(), typeEntry);
TRACE_LOCALS("DwarfTypeFactory::_CreateCompoundType(\"%s\", %p, %d)\n",
name.String(), typeEntry, compoundKind);
// create the type
DwarfCompoundType* type = new(std::nothrow) DwarfCompoundType(fTypeContext,
name, typeEntry);
name, typeEntry, compoundKind);
if (type == NULL)
return B_NO_MEMORY;
BReference<DwarfCompoundType> typeReference(type, true);
@@ -70,6 +70,7 @@ private:
status_t _CreateCompoundType(const BString& name,
DIECompoundType* typeEntry,
compound_type_kind compoundKind,
DwarfType*& _type);
status_t _CreatePrimitiveType(const BString& name,
DIEBaseType* typeEntry,
+10 -1
View File
@@ -532,9 +532,11 @@ DwarfPrimitiveType::TypeConstant() const
DwarfCompoundType::DwarfCompoundType(DwarfTypeContext* typeContext,
const BString& name, DIECompoundType* entry)
const BString& name, DIECompoundType* entry,
compound_type_kind compoundKind)
:
DwarfType(typeContext, name, entry),
fCompoundKind(compoundKind),
fEntry(entry)
{
}
@@ -551,6 +553,13 @@ DwarfCompoundType::~DwarfCompoundType()
}
compound_type_kind
DwarfCompoundType::CompoundKind() const
{
return fCompoundKind;
}
int32
DwarfCompoundType::CountBaseTypes() const
{
+5 -1
View File
@@ -254,9 +254,12 @@ private:
class DwarfCompoundType : public CompoundType, public DwarfType {
public:
DwarfCompoundType(DwarfTypeContext* typeContext,
const BString& name, DIECompoundType* entry);
const BString& name, DIECompoundType* entry,
compound_type_kind compoundKind);
~DwarfCompoundType();
virtual compound_type_kind CompoundKind() const;
virtual int32 CountBaseTypes() const;
virtual BaseType* BaseTypeAt(int32 index) const;
@@ -290,6 +293,7 @@ private:
ValueLocation*& _location);
private:
compound_type_kind fCompoundKind;
DIECompoundType* fEntry;
InheritanceList fInheritances;
DataMemberList fDataMembers;
@@ -156,6 +156,23 @@ GlobalTypeCache::GetType(const BString& name,
if (constraints.HasTypeKind()
&& typeEntry->type->Kind() != constraints.TypeKind())
typeEntry = NULL;
else if (constraints.HasSubtypeKind()) {
if (typeEntry->type->Kind() == TYPE_ADDRESS) {
AddressType* type = dynamic_cast<AddressType*>(
typeEntry->type);
if (type == NULL)
typeEntry = NULL;
else if (type->AddressKind() != constraints.SubtypeKind())
typeEntry = NULL;
} else if (typeEntry->type->Kind() == TYPE_COMPOUND) {
CompoundType* type = dynamic_cast<CompoundType*>(
typeEntry->type);
if (type == NULL)
typeEntry = NULL;
else if (type->CompoundKind() != constraints.SubtypeKind())
typeEntry = NULL;
}
}
}
return typeEntry != NULL ? typeEntry->type : NULL;
}
+1
View File
@@ -143,6 +143,7 @@ public:
virtual ~CompoundType();
virtual type_kind Kind() const;
virtual compound_type_kind CompoundKind() const = 0;
virtual int32 CountBaseTypes() const = 0;
virtual BaseType* BaseTypeAt(int32 index) const = 0;