mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 20:03:33 +08:00
[0.1.x] added : getDebuggeeType routine ( Return type of the debuggee )
git-svn-id: https://pykd.svn.codeplex.com/svn@70309 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
bcbe5e7c96
commit
db85aad76a
@ -10,25 +10,6 @@ namespace pykd {
|
|||||||
|
|
||||||
DebugClientPtr g_dbgClient( DebugClient::createDbgClient() );
|
DebugClientPtr g_dbgClient( DebugClient::createDbgClient() );
|
||||||
|
|
||||||
void loadDump( const std::wstring &fileName ) {
|
|
||||||
g_dbgClient->loadDump( fileName );
|
|
||||||
}
|
|
||||||
|
|
||||||
void startProcess( const std::wstring &processName ) {
|
|
||||||
g_dbgClient->startProcess( processName );
|
|
||||||
}
|
|
||||||
|
|
||||||
void attachProcess( ULONG processId ) {
|
|
||||||
g_dbgClient->attachProcess( processId );
|
|
||||||
}
|
|
||||||
|
|
||||||
void attachKernel( const std::wstring ¶m ) {
|
|
||||||
g_dbgClient->attachKernel( param );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
DebugClientPtr DebugClient::setDbgClientCurrent( DebugClientPtr newDbgClient ) {
|
DebugClientPtr DebugClient::setDbgClientCurrent( DebugClientPtr newDbgClient ) {
|
||||||
DebugClientPtr oldClient = g_dbgClient;
|
DebugClientPtr oldClient = g_dbgClient;
|
||||||
g_dbgClient = newDbgClient;
|
g_dbgClient = newDbgClient;
|
||||||
@ -37,6 +18,66 @@ DebugClientPtr DebugClient::setDbgClientCurrent( DebugClientPtr newDbgClient )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
python::tuple DebugClient::getDebuggeeType()
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG debugClass, debugQualifier;
|
||||||
|
|
||||||
|
hres = m_control->GetDebuggeeType( &debugClass, &debugQualifier );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
|
||||||
|
|
||||||
|
return python::make_tuple( debugClass, debugQualifier );
|
||||||
|
}
|
||||||
|
|
||||||
|
python::tuple getDebuggeeType()
|
||||||
|
{
|
||||||
|
return g_dbgClient->getDebuggeeType();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool DebugClient::isDumpAnalyzing()
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG debugClass, debugQualifier;
|
||||||
|
|
||||||
|
hres = m_control->GetDebuggeeType( &debugClass, &debugQualifier );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
|
||||||
|
|
||||||
|
return debugQualifier >= DEBUG_DUMP_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isDumpAnalyzing()
|
||||||
|
{
|
||||||
|
return g_dbgClient->isDumpAnalyzing();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool DebugClient::isKernelDebugging()
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG debugClass, debugQualifier;
|
||||||
|
|
||||||
|
hres = m_control->GetDebuggeeType( &debugClass, &debugQualifier );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
|
||||||
|
|
||||||
|
return debugClass == DEBUG_CLASS_KERNEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isKernelDebugging()
|
||||||
|
{
|
||||||
|
return g_dbgClient->isKernelDebugging();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DebugClient::loadDump( const std::wstring &fileName )
|
void DebugClient::loadDump( const std::wstring &fileName )
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
@ -51,6 +92,10 @@ void DebugClient::loadDump( const std::wstring &fileName )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadDump( const std::wstring &fileName ) {
|
||||||
|
g_dbgClient->loadDump( fileName );
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DebugClient::startProcess( const std::wstring &processName )
|
void DebugClient::startProcess( const std::wstring &processName )
|
||||||
@ -79,6 +124,10 @@ void DebugClient::startProcess( const std::wstring &processName )
|
|||||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startProcess( const std::wstring &processName ) {
|
||||||
|
g_dbgClient->startProcess( processName );
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DebugClient::attachProcess( ULONG processId )
|
void DebugClient::attachProcess( ULONG processId )
|
||||||
@ -90,6 +139,10 @@ void DebugClient::attachProcess( ULONG processId )
|
|||||||
throw DbgException( "IDebugClient::AttachProcess failed" );
|
throw DbgException( "IDebugClient::AttachProcess failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void attachProcess( ULONG processId ) {
|
||||||
|
g_dbgClient->attachProcess( processId );
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DebugClient::attachKernel( const std::wstring ¶m )
|
void DebugClient::attachKernel( const std::wstring ¶m )
|
||||||
@ -101,6 +154,11 @@ void DebugClient::attachKernel( const std::wstring ¶m )
|
|||||||
throw DbgException( "IDebugClient5::AttachKernelWide failed" );
|
throw DbgException( "IDebugClient5::AttachKernelWide failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void attachKernel( const std::wstring ¶m ) {
|
||||||
|
g_dbgClient->attachKernel( param );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}; // end of namespace pykd
|
}; // end of namespace pykd
|
@ -64,6 +64,12 @@ public:
|
|||||||
|
|
||||||
ULONG64 evaluate( const std::wstring &expression );
|
ULONG64 evaluate( const std::wstring &expression );
|
||||||
|
|
||||||
|
python::tuple getDebuggeeType();
|
||||||
|
|
||||||
|
bool isKernelDebugging();
|
||||||
|
|
||||||
|
bool isDumpAnalyzing();
|
||||||
|
|
||||||
Module loadModule( const std::string &moduleName ) {
|
Module loadModule( const std::string &moduleName ) {
|
||||||
return Module( m_client, moduleName );
|
return Module( m_client, moduleName );
|
||||||
}
|
}
|
||||||
@ -128,9 +134,11 @@ void attachProcess( ULONG processId );
|
|||||||
|
|
||||||
void attachKernel( const std::wstring ¶m );
|
void attachKernel( const std::wstring ¶m );
|
||||||
|
|
||||||
Module loadModule( const std::string &moduleName );
|
python::tuple getDebuggeeType();
|
||||||
|
|
||||||
Module findModule( ULONG64 offset );
|
bool isKernelDebugging();
|
||||||
|
|
||||||
|
bool isDumpAnalyzing();
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -67,6 +67,12 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Attach debugger to a target's kernel" )
|
"Attach debugger to a target's kernel" )
|
||||||
.def( "expr", &pykd::DebugClient::evaluate,
|
.def( "expr", &pykd::DebugClient::evaluate,
|
||||||
"Evaluate windbg expression" )
|
"Evaluate windbg expression" )
|
||||||
|
.def( "getDebuggeeType", &pykd::DebugClient::getDebuggeeType,
|
||||||
|
"Return type of the debuggee" )
|
||||||
|
.def( "isDumpAnalyzing", &pykd::DebugClient::isDumpAnalyzing,
|
||||||
|
"Check if it is a dump analyzing ( not living debuggee )" )
|
||||||
|
.def( "isKernelDebugging", &pykd::DebugClient::isKernelDebugging,
|
||||||
|
"Check if kernel dubugging is running" )
|
||||||
.def ( "loadExt", &pykd::DebugClient::loadExtension,
|
.def ( "loadExt", &pykd::DebugClient::loadExtension,
|
||||||
"Load a debuger extension" )
|
"Load a debuger extension" )
|
||||||
.def( "loadModule", &pykd::DebugClient::loadModule,
|
.def( "loadModule", &pykd::DebugClient::loadModule,
|
||||||
@ -92,6 +98,12 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Attach debugger to a kernel target" );
|
"Attach debugger to a kernel target" );
|
||||||
python::def( "expr", &pykd::evaluate,
|
python::def( "expr", &pykd::evaluate,
|
||||||
"Evaluate windbg expression" );
|
"Evaluate windbg expression" );
|
||||||
|
python::def( "getDebuggeeType", &pykd::getDebuggeeType,
|
||||||
|
"Return type of the debuggee" );
|
||||||
|
python::def( "isDumpAnalyzing", &pykd::isDumpAnalyzing,
|
||||||
|
"Check if it is a dump analyzing ( not living debuggee )" );
|
||||||
|
python::def( "isKernelDebugging", &pykd::isKernelDebugging,
|
||||||
|
"Check if kernel dubugging is running" );
|
||||||
python::def( "loadExt", &pykd::loadExtension,
|
python::def( "loadExt", &pykd::loadExtension,
|
||||||
"Load a debuger extension" );
|
"Load a debuger extension" );
|
||||||
python::def( "loadModule", &pykd::loadModule,
|
python::def( "loadModule", &pykd::loadModule,
|
||||||
@ -327,6 +339,22 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
pyDia::Exception::setTypeObject( diaException.ptr() );
|
pyDia::Exception::setTypeObject( diaException.ptr() );
|
||||||
boost::python::register_exception_translator<pyDia::Exception>(
|
boost::python::register_exception_translator<pyDia::Exception>(
|
||||||
&pyDia::Exception::exceptionTranslate );
|
&pyDia::Exception::exceptionTranslate );
|
||||||
|
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_CLASS_UNINITIALIZED );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_CLASS_KERNEL );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_CLASS_USER_WINDOWS );
|
||||||
|
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_KERNEL_CONNECTION );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_KERNEL_LOCAL );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_KERNEL_EXDI_DRIVER );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_KERNEL_SMALL_DUMP );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_KERNEL_DUMP );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_KERNEL_FULL_DUMP );
|
||||||
|
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_USER_WINDOWS_PROCESS );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_USER_WINDOWS_PROCESS_SERVER );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_USER_WINDOWS_SMALL_DUMP );
|
||||||
|
DEF_PY_CONST_ULONG( DEBUG_USER_WINDOWS_DUMP );
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DEF_PY_CONST_ULONG
|
#undef DEF_PY_CONST_ULONG
|
||||||
|
@ -81,7 +81,13 @@ private:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
};
|
Module loadModule( const std::string &moduleName );
|
||||||
|
|
||||||
|
Module findModule( ULONG64 offset );
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}; // end pykd namespace
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@ class BaseTest( unittest.TestCase ):
|
|||||||
""" Branch test: new API 0.1.x what must be available """
|
""" Branch test: new API 0.1.x what must be available """
|
||||||
self.assertTrue( hasattr(pykd, 'createDbgClient') )
|
self.assertTrue( hasattr(pykd, 'createDbgClient') )
|
||||||
self.assertTrue( hasattr(pykd, 'diaLoadPdb') )
|
self.assertTrue( hasattr(pykd, 'diaLoadPdb') )
|
||||||
|
self.assertTrue( hasattr(pykd, 'getDebuggeeType' ) )
|
||||||
self.assertTrue( hasattr(pykd, 'loadExt') )
|
self.assertTrue( hasattr(pykd, 'loadExt') )
|
||||||
|
|
||||||
self.assertTrue( hasattr(pykd, 'DiaException') )
|
self.assertTrue( hasattr(pykd, 'DiaException') )
|
||||||
|
18
test/scripts/clienttest.py
Normal file
18
test/scripts/clienttest.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import unittest
|
||||||
|
import target
|
||||||
|
import pykd
|
||||||
|
|
||||||
|
class DbgClientTest( unittest.TestCase ):
|
||||||
|
|
||||||
|
def testGetDebuggeeType( self ):
|
||||||
|
c, q = pykd.getDebuggeeType()
|
||||||
|
self.assertEqual( c, pykd.DEBUG_CLASS_USER_WINDOWS )
|
||||||
|
self.assertEqual( q, pykd.DEBUG_USER_WINDOWS_PROCESS )
|
||||||
|
|
||||||
|
def testIsKernelDebugging( self ):
|
||||||
|
self.assertFalse( pykd.isKernelDebugging() )
|
||||||
|
|
||||||
|
def testIsDumpAnalyzing( self ):
|
||||||
|
self.assertFalse( pykd.isDumpAnalyzing() )
|
||||||
|
|
@ -17,6 +17,7 @@ import regtest
|
|||||||
import moduletest
|
import moduletest
|
||||||
import diatest
|
import diatest
|
||||||
import dbgcmd
|
import dbgcmd
|
||||||
|
import clienttest
|
||||||
|
|
||||||
def getTestSuite( singleName = "" ):
|
def getTestSuite( singleName = "" ):
|
||||||
if singleName == "":
|
if singleName == "":
|
||||||
@ -25,7 +26,8 @@ def getTestSuite( singleName = "" ):
|
|||||||
unittest.TestLoader().loadTestsFromTestCase( moduletest.ModuleTest ),
|
unittest.TestLoader().loadTestsFromTestCase( moduletest.ModuleTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( diatest.DiaTest ),
|
unittest.TestLoader().loadTestsFromTestCase( diatest.DiaTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( typeinfo.TypeInfoTest ),
|
unittest.TestLoader().loadTestsFromTestCase( typeinfo.TypeInfoTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( dbgcmd.DbgcmdTest )
|
unittest.TestLoader().loadTestsFromTestCase( dbgcmd.DbgcmdTest ),
|
||||||
|
unittest.TestLoader().loadTestsFromTestCase( clienttest.DbgClientTest )
|
||||||
] )
|
] )
|
||||||
else:
|
else:
|
||||||
return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
||||||
|
@ -404,6 +404,10 @@
|
|||||||
RelativePath="..\scripts\basetest.py"
|
RelativePath="..\scripts\basetest.py"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\scripts\clienttest.py"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\scripts\dbgcmd.py"
|
RelativePath="..\scripts\dbgcmd.py"
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user