[0.3.x] added : function getModulesList ( return list of modules for the current target )

git-svn-id: https://pykd.svn.codeplex.com/svn@91084 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\ussrhero_cp 2016-12-19 21:04:56 +00:00 committed by Mikhail I. Izmestev
parent 0288cae4f8
commit 933e3e650d
4 changed files with 27 additions and 1 deletions

View File

@ -549,6 +549,10 @@ BOOST_PYTHON_MODULE( pykd )
python::def( "setImplicitThread", pykd::setImplicitThread, python::def( "setImplicitThread", pykd::setImplicitThread,
"Set implicit thread" ); "Set implicit thread" );
// modules
python::def( "getModulesList", pykd::getModuleList,
"Return list of modules for the current target" );
// events // events
python::def("getLastEvent", pykd::getLastEvent, python::def("getLastEvent", pykd::getLastEvent,
"Get last debug event information"); "Get last debug event information");

View File

@ -6,6 +6,22 @@ namespace pykd {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
python::list getModuleList()
{
std::vector<kdlib::ModulePtr > moduleLst;
do {
AutoRestorePyState pystate;
for ( unsigned long i = 0; i < kdlib::getNumberModules(); ++i)
moduleLst.push_back( kdlib::loadModule(kdlib::getModuleOffsetByIndex(i) ) );
} while(false);
return vectorToList(moduleLst);
}
///////////////////////////////////////////////////////////////////////////////
FixedFileInfoPtr ModuleAdapter::getFixedFileInfo( kdlib::Module& module ) FixedFileInfoPtr ModuleAdapter::getFixedFileInfo( kdlib::Module& module )
{ {
AutoRestorePyState pystate; AutoRestorePyState pystate;
@ -155,4 +171,5 @@ python::list ModuleAdapter::getTypedVarArrayByTypeName( kdlib::Module& module, k
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
} // namespace pykd } // namespace pykd

View File

@ -16,6 +16,8 @@ namespace pykd {
typedef boost::shared_ptr< kdlib::FixedFileInfo > FixedFileInfoPtr; typedef boost::shared_ptr< kdlib::FixedFileInfo > FixedFileInfoPtr;
python::list getModuleList();
struct ModuleAdapter : public kdlib::Module struct ModuleAdapter : public kdlib::Module
{ {

View File

@ -1,4 +1,4 @@
# #
# #
# #
@ -136,4 +136,7 @@ class ModuleTest( unittest.TestCase ):
self.assertFalse(target.module==None) self.assertFalse(target.module==None)
self.assertTrue(target.module!=None) self.assertTrue(target.module!=None)
def testModuleList(self):
self.assertTrue( [] != pykd.getModulesList() )