Add a constraint field which allows one to specify a particular base type name.
This is necessary for looking up pointer and array types. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42373 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
063fa6fa1e
commit
e5519ef504
@ -51,6 +51,23 @@
|
||||
#include "Variable.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
// #pragma mark - HasTypePredicate
|
||||
|
||||
|
||||
template<typename EntryType>
|
||||
struct HasTypePredicate {
|
||||
inline bool operator()(EntryType* entry) const
|
||||
{
|
||||
return entry->GetType() != NULL;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BasicTargetInterface
|
||||
|
||||
|
||||
@ -414,10 +431,16 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache,
|
||||
if (typeEntry->IsDeclaration())
|
||||
continue;
|
||||
|
||||
if (constraints.HasTypeKind()
|
||||
&& dwarf_tag_to_type_kind(typeEntry->Tag())
|
||||
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())
|
||||
@ -1012,3 +1035,49 @@ DwarfImageDebugInfo::_CreateLocalVariables(CompilationUnit* unit,
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DwarfImageDebugInfo::_EvaluateBaseTypeConstraints(DIEType* type,
|
||||
const TypeLookupConstraints& constraints)
|
||||
{
|
||||
if (constraints.HasBaseTypeName()) {
|
||||
BString baseEntryName;
|
||||
DIEType* baseTypeOwnerEntry = NULL;
|
||||
|
||||
switch (constraints.TypeKind()) {
|
||||
case TYPE_ADDRESS:
|
||||
{
|
||||
DIEAddressingType* addressType =
|
||||
dynamic_cast<DIEAddressingType*>(type);
|
||||
if (addressType != NULL) {
|
||||
baseTypeOwnerEntry = DwarfUtils::GetDIEByPredicate(
|
||||
addressType, HasTypePredicate<DIEAddressingType>());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_ARRAY:
|
||||
{
|
||||
DIEArrayType* arrayType =
|
||||
dynamic_cast<DIEArrayType*>(type);
|
||||
if (arrayType != NULL) {
|
||||
baseTypeOwnerEntry = DwarfUtils::GetDIEByPredicate(
|
||||
arrayType, HasTypePredicate<DIEArrayType>());
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (baseTypeOwnerEntry != NULL) {
|
||||
DwarfUtils::GetFullyQualifiedDIEName(baseTypeOwnerEntry,
|
||||
baseEntryName);
|
||||
if (!baseEntryName.IsEmpty() && baseEntryName
|
||||
!= constraints.BaseTypeName())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
class Architecture;
|
||||
class CompilationUnit;
|
||||
class DIEType;
|
||||
class DwarfStackFrameDebugInfo;
|
||||
class DwarfFile;
|
||||
class ElfSegment;
|
||||
@ -99,6 +100,9 @@ private:
|
||||
const EntryListWrapper& variableEntries,
|
||||
const EntryListWrapper& blockEntries);
|
||||
|
||||
bool _EvaluateBaseTypeConstraints(DIEType* type,
|
||||
const TypeLookupConstraints& constraints);
|
||||
|
||||
private:
|
||||
BLocker fLock;
|
||||
ImageInfo fImageInfo;
|
||||
|
@ -30,7 +30,8 @@ TypeLookupConstraints::TypeLookupConstraints(type_kind typeKind,
|
||||
fTypeKind(typeKind),
|
||||
fSubtypeKind(subTypeKind),
|
||||
fTypeKindGiven(true),
|
||||
fSubtypeKindGiven(true)
|
||||
fSubtypeKindGiven(true),
|
||||
fBaseTypeName()
|
||||
{
|
||||
}
|
||||
|
||||
@ -49,6 +50,13 @@ TypeLookupConstraints::HasSubtypeKind() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TypeLookupConstraints::HasBaseTypeName() const
|
||||
{
|
||||
return fBaseTypeName.Length() > 0;
|
||||
}
|
||||
|
||||
|
||||
type_kind
|
||||
TypeLookupConstraints::TypeKind() const
|
||||
{
|
||||
@ -63,6 +71,13 @@ TypeLookupConstraints::SubtypeKind() const
|
||||
}
|
||||
|
||||
|
||||
const BString&
|
||||
TypeLookupConstraints::BaseTypeName() const
|
||||
{
|
||||
return fBaseTypeName;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TypeLookupConstraints::SetTypeKind(type_kind typeKind)
|
||||
{
|
||||
@ -77,3 +92,10 @@ TypeLookupConstraints::SetSubtypeKind(int32 subtypeKind)
|
||||
fSubtypeKind = subtypeKind;
|
||||
fSubtypeKindGiven = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TypeLookupConstraints::SetBaseTypeName(const BString& name)
|
||||
{
|
||||
fBaseTypeName = name;
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
#define TYPE_LOOKUP_CONSTRAINTS_H
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
|
||||
@ -20,17 +22,21 @@ public:
|
||||
|
||||
bool HasTypeKind() const;
|
||||
bool HasSubtypeKind() const;
|
||||
bool HasBaseTypeName() const;
|
||||
type_kind TypeKind() const;
|
||||
int32 SubtypeKind() const;
|
||||
const BString& BaseTypeName() const;
|
||||
|
||||
void SetTypeKind(type_kind typeKind);
|
||||
void SetSubtypeKind(int32 subtypeKind);
|
||||
void SetBaseTypeName(const BString& name);
|
||||
|
||||
private:
|
||||
type_kind fTypeKind;
|
||||
int32 fSubtypeKind;
|
||||
bool fTypeKindGiven;
|
||||
bool fSubtypeKindGiven;
|
||||
BString fBaseTypeName;
|
||||
};
|
||||
|
||||
#endif // TYPE_LOOKUP_CONSTRAINTS_H
|
||||
|
Loading…
Reference in New Issue
Block a user