mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.3.x] added : CTRL+BREAK support for windbg
git-svn-id: https://pykd.svn.codeplex.com/svn@84522 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
b94a9cdaae
commit
3eb38e0cca
@ -568,37 +568,12 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.def("__getattr__", &CPUContextAdaptor::getRegisterByName )
|
.def("__getattr__", &CPUContextAdaptor::getRegisterByName )
|
||||||
.def("__getitem__", &CPUContextAdaptor::getRegisterByIndex );
|
.def("__getitem__", &CPUContextAdaptor::getRegisterByIndex );
|
||||||
|
|
||||||
|
|
||||||
// python::class_<CpuReg, python::bases<intBase> >(
|
|
||||||
// "cpuReg", "CPU regsiter class", boost::python::no_init )
|
|
||||||
// .def( "name", &CpuReg::name, "The name of the regsiter" )
|
|
||||||
// .def( "index", &CpuReg::index, "The index of thr register" );
|
|
||||||
|
|
||||||
// python::class_<ScopeVars,ScopeVarsPtr,boost::noncopyable>( "locals",
|
// python::class_<ScopeVars,ScopeVarsPtr,boost::noncopyable>( "locals",
|
||||||
// "Class for access to local vars", python::no_init )
|
// "Class for access to local vars", python::no_init )
|
||||||
// .def("__len__", &ScopeVars::getVarCount )
|
// .def("__len__", &ScopeVars::getVarCount )
|
||||||
// .def("__getitem__", &ScopeVars::getVarByIndex )
|
// .def("__getitem__", &ScopeVars::getVarByIndex )
|
||||||
// .def("__getitem__", &ScopeVars::getVarByName );
|
// .def("__getitem__", &ScopeVars::getVarByName );
|
||||||
|
|
||||||
// python::class_<StackFrame, StackFramePtr,boost::noncopyable>( "stackFrame",
|
|
||||||
// "Class representing a frame of the call stack", python::no_init )
|
|
||||||
// .def_readonly( "instructionOffset", &StackFrame::m_instructionOffset,
|
|
||||||
// "Return a frame's instruction offset" )
|
|
||||||
// .def_readonly( "returnOffset", &StackFrame::m_returnOffset,
|
|
||||||
// "Return a frame's return offset" )
|
|
||||||
// .def_readonly( "frameOffset", &StackFrame::m_frameOffset,
|
|
||||||
// "Return a frame's offset" )
|
|
||||||
// .def_readonly( "stackOffset", &StackFrame::m_stackOffset,
|
|
||||||
// "Return a frame's stack offset" )
|
|
||||||
// .def_readonly( "frameNumber", &StackFrame::m_frameNumber,
|
|
||||||
// "Return a frame's number" )
|
|
||||||
// .add_property( "locals", &StackFrame::getLocals,
|
|
||||||
// "Get list of local variables for this stack frame" )
|
|
||||||
// .add_property( "params", &StackFrame::getParams,
|
|
||||||
// "Get list of function params" )
|
|
||||||
// .def( "__str__", &StackFrame::print,
|
|
||||||
// "Return stacks frame as a string");
|
|
||||||
|
|
||||||
python::class_< kdlib::SystemInfo>(
|
python::class_< kdlib::SystemInfo>(
|
||||||
"systemVersion", "Operation system version", python::no_init)
|
"systemVersion", "Operation system version", python::no_init)
|
||||||
//.def_readonly( "platformId", &SystemVersion::platformId,
|
//.def_readonly( "platformId", &SystemVersion::platformId,
|
||||||
|
@ -34,6 +34,8 @@ void PykdExt::setUp()
|
|||||||
|
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
|
|
||||||
|
PyEval_InitThreads();
|
||||||
|
|
||||||
python::import( "pykd" );
|
python::import( "pykd" );
|
||||||
|
|
||||||
// ïåðåíàïðàâëåíèå ñòàíäàðòíûõ ïîòîêîâ ÂÂ
|
// ïåðåíàïðàâëåíèå ñòàíäàðòíûõ ïîòîêîâ ÂÂ
|
||||||
@ -97,6 +99,7 @@ KDLIB_EXT_COMMAND_METHOD_IMPL(PykdExt, py)
|
|||||||
python::object global(main.attr("__dict__"));
|
python::object global(main.attr("__dict__"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
PykdInterruptWatch interruptWatch;
|
||||||
python::exec_file( scriptFileName.c_str(), global );
|
python::exec_file( scriptFileName.c_str(), global );
|
||||||
}
|
}
|
||||||
catch( python::error_already_set const & )
|
catch( python::error_already_set const & )
|
||||||
@ -116,6 +119,7 @@ void PykdExt::startConsole()
|
|||||||
python::object global(main.attr("__dict__"));
|
python::object global(main.attr("__dict__"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
PykdInterruptWatch interruptWatch;
|
||||||
python::exec( "__import__('code').InteractiveConsole(__import__('__main__').__dict__).interact()\n", global );
|
python::exec( "__import__('code').InteractiveConsole(__import__('__main__').__dict__).interact()\n", global );
|
||||||
}
|
}
|
||||||
catch( python::error_already_set const & )
|
catch( python::error_already_set const & )
|
||||||
@ -178,3 +182,28 @@ std::string PykdExt::getScriptFileName( const std::string &scriptName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool PykdInterruptWatch::onInterrupt()
|
||||||
|
{
|
||||||
|
HANDLE quitEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||||
|
PyGILState_STATE state = PyGILState_Ensure();
|
||||||
|
Py_AddPendingCall(&quit, (void*)quitEvent);
|
||||||
|
PyGILState_Release(state);
|
||||||
|
WaitForSingleObject(quitEvent,INFINITE);
|
||||||
|
CloseHandle(quitEvent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
int PykdInterruptWatch::quit(void *context)
|
||||||
|
{
|
||||||
|
HANDLE quitEvent = (HANDLE)context;
|
||||||
|
kdlib::eprintln( L"User Interrupt: CTRL+BREAK");
|
||||||
|
PyErr_SetString( PyExc_SystemExit, "CTRL+BREAK" );
|
||||||
|
SetEvent(quitEvent);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -29,3 +29,11 @@ private:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class PykdInterruptWatch : public kdlib::windbg::InterruptWatch
|
||||||
|
{
|
||||||
|
virtual bool onInterrupt();
|
||||||
|
|
||||||
|
static int quit(void *);
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user