From 677379191fa7c9d25965ecdea521c2b418b45e30 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Mon, 4 Jul 2011 13:20:00 +0000 Subject: [PATCH] Lookups against the type cache need to be checked against the constraints as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42371 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/debug_info/DwarfTypeFactory.cpp | 15 ++++++++------- src/apps/debugger/debug_info/GlobalTypeLookup.cpp | 9 ++++++++- src/apps/debugger/debug_info/GlobalTypeLookup.h | 4 +++- src/apps/debugger/debug_info/TeamDebugInfo.cpp | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/apps/debugger/debug_info/DwarfTypeFactory.cpp b/src/apps/debugger/debug_info/DwarfTypeFactory.cpp index 017a9aeb38..0da0c4f55f 100644 --- a/src/apps/debugger/debug_info/DwarfTypeFactory.cpp +++ b/src/apps/debugger/debug_info/DwarfTypeFactory.cpp @@ -292,9 +292,15 @@ DwarfTypeFactory::CreateType(DIEType* typeEntry, DwarfType*& _type) 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 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 @@ DwarfTypeFactory::CreateType(DIEType* typeEntry, DwarfType*& _type) // 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 @@ DwarfTypeFactory::CreateType(DIEType* typeEntry, DwarfType*& _type) // 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) diff --git a/src/apps/debugger/debug_info/GlobalTypeLookup.cpp b/src/apps/debugger/debug_info/GlobalTypeLookup.cpp index 84f500c9f1..5f2b2aaeb0 100644 --- a/src/apps/debugger/debug_info/GlobalTypeLookup.cpp +++ b/src/apps/debugger/debug_info/GlobalTypeLookup.cpp @@ -14,6 +14,7 @@ #include "StringUtils.h" #include "Type.h" +#include "TypeLookupConstraints.h" struct GlobalTypeCache::TypeEntry { @@ -147,9 +148,15 @@ GlobalTypeCache::Init() 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; } diff --git a/src/apps/debugger/debug_info/GlobalTypeLookup.h b/src/apps/debugger/debug_info/GlobalTypeLookup.h index c045d3789c..6a28117749 100644 --- a/src/apps/debugger/debug_info/GlobalTypeLookup.h +++ b/src/apps/debugger/debug_info/GlobalTypeLookup.h @@ -35,7 +35,9 @@ public: 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); diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.cpp b/src/apps/debugger/debug_info/TeamDebugInfo.cpp index 6e1d40727e..b3817fe898 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.cpp +++ b/src/apps/debugger/debug_info/TeamDebugInfo.cpp @@ -377,7 +377,7 @@ TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, { // maybe the type is already cached AutoLocker cacheLocker(cache); - Type* type = cache->GetType(name); + Type* type = cache->GetType(name, constraints); if (type != NULL) { type->AcquireReference(); _type = type;