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
This commit is contained in:
@@ -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<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 @@ 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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -377,7 +377,7 @@ TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name,
|
||||
{
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user