diff --git a/pykd/pydbgeng.cpp b/pykd/pydbgeng.cpp index 6eafc0f..e6b9825 100644 --- a/pykd/pydbgeng.cpp +++ b/pykd/pydbgeng.cpp @@ -4,6 +4,7 @@ #include "kdlib/typeinfo.h" #include "pydbgeng.h" +#include "stladaptor.h" #include "variant.h" namespace pykd { @@ -96,4 +97,49 @@ std::wstring printExceptionInfo( kdlib::ExceptionInfo& exceptionInfo ) /////////////////////////////////////////////////////////////////////////////// +python::list getProcessThreads() +{ + std::vector threadList; + + do { + + AutoRestorePyState pystate; + + unsigned long threadNumber = getNumberThreads(); + + for ( unsigned long i = 0; i < threadNumber; ++i ) + { + kdlib::THREAD_DEBUG_ID threadId = kdlib::getThreadIdByIndex(i); + threadList.push_back( kdlib::getThreadOffset(threadId) ); + } + + } while(false); + + return vectorToList(threadList); +} + +/////////////////////////////////////////////////////////////////////////////// + +python::list getTargetProcesses() +{ + std::vector processList; + + do { + + AutoRestorePyState pystate; + + unsigned long processNumber = getNumberProcesses(); + + for ( unsigned long i = 0; i < processNumber; ++i ) + { + processList.push_back( kdlib::getProcessIdByIndex(i) ); + } + + } while(false); + + return vectorToList(processList); +} + +/////////////////////////////////////////////////////////////////////////////// + } //end namespace pykd diff --git a/pykd/pydbgeng.h b/pykd/pydbgeng.h index f7602ba..eadf3a7 100644 --- a/pykd/pydbgeng.h +++ b/pykd/pydbgeng.h @@ -213,6 +213,9 @@ inline kdlib::MEMOFFSET_64 getImplicitProcessOffset() return kdlib::getImplicitProcessOffset(); } +python::list getProcessThreads(); +python::list getTargetProcesses(); + /////////////////////////////////////////////////////////////////////////////// inline diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index a09ef96..b220136 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -363,6 +363,10 @@ BOOST_PYTHON_MODULE( pykd ) "Set implicit process" ); // python::def( "getCurrentProcessExeName", &getCurrentProcessExecutableName, // "Return name of executable file loaded in the current process"); + python::def( "getProcessThreads", pykd::getProcessThreads, + "Get all process's threads " ); + python::def( "getTargetProcesses", pykd::getTargetProcesses, + "Get all target processes " ); python::def ( "getNumberThreads", pykd::getNumberThreads, diff --git a/test/scripts/pykdtest.py b/test/scripts/pykdtest.py index 294db95..a0cc2ab 100644 --- a/test/scripts/pykdtest.py +++ b/test/scripts/pykdtest.py @@ -81,7 +81,7 @@ def getTestSuite( singleName = "" ): if __name__ == "__main__": - print "\nTesting PyKd ver. " + pykd.version + print "\nTesting PyKd ver. " + pykd.__version__ target.appPath = sys.argv[1] target.moduleName = os.path.splitext(os.path.basename(target.appPath))[0]