Debugger: DwarfFile: Fix DWARF4 signature handling.
Depending on how the type unit was actually set up hierarchically, we sometimes ended up with the unit set to the wrong actual type object. Instead, we now simply let the unit parse, and then look up the entry by the offset specified in the header after all is said and done. Fixes class/struct objects sometimes winding up resolving to one of their members instead. Some problems still remain with resolving variable values for such types though, needs further investigation.
This commit is contained in:
@@ -2549,16 +2549,6 @@ DIETypeUnit::Tag() const
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DIETypeUnit::AddChild(DebugInfoEntry* child)
|
||||
{
|
||||
if (child->IsType())
|
||||
fType = dynamic_cast<DIEType*>(child);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DIETypeUnit::AddAttribute_language(uint16 attributeName,
|
||||
const AttributeValue& value)
|
||||
|
||||
@@ -1614,16 +1614,11 @@ public:
|
||||
|
||||
uint16 Language() const { return fLanguage; }
|
||||
|
||||
virtual status_t AddChild(DebugInfoEntry* child);
|
||||
|
||||
virtual status_t AddAttribute_language(uint16 attributeName,
|
||||
const AttributeValue& value);
|
||||
inline DIEType* GetType() const { return fType; }
|
||||
|
||||
|
||||
private:
|
||||
uint16 fLanguage;
|
||||
DIEType* fType;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1142,6 +1142,13 @@ DwarfFile::_ParseTypeUnit(TypeUnit* unit)
|
||||
}
|
||||
|
||||
unit->SetUnitEntry(unitEntry);
|
||||
DebugInfoEntry* typeEntry = unit->EntryForOffset(unit->TypeOffset());
|
||||
if (typeEntry == NULL) {
|
||||
WARNING("No type found for type unit %p at specified offset %"
|
||||
B_PRId64 ".\n", unit, unit->TypeOffset());
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
unit->SetTypeEntry(typeEntry);
|
||||
|
||||
TRACE_DIE_ONLY(
|
||||
TRACE_DIE("remaining bytes in unit: %" B_PRIdOFF "\n",
|
||||
@@ -2591,6 +2598,7 @@ DwarfFile::_ResolveReference(BaseUnit* unit, uint64 offset,
|
||||
}
|
||||
case dwarf_reference_type_signature:
|
||||
{
|
||||
TRACE_DIE("Resolving signature %#" B_PRIx64 "\n", offset);
|
||||
TypeUnitTableEntry* entry = fTypeUnits.Lookup(offset);
|
||||
if (entry != NULL && entry->unit != NULL)
|
||||
return entry->unit->TypeEntry();
|
||||
|
||||
@@ -16,6 +16,7 @@ TypeUnit::TypeUnit(off_t headerOffset, off_t contentOffset,
|
||||
BaseUnit(headerOffset, contentOffset, totalSize, abbreviationOffset,
|
||||
addressSize, isDwarf64),
|
||||
fUnitEntry(NULL),
|
||||
fTypeEntry(NULL),
|
||||
fSignature(signature),
|
||||
fTypeOffset(typeOffset)
|
||||
{
|
||||
@@ -37,10 +38,14 @@ TypeUnit::SetUnitEntry(DIETypeUnit* entry)
|
||||
DebugInfoEntry*
|
||||
TypeUnit::TypeEntry() const
|
||||
{
|
||||
if (fUnitEntry != NULL)
|
||||
return fUnitEntry->GetType();
|
||||
return fTypeEntry;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
void
|
||||
TypeUnit::SetTypeEntry(DebugInfoEntry* entry)
|
||||
{
|
||||
fTypeEntry = entry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,11 +36,13 @@ public:
|
||||
void SetUnitEntry(DIETypeUnit* entry);
|
||||
|
||||
DebugInfoEntry* TypeEntry() const;
|
||||
void SetTypeEntry(DebugInfoEntry* entry);
|
||||
|
||||
virtual dwarf_unit_kind Kind() const;
|
||||
|
||||
private:
|
||||
DIETypeUnit* fUnitEntry;
|
||||
DebugInfoEntry* fTypeEntry;
|
||||
uint64 fSignature;
|
||||
off_t fTypeOffset;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user