diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index 3a40299cd8..45d13884be 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -51,6 +51,23 @@ #include "Variable.h" +namespace { + + +// #pragma mark - HasTypePredicate + + +template +struct HasTypePredicate { + inline bool operator()(EntryType* entry) const + { + return entry->GetType() != NULL; + } +}; + +} + + // #pragma mark - BasicTargetInterface @@ -414,10 +431,16 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache, if (typeEntry->IsDeclaration()) continue; - if (constraints.HasTypeKind() - && dwarf_tag_to_type_kind(typeEntry->Tag()) + if (constraints.HasTypeKind()) { + if (dwarf_tag_to_type_kind(typeEntry->Tag()) != constraints.TypeKind()) continue; + + if (!_EvaluateBaseTypeConstraints(typeEntry, + constraints)) + continue; + } + if (constraints.HasSubtypeKind() && dwarf_tag_to_subtype_kind(typeEntry->Tag()) != constraints.SubtypeKind()) @@ -1012,3 +1035,49 @@ DwarfImageDebugInfo::_CreateLocalVariables(CompilationUnit* unit, return B_OK; } + + +bool +DwarfImageDebugInfo::_EvaluateBaseTypeConstraints(DIEType* type, + const TypeLookupConstraints& constraints) +{ + if (constraints.HasBaseTypeName()) { + BString baseEntryName; + DIEType* baseTypeOwnerEntry = NULL; + + switch (constraints.TypeKind()) { + case TYPE_ADDRESS: + { + DIEAddressingType* addressType = + dynamic_cast(type); + if (addressType != NULL) { + baseTypeOwnerEntry = DwarfUtils::GetDIEByPredicate( + addressType, HasTypePredicate()); + } + break; + } + case TYPE_ARRAY: + { + DIEArrayType* arrayType = + dynamic_cast(type); + if (arrayType != NULL) { + baseTypeOwnerEntry = DwarfUtils::GetDIEByPredicate( + arrayType, HasTypePredicate()); + } + break; + } + default: + break; + } + + if (baseTypeOwnerEntry != NULL) { + DwarfUtils::GetFullyQualifiedDIEName(baseTypeOwnerEntry, + baseEntryName); + if (!baseEntryName.IsEmpty() && baseEntryName + != constraints.BaseTypeName()) + return false; + } + } + + return true; +} diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h index 9c179b8b6b..e0ea796fc4 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h @@ -19,6 +19,7 @@ class Architecture; class CompilationUnit; +class DIEType; class DwarfStackFrameDebugInfo; class DwarfFile; class ElfSegment; @@ -99,6 +100,9 @@ private: const EntryListWrapper& variableEntries, const EntryListWrapper& blockEntries); + bool _EvaluateBaseTypeConstraints(DIEType* type, + const TypeLookupConstraints& constraints); + private: BLocker fLock; ImageInfo fImageInfo; diff --git a/src/apps/debugger/model/TypeLookupConstraints.cpp b/src/apps/debugger/model/TypeLookupConstraints.cpp index 1e3a0db3bf..787ee3486b 100644 --- a/src/apps/debugger/model/TypeLookupConstraints.cpp +++ b/src/apps/debugger/model/TypeLookupConstraints.cpp @@ -30,7 +30,8 @@ TypeLookupConstraints::TypeLookupConstraints(type_kind typeKind, fTypeKind(typeKind), fSubtypeKind(subTypeKind), fTypeKindGiven(true), - fSubtypeKindGiven(true) + fSubtypeKindGiven(true), + fBaseTypeName() { } @@ -49,6 +50,13 @@ TypeLookupConstraints::HasSubtypeKind() const } +bool +TypeLookupConstraints::HasBaseTypeName() const +{ + return fBaseTypeName.Length() > 0; +} + + type_kind TypeLookupConstraints::TypeKind() const { @@ -63,6 +71,13 @@ TypeLookupConstraints::SubtypeKind() const } +const BString& +TypeLookupConstraints::BaseTypeName() const +{ + return fBaseTypeName; +} + + void TypeLookupConstraints::SetTypeKind(type_kind typeKind) { @@ -77,3 +92,10 @@ TypeLookupConstraints::SetSubtypeKind(int32 subtypeKind) fSubtypeKind = subtypeKind; fSubtypeKindGiven = true; } + + +void +TypeLookupConstraints::SetBaseTypeName(const BString& name) +{ + fBaseTypeName = name; +} diff --git a/src/apps/debugger/model/TypeLookupConstraints.h b/src/apps/debugger/model/TypeLookupConstraints.h index 637df3f506..44c992574d 100644 --- a/src/apps/debugger/model/TypeLookupConstraints.h +++ b/src/apps/debugger/model/TypeLookupConstraints.h @@ -6,6 +6,8 @@ #define TYPE_LOOKUP_CONSTRAINTS_H +#include + #include "Type.h" @@ -20,17 +22,21 @@ public: bool HasTypeKind() const; bool HasSubtypeKind() const; + bool HasBaseTypeName() const; type_kind TypeKind() const; int32 SubtypeKind() const; + const BString& BaseTypeName() const; void SetTypeKind(type_kind typeKind); void SetSubtypeKind(int32 subtypeKind); + void SetBaseTypeName(const BString& name); private: type_kind fTypeKind; int32 fSubtypeKind; bool fTypeKindGiven; bool fSubtypeKindGiven; + BString fBaseTypeName; }; #endif // TYPE_LOOKUP_CONSTRAINTS_H