+ getNumberProcessors()
 + getPageSize() 

git-svn-id: https://pykd.svn.codeplex.com/svn@72721 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2011-12-27 21:58:41 +00:00 committed by Mikhail I. Izmestev
parent fd6ed0769e
commit 251a01d7e8
3 changed files with 53 additions and 4 deletions

View File

@ -30,6 +30,23 @@ typedef boost::shared_ptr<DebugClient> DebugClientPtr;
class DebugClient : private DbgObject {
private:
// simple IDebugControl4 call wrapper
template <typename T>
T getDbgControlT(
HRESULT (STDMETHODCALLTYPE IDebugControl4::*method)(T *),
const char *methodName
)
{
T retValue;
HRESULT hres = (m_control->*method)(&retValue);
if (S_OK != hres)
throw DbgException( buildExceptDesc(methodName, hres) );
return retValue;
}
#define getDbgControl(method) \
getDbgControlT( &IDebugControl4::##method, "IDebugControl4::" #method )
public:
virtual ~DebugClient() {}
@ -208,6 +225,13 @@ public:
void waitForEvent();
ULONG getNumberProcessors() {
return getDbgControl(GetNumberProcessors);
}
ULONG getPageSize() {
return getDbgControl(GetPageSize);
}
public:
@ -266,7 +290,6 @@ public:
}
private:
template<typename T>
python::list
loadArray( ULONG64 offset, ULONG count, bool phyAddr );
@ -356,6 +379,16 @@ inline ULONG delSyntheticSymbolsMask(
/////////////////////////////////////////////////////////////////////////////////
inline ULONG getNumberProcessors() {
return g_dbgClient->getNumberProcessors();
}
inline ULONG getPageSize() {
return g_dbgClient->getPageSize();
}
/////////////////////////////////////////////////////////////////////////////////
template<ULONG status>
void DebugClient::changeDebuggerStatus()
{

View File

@ -279,6 +279,10 @@ BOOST_PYTHON_MODULE( pykd )
"Wait for events that breaks into the debugger" )
.def( "wrmsr", &DebugClient::setMSR,
"Set MSR value" )
.def( "getNumberProcessors", &DebugClient::getNumberProcessors,
"Get the number of actual processors in the machine" )
.def( "getPageSize", &DebugClient::getPageSize,
"Get the page size for the currently executing processor context" )
.def( "addSynSymbol", &DebugClient::addSyntheticSymbol,
"Add new synthetic symbol for virtual address" )
.def( "delAllSynSymbols", &DebugClient::delAllSyntheticSymbols,
@ -446,7 +450,11 @@ BOOST_PYTHON_MODULE( pykd )
"Change debugger status to DEBUG_STATUS_STEP_INTO" );
python::def( "waitForEvent", &waitForEvent,
"Wait for events that breaks into the debugger" );
python::def( "getNumberProcessors", &getNumberProcessors,
"Get the number of actual processors in the machine" );
python::def( "getPageSize", &getPageSize,
"Get the page size for the currently executing processor context" );
python::class_<TypeInfo, TypeInfoPtr, python::bases<intBase>, boost::noncopyable >("typeInfo", "Class representing typeInfo", python::no_init )
.def( "name", &TypeInfo::getName )
.def( "size", &TypeInfo::getSize )

View File

@ -9,10 +9,18 @@ class DbgClientTest( unittest.TestCase ):
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 testNumberProcessors( self ):
"""Number of processors mus be >= 0"""
self.assertNotEqual( 0, pykd.getNumberProcessors() )
def testPageSize( self ):
"""Size of memory page mus be >= 4kb"""
self.assertTrue( pykd.getPageSize() >= 4*1024 )
def testIsDumpAnalyzing( self ):
self.assertFalse( pykd.isDumpAnalyzing() )