mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-22 05:13:22 +08:00
[0.1.x] added : module class can be created directly ( added two constructors )
git-svn-id: https://pykd.svn.codeplex.com/svn@75295 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
322f1a39a6
commit
811a673b47
@ -504,9 +504,9 @@ TypeInfoPtr DebugClient::getTypeInfoByName( const std::string &typeName )
|
|||||||
|
|
||||||
splitSymName( typeName, moduleName, symName );
|
splitSymName( typeName, moduleName, symName );
|
||||||
|
|
||||||
Module module = loadModuleByName( moduleName );
|
ModulePtr module = loadModuleByName( moduleName );
|
||||||
|
|
||||||
return module.getTypeByName( symName );
|
return module->getTypeByName( symName );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -518,9 +518,9 @@ TypedVarPtr DebugClient::getTypedVarByName( const std::string &varName )
|
|||||||
|
|
||||||
splitSymName( varName, moduleName, symName );
|
splitSymName( varName, moduleName, symName );
|
||||||
|
|
||||||
Module module = loadModuleByName( moduleName );
|
ModulePtr module = loadModuleByName( moduleName );
|
||||||
|
|
||||||
return module.getTypedVarByName( symName );
|
return module->getTypedVarByName( symName );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -534,9 +534,9 @@ TypedVarPtr DebugClient::getTypedVarByTypeName( const std::string &typeName, ULO
|
|||||||
|
|
||||||
splitSymName( typeName, moduleName, symName );
|
splitSymName( typeName, moduleName, symName );
|
||||||
|
|
||||||
Module module = loadModuleByName( moduleName );
|
ModulePtr module = loadModuleByName( moduleName );
|
||||||
|
|
||||||
return module.getTypedVarByTypeName( symName, addr );
|
return module->getTypedVarByTypeName( symName, addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -550,9 +550,9 @@ TypedVarPtr DebugClient::containingRecordByName( ULONG64 addr, const std::string
|
|||||||
|
|
||||||
splitSymName( typeName, moduleName, symName );
|
splitSymName( typeName, moduleName, symName );
|
||||||
|
|
||||||
Module module = loadModuleByName( moduleName );
|
ModulePtr module = loadModuleByName( moduleName );
|
||||||
|
|
||||||
return module.containingRecordByName( addr, symName, fieldName );
|
return module->containingRecordByName( addr, symName, fieldName );
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedVarPtr containingRecordByName( ULONG64 addr, const std::string &typeName, const std::string &fieldName )
|
TypedVarPtr containingRecordByName( ULONG64 addr, const std::string &typeName, const std::string &fieldName )
|
||||||
@ -618,9 +618,9 @@ python::list DebugClient::getTypedVarListByTypeName( ULONG64 listHeadAddress, co
|
|||||||
|
|
||||||
splitSymName( typeName, moduleName, symName );
|
splitSymName( typeName, moduleName, symName );
|
||||||
|
|
||||||
Module module = loadModuleByName( moduleName );
|
ModulePtr module = loadModuleByName( moduleName );
|
||||||
|
|
||||||
return module.getTypedVarListByTypeName( listHeadAddress, symName, listEntryName );
|
return module->getTypedVarListByTypeName( listHeadAddress, symName, listEntryName );
|
||||||
}
|
}
|
||||||
|
|
||||||
python::list getTypedVarListByTypeName( ULONG64 listHeadAddress, const std::string &typeName, const std::string &listEntryName )
|
python::list getTypedVarListByTypeName( ULONG64 listHeadAddress, const std::string &typeName, const std::string &listEntryName )
|
||||||
@ -656,9 +656,9 @@ python::list DebugClient::getTypedVarArrayByTypeName( ULONG64 addr, const std::s
|
|||||||
|
|
||||||
splitSymName( typeName, moduleName, symName );
|
splitSymName( typeName, moduleName, symName );
|
||||||
|
|
||||||
Module module = loadModuleByName( moduleName );
|
ModulePtr module = loadModuleByName( moduleName );
|
||||||
|
|
||||||
return module.getTypedVarArrayByTypeName( addr, symName, number );
|
return module->getTypedVarArrayByTypeName( addr, symName, number );
|
||||||
}
|
}
|
||||||
|
|
||||||
python::list getTypedVarArrayByTypeName( ULONG64 addr, const std::string &typeName, ULONG number )
|
python::list getTypedVarArrayByTypeName( ULONG64 addr, const std::string &typeName, ULONG number )
|
||||||
|
@ -153,12 +153,12 @@ public:
|
|||||||
|
|
||||||
void loadDump( const std::wstring &fileName );
|
void loadDump( const std::wstring &fileName );
|
||||||
|
|
||||||
Module loadModuleByName( const std::string &moduleName ) {
|
ModulePtr loadModuleByName( const std::string &moduleName ) {
|
||||||
return Module( m_client, m_symSymbols, moduleName );
|
return ModulePtr( new Module( m_client, m_symSymbols, moduleName ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Module loadModuleByOffset( ULONG64 offset ) {
|
ModulePtr loadModuleByOffset( ULONG64 offset ) {
|
||||||
return Module( m_client, m_symSymbols, offset );
|
return ModulePtr( new Module( m_client, m_symSymbols, offset ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgExtensionPtr loadExtension( const std::wstring &extPath ) {
|
DbgExtensionPtr loadExtension( const std::wstring &extPath ) {
|
||||||
|
@ -72,7 +72,7 @@ protected:
|
|||||||
|
|
||||||
virtual ULONG onException(const python::dict &/*exceptData*/) = 0;
|
virtual ULONG onException(const python::dict &/*exceptData*/) = 0;
|
||||||
|
|
||||||
virtual ULONG onLoadModule(const Module &/* module */) = 0;
|
virtual ULONG onLoadModule(const ModulePtr &/* module */) = 0;
|
||||||
|
|
||||||
virtual ULONG onUnloadModule(ULONG64 /*modBase*/) = 0;
|
virtual ULONG onUnloadModule(ULONG64 /*modBase*/) = 0;
|
||||||
|
|
||||||
@ -108,8 +108,8 @@ public:
|
|||||||
return handler<const python::dict&>("onException", exceptData);
|
return handler<const python::dict&>("onException", exceptData);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG onLoadModule(const Module &module) {
|
ULONG onLoadModule(const ModulePtr &module) {
|
||||||
return handler<const Module&>("onLoadModule", module );
|
return handler<const ModulePtr&>("onLoadModule", module );
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG onUnloadModule(ULONG64 modBase) {
|
ULONG onUnloadModule(ULONG64 modBase) {
|
||||||
|
@ -17,7 +17,7 @@ namespace impl {
|
|||||||
|
|
||||||
struct addLocals {
|
struct addLocals {
|
||||||
python::dict &m_locals;
|
python::dict &m_locals;
|
||||||
const Module &m_module;
|
const ModulePtr m_module;
|
||||||
ULONG m_rva;
|
ULONG m_rva;
|
||||||
ContextPtr m_ctx;
|
ContextPtr m_ctx;
|
||||||
IDebugClient4 *m_client;
|
IDebugClient4 *m_client;
|
||||||
@ -95,7 +95,7 @@ void addLocals::appendVar(pyDia::SymbolPtr symData)
|
|||||||
typedVar =
|
typedVar =
|
||||||
getTypeVarByOffset(
|
getTypeVarByOffset(
|
||||||
symData,
|
symData,
|
||||||
m_module.getBase() + symData->getRva() );
|
m_module->getBase() + symData->getRva() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LocIsRegRel:
|
case LocIsRegRel:
|
||||||
@ -189,10 +189,10 @@ python::dict DebugClient::getLocals(ContextPtr ctx OPTIONAL)
|
|||||||
|
|
||||||
const ULONG64 instrPtr = ctx->getIp();
|
const ULONG64 instrPtr = ctx->getIp();
|
||||||
|
|
||||||
Module mod = loadModuleByOffset( instrPtr );
|
ModulePtr mod = loadModuleByOffset( instrPtr );
|
||||||
const ULONG rva = static_cast<ULONG>( instrPtr - mod.getBase() );
|
const ULONG rva = static_cast<ULONG>( instrPtr - mod->getBase() );
|
||||||
|
|
||||||
pyDia::GlobalScopePtr globScope = mod.getDia();
|
pyDia::GlobalScopePtr globScope = mod->getDia();
|
||||||
LONG funcDispl;
|
LONG funcDispl;
|
||||||
pyDia::SymbolPtr symFunc =
|
pyDia::SymbolPtr symFunc =
|
||||||
globScope->findByRvaImpl(rva, SymTagFunction, funcDispl);
|
globScope->findByRvaImpl(rva, SymTagFunction, funcDispl);
|
||||||
|
@ -8,13 +8,11 @@ namespace pykd {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Module loadModuleByName( const std::string &moduleName ) {
|
ModulePtr Module::loadModuleByName( const std::string &moduleName ) {
|
||||||
return g_dbgClient->loadModuleByName( moduleName );
|
return g_dbgClient->loadModuleByName( moduleName );
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
ModulePtr Module::loadModuleByOffset( ULONG64 offset ) {
|
||||||
|
|
||||||
Module loadModuleByOffset( ULONG64 offset ) {
|
|
||||||
return g_dbgClient->loadModuleByOffset( offset );
|
return g_dbgClient->loadModuleByOffset( offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,21 @@ namespace pykd {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Module;
|
||||||
|
typedef boost::shared_ptr<Module> ModulePtr;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class Module : public intBase, private DbgObject {
|
class Module : public intBase, private DbgObject {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
static
|
||||||
|
ModulePtr loadModuleByName( const std::string &name );
|
||||||
|
|
||||||
|
static
|
||||||
|
ModulePtr loadModuleByOffset( ULONG64 offset );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, const std::string& moduleName );
|
Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, const std::string& moduleName );
|
||||||
@ -121,12 +134,6 @@ private:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Module loadModuleByName( const std::string &moduleName ) ;
|
|
||||||
|
|
||||||
Module loadModuleByOffset( ULONG64 offset );
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
}; // end pykd namespace
|
}; // end pykd namespace
|
||||||
|
|
||||||
|
|
||||||
|
@ -452,9 +452,9 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Delete synthetic symbols by mask of module and symbol name");
|
"Delete synthetic symbols by mask of module and symbol name");
|
||||||
python::def( "loadExt", &pykd::loadExtension,
|
python::def( "loadExt", &pykd::loadExtension,
|
||||||
"Load a debuger extension" );
|
"Load a debuger extension" );
|
||||||
python::def( "loadModule", &loadModuleByName,
|
python::def( "loadModule", &Module::loadModuleByName,
|
||||||
"Return instance of Module class" );
|
"Return instance of Module class" );
|
||||||
python::def( "loadModule", &loadModuleByOffset,
|
python::def( "loadModule", &Module::loadModuleByOffset,
|
||||||
"Return instance of the Module class which posseses specified address" );
|
"Return instance of the Module class which posseses specified address" );
|
||||||
python::def( "dbgCommand", &pykd::dbgCommand,
|
python::def( "dbgCommand", &pykd::dbgCommand,
|
||||||
"Run a debugger's command and return it's result as a string" ),
|
"Run a debugger's command and return it's result as a string" ),
|
||||||
@ -558,7 +558,9 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.def("__getitem__", &TypedVar::getElementByIndex )
|
.def("__getitem__", &TypedVar::getElementByIndex )
|
||||||
.def("__getitem__", &TypedVar::getElementByIndexPtr );
|
.def("__getitem__", &TypedVar::getElementByIndexPtr );
|
||||||
|
|
||||||
python::class_<Module, python::bases<intBase> >("module", "Class representing executable module", python::no_init )
|
python::class_<Module, ModulePtr, python::bases<intBase> >("module", "Class representing executable module", python::no_init )
|
||||||
|
.def("__init__", python::make_constructor(Module::loadModuleByName) )
|
||||||
|
.def("__init__", python::make_constructor(Module::loadModuleByOffset) )
|
||||||
.def("begin", &Module::getBase,
|
.def("begin", &Module::getBase,
|
||||||
"Return start address of the module" )
|
"Return start address of the module" )
|
||||||
.def("end", &Module::getEnd,
|
.def("end", &Module::getEnd,
|
||||||
|
@ -9,9 +9,8 @@ import pykd
|
|||||||
class ModuleTest( unittest.TestCase ):
|
class ModuleTest( unittest.TestCase ):
|
||||||
|
|
||||||
def testCtor( self ):
|
def testCtor( self ):
|
||||||
" module class can not be created direct """
|
self.assertEqual( target.module.name(), pykd.module(target.module.begin() ).name() )
|
||||||
try: pykd.module()
|
self.assertEqual( target.module.name(), pykd.module(target.module.name() ).name() )
|
||||||
except RuntimeError: pass
|
|
||||||
|
|
||||||
def testName( self ):
|
def testName( self ):
|
||||||
self.assertEqual( target.moduleName, target.module.name() )
|
self.assertEqual( target.moduleName, target.module.name() )
|
||||||
|
Loading…
Reference in New Issue
Block a user