mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[pykd] fixed: issue 9202 ( module object return offset = 0 for non existing symbol )
git-svn-id: https://pykd.svn.codeplex.com/svn@68357 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
369acbab98
commit
9545cf5df0
@ -17,11 +17,10 @@ loadModule( const std::string &moduleName )
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
try {
|
||||
ULONG64 moduleBase;
|
||||
hres = dbgExt->symbols->GetModuleByModuleName( moduleName.c_str(), 0, NULL, &moduleBase );
|
||||
if ( FAILED( hres ) )
|
||||
return boost::python::object();
|
||||
throw DbgException( "IDebugSymbol::GetModuleByModuleName failed" );
|
||||
|
||||
DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
||||
hres = dbgExt->symbols->GetModuleParameters( 1, &moduleBase, 0, &moduleParam );
|
||||
@ -31,17 +30,6 @@ loadModule( const std::string &moduleName )
|
||||
|
||||
return boost::python::object( dbgModuleClass( moduleName, moduleBase, moduleParam.Size ) );
|
||||
|
||||
}
|
||||
catch( std::exception &e )
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
|
||||
return boost::python::object();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -102,26 +90,13 @@ void queryModuleParams(
|
||||
boost::python::object
|
||||
findModule( ULONG64 addr )
|
||||
{
|
||||
try {
|
||||
ULONG64 moduleBase;
|
||||
ULONG moduleSize;
|
||||
std::string moduleName;
|
||||
queryModuleParams(addr, moduleName, moduleBase, moduleSize);
|
||||
return
|
||||
boost::python::object(
|
||||
dbgModuleClass( moduleName, moduleBase, moduleSize )
|
||||
);
|
||||
}
|
||||
catch( std::exception &e )
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
|
||||
return boost::python::object();
|
||||
queryModuleParams(addr, moduleName, moduleBase, moduleSize);
|
||||
|
||||
return boost::python::object( dbgModuleClass( moduleName, moduleBase, moduleSize ) );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -188,7 +163,6 @@ dbgModuleClass::reloadSymbols()
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
try {
|
||||
static const char *szReloadParam = "/f "; //"/f /s ";
|
||||
std::string reloadParam = szReloadParam;
|
||||
reloadParam += m_name;
|
||||
@ -225,16 +199,6 @@ dbgModuleClass::reloadSymbols()
|
||||
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSymbol::Reload failed" );
|
||||
}
|
||||
catch( std::exception &e )
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -247,8 +211,14 @@ dbgModuleClass::getOffset( const std::string &symName )
|
||||
{
|
||||
return offset->second;
|
||||
}
|
||||
|
||||
ModuleInfo moduleInfo(m_debugInfo);
|
||||
return ::getSyntheticSymbol(moduleInfo, symName);
|
||||
ULONG64 syntheticOffset = getSyntheticSymbol(moduleInfo, symName);
|
||||
|
||||
if ( syntheticOffset == 0 )
|
||||
throw DbgException( "failed to find offset for symbol" );
|
||||
|
||||
return syntheticOffset;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -295,8 +265,6 @@ dbgModuleClass::getImagePath()
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
try {
|
||||
|
||||
ULONG pathSize = 0;
|
||||
hres = dbgExt->symbols3->GetSymbolPathWide( NULL, 0, &pathSize );
|
||||
if ( FAILED( hres ) )
|
||||
@ -351,22 +319,10 @@ dbgModuleClass::getImagePath()
|
||||
|
||||
offset = newOffset + 1;
|
||||
}
|
||||
|
||||
}
|
||||
catch( std::exception &e )
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
dbgModuleClass::print() const
|
||||
{
|
||||
try
|
||||
{
|
||||
const char * format_string(dbgExt->control->IsPointer64Bit() == S_OK ?
|
||||
"%1$016x %2$016x %3$20s %4$20s" : "%1$08x %2$08x %3$20s %4$20s");
|
||||
@ -385,15 +341,5 @@ dbgModuleClass::print() const
|
||||
fmt % m_base % (m_end - m_base) % m_name % fullname;
|
||||
return fmt.str();
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
@ -63,8 +63,6 @@ findAddressForSymbol( const std::string &moduleName, const std::string &symbol
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
try {
|
||||
|
||||
std::string ModuleSymName = moduleName;
|
||||
ModuleSymName += "!";
|
||||
ModuleSymName += symbolName;
|
||||
@ -73,17 +71,8 @@ findAddressForSymbol( const std::string &moduleName, const std::string &symbol
|
||||
hres = dbgExt->symbols->GetOffsetByName( ModuleSymName.c_str(), &offset );
|
||||
if ( SUCCEEDED( hres ) )
|
||||
return offset;
|
||||
}
|
||||
catch( std::exception &e )
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
|
||||
return 0;
|
||||
throw DbgException( "failed to find offset for symbol" );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue
Block a user