diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index ea5ade0..7285ca0 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -621,6 +621,18 @@ BOOST_PYTHON_MODULE( pykd ) "Retrun system thread ID ( TID )" ) .add_property("teb", TargetThreadAdapter::getTebOffset, "Return TEB address" ) + .add_property( "ip", TargetThreadAdapter::getIP, + "instruction pointer" ) + .add_property( "instructionOffset", TargetThreadAdapter::getIP, + "Return an instruction offset" ) + .add_property( "fp", TargetThreadAdapter::getFP, + "frame pointer" ) + .add_property( "frameOffset",TargetThreadAdapter::getFP, + "Return a frame's offset" ) + .add_property( "sp", TargetThreadAdapter::getSP, + "stack pointer" ) + .add_property( "stackOffset", TargetThreadAdapter::getSP, + "Return a stack pointer" ) .def("setCurrent", TargetThreadAdapter::setCurrent, "Set this thread current") .def("isCurrent", TargetThreadAdapter::isCurrent, diff --git a/pykd/pyprocess.h b/pykd/pyprocess.h index fe9b4bf..26cd75c 100644 --- a/pykd/pyprocess.h +++ b/pykd/pyprocess.h @@ -272,6 +272,25 @@ struct TargetThreadAdapter { } static python::list getStack(kdlib::TargetThread& thread); + + static kdlib::MEMOFFSET_64 getIP(kdlib::TargetThread& thread) + { + AutoRestorePyState pystate; + return thread.getInstructionOffset(); + } + + static kdlib::MEMOFFSET_64 getSP(kdlib::TargetThread& thread) + { + AutoRestorePyState pystate; + return thread.getStackOffset(); + } + + static kdlib::MEMOFFSET_64 getFP(kdlib::TargetThread& thread) + { + AutoRestorePyState pystate; + return thread.getFrameOffset(); + } + }; } // pykd namespace diff --git a/pykd/pytypedvar.cpp b/pykd/pytypedvar.cpp index ae4f67b..7e50771 100644 --- a/pykd/pytypedvar.cpp +++ b/pykd/pytypedvar.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "pytypedvar.h" +#include "kdlib/exceptions.h" namespace pykd { @@ -100,8 +101,9 @@ python::list TypedVarAdapter::getFields( kdlib::TypedVar& typedVar ) python::list TypedVarAdapter::getElementsDir(kdlib::TypedVar& typedVar) { std::list lst; + python::list pylst; - do { + try { AutoRestorePyState pystate; @@ -111,9 +113,10 @@ python::list TypedVarAdapter::getElementsDir(kdlib::TypedVar& typedVar) lst.push_back(name); } - } while (false); - - python::list pylst; + } catch(kdlib::DbgException&) + { + return pylst; + } for (std::list::const_iterator it = lst.begin(); it != lst.end(); ++it) pylst.append(*it); diff --git a/pykd/pytypeinfo.cpp b/pykd/pytypeinfo.cpp index 50f082e..84001e2 100644 --- a/pykd/pytypeinfo.cpp +++ b/pykd/pytypeinfo.cpp @@ -108,7 +108,9 @@ python::list TypeInfoAdapter::getElementDir(kdlib::TypeInfo &typeInfo) { std::list lst; - do { + python::list pylst; + + try{ AutoRestorePyState pystate; @@ -118,9 +120,10 @@ python::list TypeInfoAdapter::getElementDir(kdlib::TypeInfo &typeInfo) lst.push_back(name); } - } while (false); - - python::list pylst; + } catch(kdlib::DbgException&) + { + return pylst; + } for (std::list::const_iterator it = lst.begin(); it != lst.end(); ++it) pylst.append(*it);