diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 5007617..7185908 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -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_("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_("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_, boost::noncopyable>("module", "Class representing executable module", python::no_init) diff --git a/pykd/pyprocess.cpp b/pykd/pyprocess.cpp index 14434ad..52f1aa2 100644 --- a/pykd/pyprocess.cpp +++ b/pykd/pyprocess.cpp @@ -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 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(); +} + +/////////////////////////////////////////////////////////////////////////////// + } diff --git a/pykd/pyprocess.h b/pykd/pyprocess.h index 26cd75c..8473315 100644 --- a/pykd/pyprocess.h +++ b/pykd/pyprocess.h @@ -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