Commit 3dce4c04 authored by ussrhero's avatar ussrhero

added pdb type enumerator

parent ce122a05
......@@ -173,6 +173,7 @@ public:
virtual unsigned long getBaseType() = 0;
virtual BITOFFSET getBitPosition() = 0;
virtual SymbolPtr getChildByIndex(unsigned long index ) = 0;
virtual SymbolPtr getChildByIndex(unsigned long symTag, unsigned long index ) = 0;
virtual SymbolPtr getChildByName(const std::wstring &name ) = 0;
virtual size_t getChildCount() = 0;
virtual size_t getChildCount(unsigned long symTag ) = 0;
......
......@@ -306,7 +306,7 @@ protected:
class TypeInfoProviderClangEnum : public TypeInfoEnumerator{
class TypeInfoProviderClangEnum : public TypeInfoEnumerator {
public:
......
......@@ -322,7 +322,12 @@ public:
NOT_IMPLEMENTED();
}
virtual SymbolPtr getChildByIndex(ULONG _index)
virtual SymbolPtr getChildByIndex(ULONG index)
{
return getChildByIndex(SymTagNull, index);
}
virtual SymbolPtr getChildByIndex(unsigned long symTag, unsigned long index )
{
throw SymbolException(L"symbol not found");
}
......
......@@ -88,6 +88,11 @@ class ExportSymbolBase : public Symbol
NOT_IMPLEMENTED();
}
virtual SymbolPtr getChildByIndex(unsigned long symTag, unsigned long index )
{
NOT_IMPLEMENTED();
}
virtual SymbolPtr getChildByName(const std::wstring &_name )
{
NOT_IMPLEMENTED();
......
......@@ -14,6 +14,7 @@
#include "typeinfoimp.h"
#include "typedvarimp.h"
#include "processmon.h"
#include "fnmatch.h"
namespace {
......@@ -1841,4 +1842,58 @@ TypeInfoPtr TypeInfoSymbolProvider::getTypeByName(const std::wstring& name)
///////////////////////////////////////////////////////////////////////////////
TypeInfoEnumeratorPtr TypeInfoSymbolProvider::getTypeEnumerator(const std::wstring& mask)
{
return TypeInfoEnumeratorPtr( new TypeInfoSymbolEnum(m_symbolSession, mask) );
}
///////////////////////////////////////////////////////////////////////////////
inline
bool isTypeTag(SymTags tag)
{
switch(tag)
{
case SymTagUDT:
case SymTagEnum:
case SymTagTypedef:
return true;
}
return false;
}
TypeInfoSymbolEnum::TypeInfoSymbolEnum(SymbolSessionPtr& symSession, const std::wstring& mask)
{
m_index = 0;
SymbolPtr symScope = symSession->getSymbolScope();
size_t symCount = symScope->getChildCount();
for ( size_t index = 0; index < symCount; index++)
{
SymbolPtr sym = symScope->getChildByIndex(index);
if (!isTypeTag(sym->getSymTag()) )
continue;
std::wstring symName = sym->getName();
if ( mask.empty() || fnmatch(mask, symName ) )
{
m_typeList.push_back( loadType(sym) );
}
}
}
///////////////////////////////////////////////////////////////////////////////
TypeInfoPtr TypeInfoSymbolEnum::Next()
{
if ( m_index < m_typeList.size() )
return m_typeList[m_index++];
return TypeInfoPtr();
}
///////////////////////////////////////////////////////////////////////////////
} // kdlib namespace end
......@@ -1004,6 +1004,22 @@ protected:
///////////////////////////////////////////////////////////////////////////////
class TypeInfoSymbolEnum : public TypeInfoEnumerator {
public:
TypeInfoSymbolEnum(SymbolSessionPtr& symSession, const std::wstring& mask);
virtual TypeInfoPtr Next();
private:
std::vector<TypeInfoPtr> m_typeList;
size_t m_index;
};
///////////////////////////////////////////////////////////////////////////////
class TypeInfoSymbolProvider : public TypeInfoProvider
{
public:
......@@ -1014,9 +1030,7 @@ private:
virtual TypeInfoPtr getTypeByName(const std::wstring& name);
virtual TypeInfoEnumeratorPtr getTypeEnumerator(const std::wstring& mask = L"") {
NOT_IMPLEMENTED();
}
virtual TypeInfoEnumeratorPtr getTypeEnumerator(const std::wstring& mask = L"");
private:
......
......@@ -592,3 +592,22 @@ TEST_F(TypeInfoTest, GetScopeName)
}
TEST_F(TypeInfoTest, PdbProviderEnum)
{
TypeInfoProviderPtr typeProvider;
ASSERT_NO_THROW( typeProvider = getTypeInfoProviderFromPdb( m_targetModule->getSymFile() ) );
TypeInfoEnumeratorPtr typeEnum;
size_t count;
ASSERT_NO_THROW( typeEnum = typeProvider->getTypeEnumerator() );
for ( count = 0; 0 != typeEnum->Next(); ++count);
EXPECT_LT(1000, count);
ASSERT_NO_THROW( typeEnum = typeProvider->getTypeEnumerator(L"struct*") );
for ( count = 0; 0 != typeEnum->Next(); ++count);
EXPECT_EQ(12, count);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment