mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:24:52 +08:00
[0.2.x] added: if there is no symbol information, symbols construct from module exports
git-svn-id: https://pykd.svn.codeplex.com/svn@82047 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
c5080ef41e
commit
e22b5e319f
@ -228,7 +228,7 @@ public:
|
|||||||
m_session( session )
|
m_session( session )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SymbolPtr& getSymbolScope() {
|
SymbolPtr getSymbolScope() {
|
||||||
return m_globalSymbol;
|
return m_globalSymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,11 +55,14 @@ SymbolSessionPtr& Module::getSymSession()
|
|||||||
if (m_symSession)
|
if (m_symSession)
|
||||||
return m_symSession;
|
return m_symSession;
|
||||||
|
|
||||||
SymbolMapKey cacheKey = { m_size, m_timeDataStamp, m_checkSum };
|
SymbolMapKey cacheKey = { m_name, m_size, m_timeDataStamp, m_checkSum };
|
||||||
SymbolSessionCache::iterator found = m_symSessionCache.find( cacheKey );
|
SymbolSessionCache::iterator found = m_symSessionCache.find( cacheKey );
|
||||||
if ( found != m_symSessionCache.end() )
|
if ( found != m_symSessionCache.end() )
|
||||||
{
|
{
|
||||||
m_symSession = found->second;
|
m_symSession = found->second;
|
||||||
|
if ( !m_symSession )
|
||||||
|
throw SymbolException( "failed to load symbol file" );
|
||||||
|
|
||||||
return m_symSession;
|
return m_symSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,9 +82,8 @@ SymbolSessionPtr& Module::getSymSession()
|
|||||||
// TODO: read image file path and load using IDiaReadExeAtOffsetCallback
|
// TODO: read image file path and load using IDiaReadExeAtOffsetCallback
|
||||||
|
|
||||||
m_symfile = getModuleSymbolFileName(m_base);
|
m_symfile = getModuleSymbolFileName(m_base);
|
||||||
if (m_symfile.empty())
|
if (!m_symfile.empty() )
|
||||||
throw SymbolException( "failed to find symbol file" );
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_symSession = loadSymbolFile(m_symfile, m_base);
|
m_symSession = loadSymbolFile(m_symfile, m_base);
|
||||||
@ -95,15 +97,31 @@ SymbolSessionPtr& Module::getSymSession()
|
|||||||
m_symSessionCache.insert( std::make_pair( cacheKey, m_symSession ) );
|
m_symSessionCache.insert( std::make_pair( cacheKey, m_symSession ) );
|
||||||
return m_symSession;
|
return m_symSession;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_symfile.clear();
|
try
|
||||||
|
{
|
||||||
|
m_symSession = loadSymbolFromExports(m_base);
|
||||||
|
m_symfile = "export symbols";
|
||||||
|
}
|
||||||
|
catch(const SymbolException&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_symSession)
|
||||||
|
{
|
||||||
|
m_symSessionCache.insert( std::make_pair( cacheKey, m_symSession ) );
|
||||||
|
return m_symSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_symSessionCache.insert( std::make_pair( cacheKey, SymbolSessionPtr() ) );
|
||||||
|
|
||||||
throw SymbolException( "failed to load symbol file" );
|
throw SymbolException( "failed to load symbol file" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SymbolPtr& Module::getSymScope()
|
SymbolPtr Module::getSymScope()
|
||||||
{
|
{
|
||||||
return getSymSession()->getSymbolScope();
|
return getSymSession()->getSymbolScope();
|
||||||
}
|
}
|
||||||
@ -112,7 +130,7 @@ SymbolPtr& Module::getSymScope()
|
|||||||
|
|
||||||
void Module::reloadSymbols()
|
void Module::reloadSymbols()
|
||||||
{
|
{
|
||||||
SymbolMapKey cacheKey = { m_size, m_timeDataStamp, m_checkSum };
|
SymbolMapKey cacheKey = { m_name, m_size, m_timeDataStamp, m_checkSum };
|
||||||
m_symSessionCache.erase( cacheKey );
|
m_symSessionCache.erase( cacheKey );
|
||||||
|
|
||||||
m_symSession.reset();
|
m_symSession.reset();
|
||||||
|
@ -27,12 +27,18 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
struct SymbolMapKey{
|
struct SymbolMapKey{
|
||||||
|
std::string name;
|
||||||
ULONG size;
|
ULONG size;
|
||||||
ULONG timeStamp;
|
ULONG timeStamp;
|
||||||
ULONG checkSum;
|
ULONG checkSum;
|
||||||
|
|
||||||
bool operator < ( const SymbolMapKey& key ) const
|
bool operator < ( const SymbolMapKey& key ) const
|
||||||
{
|
{
|
||||||
|
if ( name < key.name )
|
||||||
|
return true;
|
||||||
|
if ( name > key.name )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( size < key.size )
|
if ( size < key.size )
|
||||||
return true;
|
return true;
|
||||||
if ( size > key.size )
|
if ( size > key.size )
|
||||||
@ -143,7 +149,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SymbolPtr& getSymScope();
|
SymbolPtr getSymScope();
|
||||||
|
|
||||||
SymbolSessionPtr& getSymSession();
|
SymbolSessionPtr& getSymSession();
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ class SymbolSession {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual SymbolPtr& getSymbolScope() = 0;
|
virtual SymbolPtr getSymbolScope() = 0;
|
||||||
|
|
||||||
virtual SymbolPtr findByRva( ULONG rva, ULONG symTag = SymTagNull, LONG* displacement = NULL ) = 0;
|
virtual SymbolPtr findByRva( ULONG rva, ULONG symTag = SymTagNull, LONG* displacement = NULL ) = 0;
|
||||||
|
|
||||||
@ -183,6 +183,8 @@ SymbolSessionPtr loadSymbolFile(
|
|||||||
|
|
||||||
void setSymSrvDir(const std::wstring &symSrvDirectory);
|
void setSymSrvDir(const std::wstring &symSrvDirectory);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
SymbolSessionPtr loadSymbolFromExports(ULONGLONG loadBase);
|
||||||
|
|
||||||
}; // end pykd endpoint
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}; // end pykd namespace
|
Loading…
Reference in New Issue
Block a user