[0.2.x] added : startProcess routine extra parameter debugChildren

[0.2.x] fixed : killProcess correctly detaching from target now

git-svn-id: https://pykd.svn.codeplex.com/svn@86120 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2013-10-31 08:10:01 +00:00 committed by Mikhail I. Izmestev
parent 0b80b37258
commit 976e43a31a
6 changed files with 18 additions and 10 deletions

View File

@ -6,7 +6,7 @@
namespace pykd { namespace pykd {
// manage debug target // manage debug target
ULONG startProcess( const std::wstring &processName ); ULONG startProcess( const std::wstring &processName, bool debugChildren = false );
ULONG attachProcess( ULONG pid ); ULONG attachProcess( ULONG pid );
void attachKernel( const std::string &connectOptions = "" ); void attachKernel( const std::string &connectOptions = "" );
bool isLocalKernelDebuggerEnabled(); bool isLocalKernelDebuggerEnabled();

View File

@ -2,7 +2,7 @@
#define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MAJOR 0
#define PYKD_VERSION_MINOR 2 #define PYKD_VERSION_MINOR 2
#define PYKD_VERSION_SUBVERSION 0 #define PYKD_VERSION_SUBVERSION 0
#define PYKD_VERSION_BUILDNO 25 #define PYKD_VERSION_BUILDNO 26
#define __VER_STR2__(x) #x #define __VER_STR2__(x) #x

View File

@ -38,6 +38,7 @@ static const std::string pykdVersion = PYKD_VERSION_BUILD_STR
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
BOOST_PYTHON_FUNCTION_OVERLOADS( startProcess_, startProcess, 1, 2 );
BOOST_PYTHON_FUNCTION_OVERLOADS( attachKernel_, attachKernel, 0, 1 ); BOOST_PYTHON_FUNCTION_OVERLOADS( attachKernel_, attachKernel, 0, 1 );
BOOST_PYTHON_FUNCTION_OVERLOADS( detachProcess_, detachProcess, 0, 1 ); BOOST_PYTHON_FUNCTION_OVERLOADS( detachProcess_, detachProcess, 0, 1 );
@ -90,8 +91,8 @@ BOOST_PYTHON_MODULE( pykd )
// Manage debug target // Manage debug target
python::def( "startProcess", &startProcess, python::def( "startProcess", &startProcess, startProcess_( boost::python::args( "commandline", "debugChildren" ),
"Start process for debugging" ); "Start process for debugging" ) );
python::def( "attachProcess", &attachProcess, python::def( "attachProcess", &attachProcess,
"Attach debugger to a exsisting process" ); "Attach debugger to a exsisting process" );
python::def( "attachKernel", &attachKernel, attachKernel_( boost::python::args( "connectOptions" ), python::def( "attachKernel", &attachKernel, attachKernel_( boost::python::args( "connectOptions" ),

View File

@ -13,7 +13,7 @@ namespace pykd {
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
ULONG startProcess( const std::wstring &processName ) ULONG startProcess( const std::wstring &processName, bool debugChildren )
{ {
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
@ -32,7 +32,12 @@ ULONG startProcess( const std::wstring &processName )
std::vector< std::wstring::value_type > cmdLine( processName.size() + 1 ); std::vector< std::wstring::value_type > cmdLine( processName.size() + 1 );
wcscpy_s( &cmdLine[0], cmdLine.size(), processName.c_str() ); wcscpy_s( &cmdLine[0], cmdLine.size(), processName.c_str() );
hres = g_dbgEng->client->CreateProcessWide( 0, &cmdLine[0], DEBUG_PROCESS | DETACHED_PROCESS ); hres = g_dbgEng->client->CreateProcessWide(
0,
&cmdLine[0],
( debugChildren ? DEBUG_PROCESS : DEBUG_ONLY_THIS_PROCESS) | DETACHED_PROCESS
);
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugClient4::CreateProcessWide failed" ); throw DbgException( "IDebugClient4::CreateProcessWide failed" );
@ -159,6 +164,10 @@ void terminateProcess( ULONG processId )
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugClient::TerminateCurrentProcess", hres ); throw DbgException( "IDebugClient::TerminateCurrentProcess", hres );
hres = g_dbgEng->client->DetachCurrentProcess();
if ( FAILED( hres ) )
throw DbgException( "IDebugClient::DetachCurrentProcess failed" );
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -7,7 +7,7 @@ class PykdMagic (Magics):
@line_magic @line_magic
def kd(self,line): def kd(self,line):
"any windbg command" "magic for calling any windbg command"
try: try:
pykd.dprintln( pykd.dbgCommand(line) ) pykd.dprintln( pykd.dbgCommand(line) )
except pykd.BaseException: except pykd.BaseException:
@ -20,4 +20,3 @@ def load_ipython_extension(ipython):
def unload_ipython_extension(ipython): def unload_ipython_extension(ipython):
pass pass

View File

@ -37,7 +37,6 @@ class StartProcessWithoutParamsTest(unittest.TestCase):
class TerminateProcessTest(unittest.TestCase): class TerminateProcessTest(unittest.TestCase):
def testKill(self): def testKill(self):
pykd.killProcess( target.processId ) pykd.killProcess( target.processId )
pykd.detachProcess( target.processId )
def getTestSuite( singleName = "" ): def getTestSuite( singleName = "" ):
if singleName == "": if singleName == "":