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);
|
DwarfUtils::GetFullyQualifiedDIEName(typeEntry, name);
|
||||||
// TODO: The DIE may not have a name (e.g. pointer and reference types don't).
|
// 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);
|
AutoLocker<GlobalTypeCache> cacheLocker(fTypeCache);
|
||||||
Type* globalType = name.Length() > 0
|
Type* globalType = name.Length() > 0
|
||||||
? fTypeCache->GetType(name) : NULL;
|
? fTypeCache->GetType(name, constraints) : NULL;
|
||||||
if (globalType == NULL) {
|
if (globalType == NULL) {
|
||||||
// lookup by name failed -- try lookup by ID
|
// lookup by name failed -- try lookup by ID
|
||||||
BString 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
|
// If the type entry indicates a declaration only, we try to look the
|
||||||
// type up globally first.
|
// 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
|
if (typeEntry->IsDeclaration() && name.Length() > 0
|
||||||
&& fTypeLookup->GetType(fTypeCache, name,
|
&& fTypeLookup->GetType(fTypeCache, name,
|
||||||
constraints, globalType)
|
constraints, globalType)
|
||||||
@@ -345,7 +346,7 @@ DwarfTypeFactory::CreateType(DIEType* typeEntry, DwarfType*& _type)
|
|||||||
// have been inserted (e.g. in the compound type case).
|
// have been inserted (e.g. in the compound type case).
|
||||||
cacheLocker.Lock();
|
cacheLocker.Lock();
|
||||||
if (name.Length() > 0
|
if (name.Length() > 0
|
||||||
? fTypeCache->GetType(name) == NULL
|
? fTypeCache->GetType(name, constraints) == NULL
|
||||||
: fTypeCache->GetTypeByID(type->ID()) == NULL) {
|
: fTypeCache->GetTypeByID(type->ID()) == NULL) {
|
||||||
error = fTypeCache->AddType(type);
|
error = fTypeCache->AddType(type);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
#include "Type.h"
|
#include "Type.h"
|
||||||
|
#include "TypeLookupConstraints.h"
|
||||||
|
|
||||||
|
|
||||||
struct GlobalTypeCache::TypeEntry {
|
struct GlobalTypeCache::TypeEntry {
|
||||||
@@ -147,9 +148,15 @@ GlobalTypeCache::Init()
|
|||||||
|
|
||||||
|
|
||||||
Type*
|
Type*
|
||||||
GlobalTypeCache::GetType(const BString& name) const
|
GlobalTypeCache::GetType(const BString& name,
|
||||||
|
const TypeLookupConstraints &constraints) const
|
||||||
{
|
{
|
||||||
TypeEntry* typeEntry = fTypesByName->Lookup(name);
|
TypeEntry* typeEntry = fTypesByName->Lookup(name);
|
||||||
|
if (typeEntry != NULL) {
|
||||||
|
if (constraints.HasTypeKind()
|
||||||
|
&& typeEntry->type->Kind() != constraints.TypeKind())
|
||||||
|
typeEntry = NULL;
|
||||||
|
}
|
||||||
return typeEntry != NULL ? typeEntry->type : NULL;
|
return typeEntry != NULL ? typeEntry->type : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ public:
|
|||||||
inline void Unlock();
|
inline void Unlock();
|
||||||
|
|
||||||
// cache must be locked
|
// 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;
|
Type* GetTypeByID(const BString& id) const;
|
||||||
status_t AddType(Type* type);
|
status_t AddType(Type* type);
|
||||||
void RemoveType(Type* type);
|
void RemoveType(Type* type);
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name,
|
|||||||
{
|
{
|
||||||
// maybe the type is already cached
|
// maybe the type is already cached
|
||||||
AutoLocker<GlobalTypeCache> cacheLocker(cache);
|
AutoLocker<GlobalTypeCache> cacheLocker(cache);
|
||||||
Type* type = cache->GetType(name);
|
Type* type = cache->GetType(name, constraints);
|
||||||
if (type != NULL) {
|
if (type != NULL) {
|
||||||
type->AcquireReference();
|
type->AcquireReference();
|
||||||
_type = type;
|
_type = type;
|
||||||
|
|||||||
Reference in New Issue
Block a user