mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] refactored : module class
git-svn-id: https://pykd.svn.codeplex.com/svn@78609 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
91e158ea6a
commit
8c7ef0441d
@ -33,7 +33,7 @@ BaseTypeVariant getRegVariantValue( ULONG index );
|
|||||||
ULONG64 getRegInstructionPointer();
|
ULONG64 getRegInstructionPointer();
|
||||||
|
|
||||||
// это нужно сделать по-другому!
|
// это нужно сделать по-другому!
|
||||||
std::string getSymbolByOffset( ULONG64 offset );
|
//std::string getSymbolByOffset( ULONG64 offset );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ std::string DiaException::makeFullDesc(const std::string &desc, HRESULT hres)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SymbolPtr loadSymbolFile(const std::string &filePath, ULONGLONG loadBase )
|
SymbolSessionPtr loadSymbolFile(const std::string &filePath, ULONGLONG loadBase )
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
DiaDataSourcePtr dataSource;
|
DiaDataSourcePtr dataSource;
|
||||||
@ -73,7 +73,7 @@ SymbolPtr loadSymbolFile(const std::string &filePath, ULONGLONG loadBase )
|
|||||||
if ( S_OK != hres )
|
if ( S_OK != hres )
|
||||||
throw DiaException("Call IDiaSymbol::get_globalScope", hres);
|
throw DiaException("Call IDiaSymbol::get_globalScope", hres);
|
||||||
|
|
||||||
return SymbolPtr( new DiaSymbol( _globalScope ) );
|
return SymbolSessionPtr( new DiaSession( _session, _globalScope ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -422,11 +422,29 @@ bool DiaSymbol::isVirtualBaseClass()
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//bool DiaSymbol::isIndirectVirtualBaseClass()
|
SymbolPtr DiaSession::findByRva( ULONG rva, ULONG symTag, LONG* pdisplacement )
|
||||||
//{
|
{
|
||||||
// return !!callSymbol(get_indirectVirtualBaseClass);
|
DiaSymbolPtr child;
|
||||||
//}
|
LONG displacement;
|
||||||
|
|
||||||
|
HRESULT hres =
|
||||||
|
m_session->findSymbolByRVAEx(
|
||||||
|
rva,
|
||||||
|
static_cast<enum ::SymTagEnum>(symTag),
|
||||||
|
&child,
|
||||||
|
&displacement);
|
||||||
|
|
||||||
|
if (S_OK != hres)
|
||||||
|
throw DiaException("Call IDiaSession::findSymbolByRVAEx", hres);
|
||||||
|
if (!child)
|
||||||
|
throw DiaException("Call IDiaSession::findSymbolByRVAEx", E_UNEXPECTED);
|
||||||
|
if ( pdisplacement == NULL && displacement != 0 )
|
||||||
|
throw DiaException("Call IDiaSession::findSymbolByRVAEx failed to find suymbol" );
|
||||||
|
|
||||||
|
return SymbolPtr( new DiaSymbol(child) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}; // pykd nemaspace end
|
}; // pykd nemaspace end
|
||||||
|
|
||||||
|
@ -232,6 +232,30 @@ protected:
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class DiaSession : public SymbolSession
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
DiaSession( IDiaSession* session, IDiaSymbol *globalScope ) :
|
||||||
|
m_globalScope( new DiaSymbol( globalScope ) ),
|
||||||
|
m_session( session )
|
||||||
|
{}
|
||||||
|
|
||||||
|
SymbolPtr& getSymbolScope() {
|
||||||
|
return m_globalScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
SymbolPtr findByRva( ULONG rva, ULONG symTag = SymTagData, LONG* displacement = NULL );
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
SymbolPtr m_globalScope;
|
||||||
|
DiaSessionPtr m_session;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} // end pykd namespace
|
} // end pykd namespace
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,24 +42,31 @@ Module::Module(ULONG64 offset )
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SymbolPtr& Module::getSymScope()
|
SymbolSessionPtr& Module::getSymSession()
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if ( m_symScope )
|
if ( m_symSession )
|
||||||
break;
|
return m_symSession;
|
||||||
|
|
||||||
if ( m_symfile.empty() )
|
if ( m_symfile.empty() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
m_symScope = loadSymbolFile( m_symfile, m_base );
|
m_symSession = loadSymbolFile( m_symfile, m_base );
|
||||||
|
|
||||||
} while( false );
|
} while( false );
|
||||||
|
|
||||||
if ( !m_symScope )
|
if ( !m_symSession )
|
||||||
throw SymbolException( "failed to find symbol file" );
|
throw SymbolException( "failed to find symbol file" );
|
||||||
|
|
||||||
return m_symScope;
|
return m_symSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SymbolPtr& Module::getSymScope()
|
||||||
|
{
|
||||||
|
return getSymSession()->getSymbolScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -67,7 +74,7 @@ SymbolPtr& Module::getSymScope()
|
|||||||
void Module::reloadSymbols()
|
void Module::reloadSymbols()
|
||||||
{
|
{
|
||||||
m_symfile = getModuleSymbolFileName( m_base );
|
m_symfile = getModuleSymbolFileName( m_base );
|
||||||
m_symScope.reset();
|
m_symSession.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -126,9 +133,11 @@ Module::getTypedVarByAddr( ULONG64 offset )
|
|||||||
if ( offset < m_base || offset > getEnd() )
|
if ( offset < m_base || offset > getEnd() )
|
||||||
throw DbgException( "address is out of the module space" );
|
throw DbgException( "address is out of the module space" );
|
||||||
|
|
||||||
std::string symName = getSymbolByOffset( offset );
|
SymbolPtr symVar = getSymSession()->findByRva( (ULONG)(offset - m_base ) );
|
||||||
|
|
||||||
return getTypedVarByName( symName );
|
TypeInfoPtr typeInfo = TypeInfo::getTypeInfo( symVar->getType() );
|
||||||
|
|
||||||
|
return TypedVar::getTypedVar(typeInfo, VarDataMemory::factory(offset) );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -147,32 +156,6 @@ Module::getTypedVarByName( const std::string &symName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TypedVar::getTypedVar( typeInfo, VarDataConst::factory(symVar) );
|
return TypedVar::getTypedVar( typeInfo, VarDataConst::factory(symVar) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//HRESULT hres;
|
|
||||||
|
|
||||||
//pyDia::SymbolPtr symVar = getSymScope()->getChildByName( symName );
|
|
||||||
|
|
||||||
//std::string fullName = m_name;
|
|
||||||
//fullName += '!';
|
|
||||||
//fullName += symName;
|
|
||||||
|
|
||||||
//ULONG64 offset;
|
|
||||||
|
|
||||||
//hres = m_symbols->GetOffsetByName( fullName.c_str(), &offset );
|
|
||||||
|
|
||||||
//TypeInfoPtr typeInfo = TypeInfo::getTypeInfo( symVar->getType() );
|
|
||||||
|
|
||||||
//if ( FAILED( hres ) )
|
|
||||||
//{
|
|
||||||
// if ( LocIsConstant == symVar->getLocType() )
|
|
||||||
// return TypedVar::getTypedVar( m_client, typeInfo, VarDataConst::factory(m_control, symVar) );
|
|
||||||
// throw DbgException("IDebugSymbols::GetOffsetByName failed" );
|
|
||||||
//}
|
|
||||||
|
|
||||||
//return TypedVar::getTypedVar( m_client, typeInfo, VarDataMemory::factory(m_dataSpaces, offset) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -211,5 +194,3 @@ python::list Module::getTypedVarListByTypeName( ULONG64 listHeadAddress, const s
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}; // end of namespace pykd
|
}; // end of namespace pykd
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,6 +99,8 @@ private:
|
|||||||
|
|
||||||
SymbolPtr& getSymScope();
|
SymbolPtr& getSymScope();
|
||||||
|
|
||||||
|
SymbolSessionPtr& getSymSession();
|
||||||
|
|
||||||
BaseTypeVariant getValue() {
|
BaseTypeVariant getValue() {
|
||||||
return BaseTypeVariant(m_base);
|
return BaseTypeVariant(m_base);
|
||||||
}
|
}
|
||||||
@ -113,7 +115,7 @@ private:
|
|||||||
ULONG m_timeDataStamp;
|
ULONG m_timeDataStamp;
|
||||||
ULONG m_checkSum;
|
ULONG m_checkSum;
|
||||||
|
|
||||||
SymbolPtr m_symScope;
|
SymbolSessionPtr m_symSession;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -10,6 +10,9 @@ class Symbol;
|
|||||||
typedef boost::shared_ptr< Symbol > SymbolPtr;
|
typedef boost::shared_ptr< Symbol > SymbolPtr;
|
||||||
typedef std::list< SymbolPtr > SymbolPtrList;
|
typedef std::list< SymbolPtr > SymbolPtrList;
|
||||||
|
|
||||||
|
class SymbolSession;
|
||||||
|
typedef boost::shared_ptr<SymbolSession> SymbolSessionPtr;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
enum SymTagEnum
|
enum SymTagEnum
|
||||||
@ -139,9 +142,21 @@ public:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class SymbolSession {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual SymbolPtr& getSymbolScope() = 0;
|
||||||
|
|
||||||
|
virtual SymbolPtr findByRva( ULONG rva, ULONG symTag = SymTagData, LONG* displacement = NULL ) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string getBasicTypeName( ULONG basicType );
|
std::string getBasicTypeName( ULONG basicType );
|
||||||
|
|
||||||
SymbolPtr loadSymbolFile(const std::string &filePath, ULONGLONG loadBase = 0);
|
SymbolSessionPtr loadSymbolFile(const std::string &filePath, ULONGLONG loadBase = 0);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ void splitSymName( const std::string &fullName, std::string &moduleName, std::st
|
|||||||
{
|
{
|
||||||
boost::cmatch matchResult;
|
boost::cmatch matchResult;
|
||||||
|
|
||||||
//OutputReader outputDiscard( m_client );
|
|
||||||
|
|
||||||
if ( !boost::regex_match( fullName.c_str(), matchResult, moduleSymMatch ) )
|
if ( !boost::regex_match( fullName.c_str(), matchResult, moduleSymMatch ) )
|
||||||
{
|
{
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
|
Loading…
Reference in New Issue
Block a user