[0.3.x] added : __str__ operator for targetSystem, targetProcess, targetThread classed

git-svn-id: https://pykd.svn.codeplex.com/svn@91005 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2016-07-11 10:51:59 +00:00 committed by Mikhail I. Izmestev
parent dd3c6c4628
commit 93f698a3a0
3 changed files with 44 additions and 0 deletions

View File

@ -579,6 +579,7 @@ BOOST_PYTHON_MODULE( pykd )
"Return current process")
.def("processes", TargetSystemAdapter::getProcessesList,
"get list of processes for the target system")
.def("__str__", TargetSystemAdapter::print)
;
python::class_<kdlib::TargetProcess, kdlib::TargetProcessPtr, boost::noncopyable>("targetProcess", "Class representing process in the target system", python::no_init )
@ -622,6 +623,7 @@ BOOST_PYTHON_MODULE( pykd )
"Return list of breakpoints for the target process")
.def("modules", TargetProcessAdapter::getModulesList,
"Return list of modules for the target process")
.def("__str__", TargetProcessAdapter::print)
;
python::class_<kdlib::TargetThread, kdlib::TargetThreadPtr, boost::noncopyable>("targetThread", "Class representing process in the target system", python::no_init )
@ -657,6 +659,7 @@ BOOST_PYTHON_MODULE( pykd )
"Check if this thread is current")
.def("stack", TargetThreadAdapter::getStack,
"Get thread's stack tarce")
.def("__str__", TargetThreadAdapter::print)
;
python::class_<kdlib::Module, kdlib::ModulePtr, python::bases<kdlib::NumBehavior>, boost::noncopyable>("module", "Class representing executable module", python::no_init)

View File

@ -22,6 +22,18 @@ python::list TargetSystemAdapter::getProcessesList(kdlib::TargetSystem& system)
///////////////////////////////////////////////////////////////////////////////
std::wstring TargetSystemAdapter::print(kdlib::TargetSystem& system)
{
std::wstringstream sstr;
sstr << "Target System:" << std::endl;
sstr << system.getDescription() << std::endl;
return sstr.str();
}
///////////////////////////////////////////////////////////////////////////////
python::list TargetProcessAdapter::getThreadList(kdlib::TargetProcess& process)
{
std::vector<kdlib::TargetThreadPtr> threadLst;
@ -67,6 +79,18 @@ python::list TargetProcessAdapter::getModulesList(kdlib::TargetProcess& process)
///////////////////////////////////////////////////////////////////////////////
std::wstring TargetProcessAdapter::print(kdlib::TargetProcess& process)
{
std::wstringstream sstr;
sstr << "Target Process:" << std::endl;
sstr << "PID: " << std::hex << process.getSystemId() << std::endl;
sstr << "Name: " << process.getExecutableName() << std::endl;
return sstr.str();
}
///////////////////////////////////////////////////////////////////////////////
python::list TargetThreadAdapter::getStack(kdlib::TargetThread& thread)
{
@ -85,5 +109,17 @@ python::list TargetThreadAdapter::getStack(kdlib::TargetThread& thread)
///////////////////////////////////////////////////////////////////////////////
std::wstring TargetThreadAdapter::print(kdlib::TargetThread& thread)
{
std::wstringstream sstr;
sstr << "Target Thread:" << std::endl;
sstr << "PID: " << std::hex << thread.getProcess()->getSystemId() << std::endl;
sstr << "TID: " << std::hex << thread.getSystemId() << std::endl;
return sstr.str();
}
///////////////////////////////////////////////////////////////////////////////
}

View File

@ -94,6 +94,8 @@ struct TargetSystemAdapter {
}
static python::list getProcessesList(kdlib::TargetSystem& system);
static std::wstring print(kdlib::TargetSystem& system);
};
@ -212,6 +214,8 @@ struct TargetProcessAdapter {
static python::list getBreakpointsList(kdlib::TargetProcess& process);
static python::list getModulesList(kdlib::TargetProcess& process);
static std::wstring print(kdlib::TargetProcess& process);
};
@ -291,6 +295,7 @@ struct TargetThreadAdapter {
return thread.getFrameOffset();
}
static std::wstring print(kdlib::TargetThread& thread);
};
} // pykd namespace