[0.1.x] added : getProcessorMode routine

[0.1.x] added : getProcessorType routine


git-svn-id: https://pykd.svn.codeplex.com/svn@72357 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-12-15 06:28:13 +00:00 committed by Mikhail I. Izmestev
parent e44a8c41f1
commit 8b43bd9e8e
5 changed files with 80 additions and 6 deletions

View File

@ -97,6 +97,10 @@ public:
std::string getPdbFile( ULONG64 moduleBase ); std::string getPdbFile( ULONG64 moduleBase );
std::string getProcessorMode();
std::string getProcessorType();
template<ULONG status> template<ULONG status>
void changeDebuggerStatus(); void changeDebuggerStatus();

View File

@ -166,6 +166,10 @@ BOOST_PYTHON_MODULE( pykd )
"Return traget virtual address for specified symbol" ) "Return traget virtual address for specified symbol" )
.def( "getPdbFile", &DebugClient::getPdbFile, .def( "getPdbFile", &DebugClient::getPdbFile,
"Return full path to PDB (Program DataBase, debug information) file" ) "Return full path to PDB (Program DataBase, debug information) file" )
.def( "getProcessorMode", &DebugClient::getProcessorMode,
"Return current processor mode as string: X86, ARM, IA64 or X64" )
.def( "getProcessorType", &DebugClient::getProcessorType,
"Return type of physical processor: X86, ARM, IA64 or X64" )
.def( "go", &DebugClient::changeDebuggerStatus<DEBUG_STATUS_GO>, .def( "go", &DebugClient::changeDebuggerStatus<DEBUG_STATUS_GO>,
"Change debugger status to DEBUG_STATUS_GO" ) "Change debugger status to DEBUG_STATUS_GO" )
.def( "is64bitSystem", &DebugClient::is64bitSystem, .def( "is64bitSystem", &DebugClient::is64bitSystem,
@ -293,6 +297,10 @@ BOOST_PYTHON_MODULE( pykd )
"Return full path to PDB (Program DataBase, debug information) file" ); "Return full path to PDB (Program DataBase, debug information) file" );
python::def( "go", &changeDebuggerStatus<DEBUG_STATUS_GO>, python::def( "go", &changeDebuggerStatus<DEBUG_STATUS_GO>,
"Change debugger status to DEBUG_STATUS_GO" ); "Change debugger status to DEBUG_STATUS_GO" );
python::def( "getProcessorMode", &getProcessorMode,
"Return current processor mode as string: X86, ARM, IA64 or X64" );
python::def( "getProcessorType", &getProcessorType,
"Return type of physical processor: X86, ARM, IA64 or X64" );
python::def( "is64bitSystem", &is64bitSystem, python::def( "is64bitSystem", &is64bitSystem,
"Check if target system has 64 address space" ); "Check if target system has 64 address space" );
python::def( "isDumpAnalyzing", &isDumpAnalyzing, python::def( "isDumpAnalyzing", &isDumpAnalyzing,

View File

@ -78,4 +78,64 @@ getCurrentStack()
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
static std::string processorToStr(ULONG processorMode)
{
switch( processorMode )
{
case IMAGE_FILE_MACHINE_I386:
return "X86";
case IMAGE_FILE_MACHINE_ARM:
return "ARM";
case IMAGE_FILE_MACHINE_IA64:
return "IA64";
case IMAGE_FILE_MACHINE_AMD64:
return "X64";
}
throw DbgException( "Unknown CPU type" );
}
///////////////////////////////////////////////////////////////////////////////////
std::string DebugClient::getProcessorMode()
{
HRESULT hres;
ULONG processorMode;
hres = m_control->GetEffectiveProcessorType( &processorMode );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" );
return processorToStr(processorMode);
}
std::string getProcessorMode()
{
return g_dbgClient->getProcessorMode();
}
///////////////////////////////////////////////////////////////////////////////////
std::string DebugClient::getProcessorType()
{
HRESULT hres;
ULONG processorMode;
hres = m_control->GetActualProcessorType( &processorMode );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetActualProcessorType failed" );
return processorToStr(processorMode);
}
std::string getProcessorType()
{
return g_dbgClient->getProcessorType();
}
///////////////////////////////////////////////////////////////////////////////////
} }

View File

@ -10,6 +10,10 @@ ULONG64 getImplicitThread();
python::list getCurrentStack(); python::list getCurrentStack();
std::string getProcessorMode();
std::string getProcessorType();
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
} }

View File

@ -25,8 +25,6 @@ class DbgClientTest( unittest.TestCase ):
def testPdbFile( self ): def testPdbFile( self ):
self.assertNotEqual( '', target.module ) self.assertNotEqual( '', target.module )
def testProcessorMode( self ):
self.assertNotEqual( '', pykd.getProcessorMode() )
self.assertNotEqual( '', pykd.getProcessorType() )