Author: anevilyak Date: 2011-07-04 15:20:00 +0200 (Mon, 04 Jul 2011) New Revision: 42371 Changeset: https://dev.haiku-os.org/changeset/42371 Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfTypeFactory.cpp haiku/trunk/src/apps/debugger/debug_info/GlobalTypeLookup.cpp haiku/trunk/src/apps/debugger/debug_info/GlobalTypeLookup.h haiku/trunk/src/apps/debugger/debug_info/TeamDebugInfo.cpp Log: Lookups against the type cache need to be checked against the constraints as well. Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfTypeFactory.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DwarfTypeFactory.cpp 2011-07-04 12:44:29 UTC (rev 42370) +++ haiku/trunk/src/apps/debugger/debug_info/DwarfTypeFactory.cpp 2011-07-04 13:20:00 UTC (rev 42371) @@ -292,9 +292,15 @@ DwarfUtils::GetFullyQualifiedDIEName(typeEntry, name); // TODO: The DIE may not have a name (e.g. pointer and reference types don't). + TypeLookupConstraints constraints( + dwarf_tag_to_type_kind(typeEntry->Tag())); + int32 subtypeKind = dwarf_tag_to_subtype_kind(typeEntry->Tag()); + if (subtypeKind >= 0) + constraints.SetSubtypeKind(subtypeKind); + AutoLocker<GlobalTypeCache> cacheLocker(fTypeCache); Type* globalType = name.Length() > 0 - ? fTypeCache->GetType(name) : NULL; + ? fTypeCache->GetType(name, constraints) : NULL; if (globalType == NULL) { // lookup by name failed -- try lookup by ID BString id; @@ -315,11 +321,6 @@ // If the type entry indicates a declaration only, we try to look the // type up globally first. - TypeLookupConstraints constraints( - dwarf_tag_to_type_kind(typeEntry->Tag())); - int32 subtypeKind = dwarf_tag_to_subtype_kind(typeEntry->Tag()); - if (subtypeKind >= 0) - constraints.SetSubtypeKind(subtypeKind); if (typeEntry->IsDeclaration() && name.Length() > 0 && fTypeLookup->GetType(fTypeCache, name, constraints, globalType) @@ -345,7 +346,7 @@ // have been inserted (e.g. in the compound type case). cacheLocker.Lock(); if (name.Length() > 0 - ? fTypeCache->GetType(name) == NULL + ? fTypeCache->GetType(name, constraints) == NULL : fTypeCache->GetTypeByID(type->ID()) == NULL) { error = fTypeCache->AddType(type); if (error != B_OK) Modified: haiku/trunk/src/apps/debugger/debug_info/GlobalTypeLookup.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/GlobalTypeLookup.cpp 2011-07-04 12:44:29 UTC (rev 42370) +++ haiku/trunk/src/apps/debugger/debug_info/GlobalTypeLookup.cpp 2011-07-04 13:20:00 UTC (rev 42371) @@ -14,6 +14,7 @@ #include "StringUtils.h" #include "Type.h" +#include "TypeLookupConstraints.h" struct GlobalTypeCache::TypeEntry { @@ -147,9 +148,15 @@ Type* -GlobalTypeCache::GetType(const BString& name) const +GlobalTypeCache::GetType(const BString& name, + const TypeLookupConstraints &constraints) const { TypeEntry* typeEntry = fTypesByName->Lookup(name); + if (typeEntry != NULL) { + if (constraints.HasTypeKind() + && typeEntry->type->Kind() != constraints.TypeKind()) + typeEntry = NULL; + } return typeEntry != NULL ? typeEntry->type : NULL; } Modified: haiku/trunk/src/apps/debugger/debug_info/GlobalTypeLookup.h =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/GlobalTypeLookup.h 2011-07-04 12:44:29 UTC (rev 42370) +++ haiku/trunk/src/apps/debugger/debug_info/GlobalTypeLookup.h 2011-07-04 13:20:00 UTC (rev 42371) @@ -35,7 +35,9 @@ inline void Unlock(); // cache must be locked - Type* GetType(const BString& name) const; + Type* GetType(const BString& name, + const TypeLookupConstraints &constraints + ) const; Type* GetTypeByID(const BString& id) const; status_t AddType(Type* type); void RemoveType(Type* type); Modified: haiku/trunk/src/apps/debugger/debug_info/TeamDebugInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/TeamDebugInfo.cpp 2011-07-04 12:44:29 UTC (rev 42370) +++ haiku/trunk/src/apps/debugger/debug_info/TeamDebugInfo.cpp 2011-07-04 13:20:00 UTC (rev 42371) @@ -377,7 +377,7 @@ { // maybe the type is already cached AutoLocker<GlobalTypeCache> cacheLocker(cache); - Type* type = cache->GetType(name); + Type* type = cache->GetType(name, constraints); if (type != NULL) { type->AcquireReference(); _type = type;