Debugger: Extend TeamTypeInformation interface.

TeamTypeInformation:
- Add interface function to allow simply querying for whether a
  type is known to exist by a name + constraints, without actually
  requesting that it be instantiated, and implement in TeamDebugInfo.

GlobalTypeLookup:
- Add analogous type lookup function to the above, and implement in
  TeamDebugInfo.

{Specific,Debugger,Dwarf}ImageDebugInfo:
- Add function for type existence query, and implement in subclasses.
This commit is contained in:
Rene Gollent 2015-01-01 17:33:32 -05:00
parent 492a649b19
commit d21bcbb0ac
11 changed files with 141 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com. * Copyright 2013-2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -60,6 +60,14 @@ DebuggerImageDebugInfo::GetType(GlobalTypeCache* cache,
} }
bool
DebuggerImageDebugInfo::HasType(const BString& name,
const TypeLookupConstraints& constraints) const
{
return false;
}
AddressSectionType AddressSectionType
DebuggerImageDebugInfo::GetAddressSectionType(target_addr_t address) DebuggerImageDebugInfo::GetAddressSectionType(target_addr_t address)
{ {

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com. * Copyright 2013-2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef DEBUGGER_IMAGE_DEBUG_INFO_H #ifndef DEBUGGER_IMAGE_DEBUG_INFO_H
@ -33,6 +33,10 @@ public:
const BString& name, const BString& name,
const TypeLookupConstraints& constraints, const TypeLookupConstraints& constraints,
Type*& _type); Type*& _type);
virtual bool HasType(const BString& name,
const TypeLookupConstraints& constraints)
const;
virtual AddressSectionType GetAddressSectionType(target_addr_t address); virtual AddressSectionType GetAddressSectionType(target_addr_t address);
virtual status_t CreateFrame(Image* image, virtual status_t CreateFrame(Image* image,
FunctionInstance* functionInstance, FunctionInstance* functionInstance,

View File

@ -567,6 +567,39 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache, const BString& name,
} }
bool
DwarfImageDebugInfo::HasType(const BString& name,
const TypeLookupConstraints& constraints) const
{
TypeNameEntry* entry = fTypeNameTable->Lookup(name);
if (entry == NULL)
return false;
for (int32 i = 0; TypeEntryInfo* info = entry->types.ItemAt(i); i++) {
DIEType* typeEntry = info->type;
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()) {
continue;
}
return true;
}
return false;
}
AddressSectionType AddressSectionType
DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address) DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address)
{ {

View File

@ -58,6 +58,9 @@ public:
const BString& name, const BString& name,
const TypeLookupConstraints& constraints, const TypeLookupConstraints& constraints,
Type*& _type); Type*& _type);
virtual bool HasType(const BString& name,
const TypeLookupConstraints& constraints)
const;
virtual AddressSectionType GetAddressSectionType(target_addr_t address); virtual AddressSectionType GetAddressSectionType(target_addr_t address);

View File

@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef GLOBAL_TYPE_LOOKUP_H #ifndef GLOBAL_TYPE_LOOKUP_H
@ -69,6 +70,11 @@ public:
const TypeLookupConstraints& constraints, const TypeLookupConstraints& constraints,
Type*& _type) = 0; Type*& _type) = 0;
// returns a reference // returns a reference
virtual bool HasType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints)
= 0;
}; };

View File

@ -105,6 +105,20 @@ ImageDebugInfo::GetType(GlobalTypeCache* cache, const BString& name,
} }
bool
ImageDebugInfo::HasType(const BString& name,
const TypeLookupConstraints& constraints) const
{
for (int32 i = 0; SpecificImageDebugInfo* specificInfo
= fSpecificInfos.ItemAt(i); i++) {
if (specificInfo->HasType(name, constraints))
return true;
}
return false;
}
AddressSectionType AddressSectionType
ImageDebugInfo::GetAddressSectionType(target_addr_t address) const ImageDebugInfo::GetAddressSectionType(target_addr_t address) const
{ {

View File

@ -45,6 +45,11 @@ public:
const TypeLookupConstraints& constraints, const TypeLookupConstraints& constraints,
Type*& _type); Type*& _type);
// returns a reference // returns a reference
bool HasType(const BString& name,
const TypeLookupConstraints& constraints)
const;
AddressSectionType GetAddressSectionType(target_addr_t address) AddressSectionType GetAddressSectionType(target_addr_t address)
const; const;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com. * Copyright 2013-2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef SPECIFIC_IMAGE_DEBUG_INFO_H #ifndef SPECIFIC_IMAGE_DEBUG_INFO_H
@ -52,6 +52,10 @@ public:
const TypeLookupConstraints& constraints, const TypeLookupConstraints& constraints,
Type*& _type) = 0; Type*& _type) = 0;
// returns a reference // returns a reference
virtual bool HasType(const BString& name,
const TypeLookupConstraints& constraints)
const = 0;
virtual AddressSectionType GetAddressSectionType(target_addr_t address) virtual AddressSectionType GetAddressSectionType(target_addr_t address)
= 0; = 0;

View File

@ -380,12 +380,22 @@ TeamDebugInfo::LookupTypeByName(const BString& name,
return GetType(fTypeCache, name, constraints, _type); return GetType(fTypeCache, name, constraints, _type);
} }
bool
TeamDebugInfo::TypeExistsByName(const BString& name,
const TypeLookupConstraints& constraints)
{
return HasType(fTypeCache, name, constraints);
}
status_t status_t
TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name,
const TypeLookupConstraints& constraints, Type*& _type) const TypeLookupConstraints& constraints, Type*& _type)
{ {
// 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, constraints); Type* type = cache->GetType(name, constraints);
if (type != NULL) { if (type != NULL) {
type->AcquireReference(); type->AcquireReference();
@ -425,6 +435,47 @@ TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name,
} }
bool
TeamDebugInfo::HasType(GlobalTypeCache* cache, const BString& name,
const TypeLookupConstraints& constraints)
{
// maybe the type is already cached
AutoLocker<GlobalTypeCache> cacheLocker(cache);
Type* type = cache->GetType(name, constraints);
if (type != NULL)
return true;
cacheLocker.Unlock();
// Clone the image list and get references to the images, so we can iterate
// through them without locking.
AutoLocker<BLocker> locker(fLock);
ImageList images;
for (int32 i = 0; ImageDebugInfo* imageDebugInfo = fImages.ItemAt(i); i++) {
if (images.AddItem(imageDebugInfo))
imageDebugInfo->AcquireReference();
}
locker.Unlock();
bool found = false;
for (int32 i = 0; ImageDebugInfo* imageDebugInfo = images.ItemAt(i); i++) {
if (imageDebugInfo->HasType(name, constraints)) {
found = true;
break;
}
}
// release the references
for (int32 i = 0; ImageDebugInfo* imageDebugInfo = images.ItemAt(i); i++)
imageDebugInfo->ReleaseReference();
return found;
}
status_t status_t
TeamDebugInfo::LoadImageDebugInfo(const ImageInfo& imageInfo, TeamDebugInfo::LoadImageDebugInfo(const ImageInfo& imageInfo,
LocatableFile* imageFile, ImageDebugInfoLoadingState& _state, LocatableFile* imageFile, ImageDebugInfoLoadingState& _state,

View File

@ -49,10 +49,15 @@ public:
const BString& name, const BString& name,
const TypeLookupConstraints& constraints, const TypeLookupConstraints& constraints,
Type*& _type); Type*& _type);
virtual bool HasType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints);
virtual status_t LookupTypeByName(const BString& name, virtual status_t LookupTypeByName(const BString& name,
const TypeLookupConstraints& constraints, const TypeLookupConstraints& constraints,
Type*& _type); Type*& _type);
virtual bool TypeExistsByName(const BString& name,
const TypeLookupConstraints& constraints);
status_t LoadImageDebugInfo(const ImageInfo& imageInfo, status_t LoadImageDebugInfo(const ImageInfo& imageInfo,
LocatableFile* imageFile, LocatableFile* imageFile,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2011, Rene Gollent, rene@gollent.com. * Copyright 2011-2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef TEAM_TYPE_INFORMATION_H #ifndef TEAM_TYPE_INFORMATION_H
@ -24,6 +24,10 @@ public:
const TypeLookupConstraints& constraints, const TypeLookupConstraints& constraints,
Type*& _type) = 0; Type*& _type) = 0;
// returns reference // returns reference
virtual bool TypeExistsByName(const BString& name,
const TypeLookupConstraints& constraints)
= 0;
}; };