mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:24:52 +08:00
[0.3.x] added : onChangeExecutionState
git-svn-id: https://pykd.svn.codeplex.com/svn@84228 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
17dbcecbe9
commit
6d0bb6e9ab
@ -65,6 +65,48 @@ kdlib::ExecutionStatus targetStepIn()
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
kdlib::PROCESS_DEBUG_ID startProcess( const std::wstring &processName )
|
||||||
|
{
|
||||||
|
kdlib::PROCESS_DEBUG_ID id;
|
||||||
|
|
||||||
|
PyThreadState* state = PyEval_SaveThread();
|
||||||
|
|
||||||
|
id = kdlib::startProcess(processName);
|
||||||
|
|
||||||
|
PyEval_RestoreThread( state );
|
||||||
|
|
||||||
|
return id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
kdlib::PROCESS_DEBUG_ID attachProcess( kdlib::PROCESS_ID pid )
|
||||||
|
{
|
||||||
|
kdlib::PROCESS_DEBUG_ID id;
|
||||||
|
|
||||||
|
PyThreadState* state = PyEval_SaveThread();
|
||||||
|
|
||||||
|
id = kdlib::attachProcess(pid);
|
||||||
|
|
||||||
|
PyEval_RestoreThread( state );
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void loadDump( const std::wstring &fileName )
|
||||||
|
{
|
||||||
|
PyThreadState* state = PyEval_SaveThread();
|
||||||
|
|
||||||
|
kdlib::loadDump(fileName);
|
||||||
|
|
||||||
|
PyEval_RestoreThread( state );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset )
|
python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset )
|
||||||
{
|
{
|
||||||
std::wstring fileName;
|
std::wstring fileName;
|
||||||
|
@ -14,6 +14,10 @@ void targetBreak();
|
|||||||
kdlib::ExecutionStatus targetStep();
|
kdlib::ExecutionStatus targetStep();
|
||||||
kdlib::ExecutionStatus targetStepIn();
|
kdlib::ExecutionStatus targetStepIn();
|
||||||
|
|
||||||
|
kdlib::PROCESS_DEBUG_ID startProcess( const std::wstring &processName );
|
||||||
|
kdlib::PROCESS_DEBUG_ID attachProcess( kdlib::PROCESS_ID pid );
|
||||||
|
void loadDump( const std::wstring &fileName );
|
||||||
|
|
||||||
python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset = 0 );
|
python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset = 0 );
|
||||||
|
|
||||||
python::tuple findSymbolAndDisp( ULONG64 offset );
|
python::tuple findSymbolAndDisp( ULONG64 offset );
|
||||||
|
@ -176,4 +176,26 @@ kdlib::DebugCallbackResult EventHandler::onBreakpoint( kdlib::BREAKPOINT_ID bpId
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void EventHandler::onExecutionStatusChange( kdlib::ExecutionStatus executionStatus )
|
||||||
|
{
|
||||||
|
PyEval_RestoreThread( m_pystate );
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
python::override pythonHandler = get_override( "onExecutionStatusChange" );
|
||||||
|
if ( pythonHandler )
|
||||||
|
{
|
||||||
|
pythonHandler( executionStatus );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const python::error_already_set &)
|
||||||
|
{
|
||||||
|
printException();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pystate = PyEval_SaveThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} // end namespace pykd
|
} // end namespace pykd
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
EventHandler();
|
EventHandler();
|
||||||
|
|
||||||
virtual kdlib::DebugCallbackResult onBreakpoint( kdlib::BREAKPOINT_ID bpId );
|
virtual kdlib::DebugCallbackResult onBreakpoint( kdlib::BREAKPOINT_ID bpId );
|
||||||
|
virtual void onExecutionStatusChange( kdlib::ExecutionStatus executionStatus );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -83,15 +83,15 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
|
|
||||||
// Manage debug target
|
// Manage debug target
|
||||||
|
|
||||||
python::def( "startProcess", &kdlib::startProcess,
|
python::def( "startProcess", &startProcess,
|
||||||
"Start process for debugging" );
|
"Start process for debugging" );
|
||||||
python::def( "attachProcess", &kdlib::attachProcess,
|
python::def( "attachProcess", &attachProcess,
|
||||||
"Attach debugger to a exsisting process" );
|
"Attach debugger to a exsisting process" );
|
||||||
python::def( "detachProcess", &kdlib::detachProcess, detachProcess_( boost::python::args( "pid" ),
|
python::def( "detachProcess", &kdlib::detachProcess, detachProcess_( boost::python::args( "pid" ),
|
||||||
"Stop process debugging") );
|
"Stop process debugging") );
|
||||||
python::def( "killProcess", &kdlib::terminateProcess, terminateProcess_( boost::python::args( "pid" ),
|
python::def( "killProcess", &kdlib::terminateProcess, terminateProcess_( boost::python::args( "pid" ),
|
||||||
"Stop debugging and terminate current process" ) );
|
"Stop debugging and terminate current process" ) );
|
||||||
python::def( "loadDump", &kdlib::loadDump,
|
python::def( "loadDump", &loadDump,
|
||||||
"Load crash dump");
|
"Load crash dump");
|
||||||
python::def( "isDumpAnalyzing", &kdlib::isDumpAnalyzing,
|
python::def( "isDumpAnalyzing", &kdlib::isDumpAnalyzing,
|
||||||
"Check if it is a dump analyzing ( not living debuggee )" );
|
"Check if it is a dump analyzing ( not living debuggee )" );
|
||||||
@ -616,21 +616,21 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
// "Function reads the kernel bug check code and related parameters\n"
|
// "Function reads the kernel bug check code and related parameters\n"
|
||||||
// "And return tuple: (code, arg1, arg2, arg3, arg4)" );
|
// "And return tuple: (code, arg1, arg2, arg3, arg4)" );
|
||||||
|
|
||||||
// python::class_<Disasm>("disasm", "Class disassemble a processor instructions" )
|
python::class_<kdlib::Disasm>("disasm", "Class disassemble a processor instructions" )
|
||||||
// .def( python::init<>( "constructor" ) )
|
.def( python::init<>( "constructor" ) )
|
||||||
// .def( python::init<ULONG64>( boost::python::args("offset"), "constructor" ) )
|
.def( python::init<ULONG64>( boost::python::args("offset"), "constructor" ) )
|
||||||
// .def( "disasm", &Disasm::disassemble, "Disassemble next instruction" )
|
.def( "disasm", &kdlib::Disasm::disassemble, "Disassemble next instruction" )
|
||||||
// .def( "disasm", &Disasm::jump, "Disassemble from the specified offset" )
|
.def( "disasm", &kdlib::Disasm::jump, "Disassemble from the specified offset" )
|
||||||
// .def( "asm", &Disasm::assembly, "Insert assemblied instuction to current offset" )
|
.def( "asm", &kdlib::Disasm::assembly, "Insert assemblied instuction to current offset" )
|
||||||
// .def( "begin", &Disasm::begin, "Return begin offset" )
|
.def( "begin", &kdlib::Disasm::begin, "Return begin offset" )
|
||||||
// .def( "current", &Disasm::current, "Return current offset" )
|
.def( "current", &kdlib::Disasm::current, "Return current offset" )
|
||||||
// .def( "length", &Disasm::length, "Return current instruction length" )
|
.def( "length", &kdlib::Disasm::length, "Return current instruction length" )
|
||||||
// .def( "instruction", &Disasm::instruction, "Returm current disassembled instruction" )
|
.def( "instruction", &kdlib::Disasm::instruction, "Returm current disassembled instruction" )
|
||||||
// .def( "ea", &Disasm::ea, "Return effective address for last disassembled instruction or 0" )
|
.def( "ea", &kdlib::Disasm::ea, "Return effective address for last disassembled instruction or 0" )
|
||||||
// .def( "reset", &Disasm::reset, "Reset current offset to begin" )
|
.def( "reset", &kdlib::Disasm::reset, "Reset current offset to begin" )
|
||||||
// .def( "findOffset", &Disasm::getNearInstruction, "Return the location of a processor instruction relative to a given location" )
|
.def( "findOffset", &kdlib::Disasm::getNearInstruction, "Return the location of a processor instruction relative to a given location" )
|
||||||
// .def( "jump", &Disasm::jump, "Change the current instruction" )
|
.def( "jump", &kdlib::Disasm::jump, "Change the current instruction" )
|
||||||
// .def( "jumprel", &Disasm::jumprel, "Change the current instruction" );
|
.def( "jumprel", &kdlib::Disasm::jumprel, "Change the current instruction" );
|
||||||
|
|
||||||
|
|
||||||
python::enum_<kdlib::DebugCallbackResult>("eventResult", "Return value of event handler")
|
python::enum_<kdlib::DebugCallbackResult>("eventResult", "Return value of event handler")
|
||||||
@ -660,9 +660,9 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
// .def( "onException", &EventHandlerWrap::OnException,
|
// .def( "onException", &EventHandlerWrap::OnException,
|
||||||
// "Triggered exception event. Parameter - exceptionInfo\n"
|
// "Triggered exception event. Parameter - exceptionInfo\n"
|
||||||
// "For ignore event method must return eventResult.noChange" )
|
// "For ignore event method must return eventResult.noChange" )
|
||||||
// .def( "onExecutionStatusChange", &EventHandlerWrap::onExecutionStatusChange,
|
.def( "onExecutionStatusChange", &EventHandler::onExecutionStatusChange,
|
||||||
// "Triggered execution status changed. Parameter - execution status.\n"
|
"Triggered execution status changed. Parameter - execution status.\n"
|
||||||
// "There is no return value" )
|
"There is no return value" )
|
||||||
// .def( "onSymbolsLoaded", &EventHandlerWrap::onSymbolsLoaded,
|
// .def( "onSymbolsLoaded", &EventHandlerWrap::onSymbolsLoaded,
|
||||||
// "Triggered debug symbols loaded. Parameter - module base or 0\n"
|
// "Triggered debug symbols loaded. Parameter - module base or 0\n"
|
||||||
// "There is no return value")
|
// "There is no return value")
|
||||||
|
Loading…
Reference in New Issue
Block a user