diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index 806e783..e880f5c 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -12,6 +12,8 @@ void attachKernel( const std::string &connectOptions = "" ); bool isLocalKernelDebuggerEnabled(); void detachProcess( ULONG processId = -1); void terminateProcess( ULONG processId = -1); +void detachAllProcesses(); +void terminateAllProcesses(); void loadDump( const std::wstring &fileName ); void writeDump( const std::wstring &fileNamem, bool smallDump ); diff --git a/pykd/python/pymod.cpp b/pykd/python/pymod.cpp index 412a4a8..1a63a3b 100644 --- a/pykd/python/pymod.cpp +++ b/pykd/python/pymod.cpp @@ -102,8 +102,12 @@ BOOST_PYTHON_MODULE( pykd ) "Check whether kernel debugging is enabled for the local kernel" ); python::def( "detachProcess", &detachProcess, detachProcess_( boost::python::args( "pid" ), "Stop process debugging") ); + python::def( "detachAllProcesses", &detachAllProcesses, + "Detach from all process and resume all their threads" ); python::def( "killProcess", &terminateProcess, "Stop debugging and terminate current process" ); + python::def( "killAllProcesses", &terminateAllProcesses, + "Detach from all process then terminate them"); python::def( "loadDump", &loadDump, "Load crash dump"); python::def( "isDumpAnalyzing", &isDumpAnalyzing, diff --git a/pykd/win/dbgps.cpp b/pykd/win/dbgps.cpp index 745ebed..2644aad 100644 --- a/pykd/win/dbgps.cpp +++ b/pykd/win/dbgps.cpp @@ -166,7 +166,39 @@ void terminateProcess( ULONG processId ) hres = g_dbgEng->client->DetachCurrentProcess(); if ( FAILED( hres ) ) - throw DbgException( "IDebugClient::DetachCurrentProcess failed" ); + throw DbgException( "IDebugClient::DetachCurrentProcess", hres ); + +} + +/////////////////////////////////////////////////////////////////////////////// + +void detachAllProcesses() +{ + PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); + + HRESULT hres; + + hres = g_dbgEng->client->DetachProcesses(); + + if ( FAILED(hres) ) + throw DbgException( "IDebugClient::DetachProcesses", hres ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void terminateAllProcesses() +{ + PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); + + HRESULT hres; + + hres = g_dbgEng->client->TerminateProcesses(); + if ( FAILED(hres) ) + throw DbgException( "IDebugClient::TerminateProcesses", hres ); + + hres = g_dbgEng->client->DetachProcesses(); + if ( FAILED(hres) ) + throw DbgException( "IDebugClient::DetachProcesses", hres ); }