mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 20:03:33 +08:00
[~] updated : dbgModuleClass constructor fills symbol cache for optimization
git-svn-id: https://pykd.svn.codeplex.com/svn@60474 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
f932c40469
commit
afb977d03b
@ -101,6 +101,47 @@ findModule( ULONG64 addr )
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
dbgModuleClass::dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ) :
|
||||||
|
m_name( name ),
|
||||||
|
m_base( base ),
|
||||||
|
m_end( base + size )
|
||||||
|
{
|
||||||
|
reloadSymbols();
|
||||||
|
|
||||||
|
std::string pattern = name + "!*";
|
||||||
|
ULONG64 enumHandle = 0;
|
||||||
|
|
||||||
|
HRESULT hres = dbgExt->symbols->StartSymbolMatch( pattern.c_str(), &enumHandle );
|
||||||
|
|
||||||
|
while( SUCCEEDED( hres ) )
|
||||||
|
{
|
||||||
|
char nameBuf[0x100];
|
||||||
|
ULONG64 offset = 0;
|
||||||
|
|
||||||
|
hres =
|
||||||
|
dbgExt->symbols->GetNextSymbolMatch(
|
||||||
|
enumHandle,
|
||||||
|
nameBuf,
|
||||||
|
sizeof( nameBuf ),
|
||||||
|
NULL,
|
||||||
|
&offset );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
break;
|
||||||
|
|
||||||
|
std::string symbolName( nameBuf );
|
||||||
|
|
||||||
|
symbolName.erase( 0, name.size() + 1 );
|
||||||
|
|
||||||
|
m_offsets.insert( std::make_pair( symbolName, offset ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( enumHandle )
|
||||||
|
dbgExt->symbols->EndSymbolMatch( enumHandle );
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void
|
void
|
||||||
dbgModuleClass::reloadSymbols()
|
dbgModuleClass::reloadSymbols()
|
||||||
{
|
{
|
||||||
@ -137,13 +178,7 @@ dbgModuleClass::getOffset( const std::string &symName )
|
|||||||
return offset->second;
|
return offset->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG64 offsetVal = findAddressForSymbol( m_name, symName );
|
return 0;
|
||||||
if ( (ULONG64)~0 == offsetVal )
|
|
||||||
return offsetVal;
|
|
||||||
|
|
||||||
m_offsets.insert( std::make_pair( symName, offsetVal ) );
|
|
||||||
|
|
||||||
return offsetVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -17,11 +17,7 @@ public:
|
|||||||
m_end( 0 )
|
m_end( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ) :
|
dbgModuleClass( const std::string &name, ULONG64 base, ULONG size );
|
||||||
m_name( name ),
|
|
||||||
m_base( base ),
|
|
||||||
m_end( base + size )
|
|
||||||
{}
|
|
||||||
|
|
||||||
ULONG64
|
ULONG64
|
||||||
getBegin() const {
|
getBegin() const {
|
||||||
|
@ -72,9 +72,7 @@ findAddressForSymbol( const std::string &moduleName, const std::string &symbol
|
|||||||
|
|
||||||
ULONG64 offset = 0ULL;
|
ULONG64 offset = 0ULL;
|
||||||
hres = dbgExt->symbols->GetOffsetByName( ModuleSymName.c_str(), &offset );
|
hres = dbgExt->symbols->GetOffsetByName( ModuleSymName.c_str(), &offset );
|
||||||
if ( FAILED( hres ) )
|
if ( SUCCEEDED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol::GetOffsetByName failed" );
|
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
catch( std::exception &e )
|
catch( std::exception &e )
|
||||||
@ -86,7 +84,7 @@ findAddressForSymbol( const std::string &moduleName, const std::string &symbol
|
|||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ULONG64)~0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue
Block a user