mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 20:03:33 +08:00
[0.1.x] added : typeInfo.size()
git-svn-id: https://pykd.svn.codeplex.com/svn@70223 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
0d7d746778
commit
a8ff8e9f84
@ -68,7 +68,6 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.def( "dprintln", &pykd::DebugClient::dprintln,
|
.def( "dprintln", &pykd::DebugClient::dprintln,
|
||||||
"Print out string and insert end of line symbol. If dml = True string is printed with dml highlighting ( only for windbg )" );
|
"Print out string and insert end of line symbol. If dml = True string is printed with dml highlighting ( only for windbg )" );
|
||||||
|
|
||||||
|
|
||||||
// python::def( "createDbgClient", pykd::DebugClient::createDbgClient,
|
// python::def( "createDbgClient", pykd::DebugClient::createDbgClient,
|
||||||
// "create a new instance of the dbgClient class" );
|
// "create a new instance of the dbgClient class" );
|
||||||
python::def( "loadDump", &pykd::loadDump,
|
python::def( "loadDump", &pykd::loadDump,
|
||||||
@ -90,7 +89,9 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
|
|
||||||
python::class_<pykd::TypeInfo>("typeInfo", "Class representing typeInfo", python::no_init )
|
python::class_<pykd::TypeInfo>("typeInfo", "Class representing typeInfo", python::no_init )
|
||||||
.def( "name", &pykd::TypeInfo::getName )
|
.def( "name", &pykd::TypeInfo::getName )
|
||||||
|
.def( "size", &pykd::TypeInfo::getSize )
|
||||||
.def( "offset", &pykd::TypeInfo::getOffset )
|
.def( "offset", &pykd::TypeInfo::getOffset )
|
||||||
|
.def( "field", &pykd::TypeInfo::getField )
|
||||||
.def( "__getattr__", &pykd::TypeInfo::getField );
|
.def( "__getattr__", &pykd::TypeInfo::getField );
|
||||||
|
|
||||||
python::class_<pykd::Module>("module", "Class representing executable module", python::no_init )
|
python::class_<pykd::Module>("module", "Class representing executable module", python::no_init )
|
||||||
@ -329,6 +330,8 @@ WindbgGlobalSession::WindbgGlobalSession() {
|
|||||||
|
|
||||||
main_namespace[ key ] = pykd_namespace[ key ];
|
main_namespace[ key ] = pykd_namespace[ key ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pyState = PyEval_SaveThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -370,6 +373,8 @@ py( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
DebugClientPtr dbgClient = DebugClient::createDbgClient( client );
|
DebugClientPtr dbgClient = DebugClient::createDbgClient( client );
|
||||||
DebugClientPtr oldClient = DebugClient::setDbgClientCurrent( dbgClient );
|
DebugClientPtr oldClient = DebugClient::setDbgClientCurrent( dbgClient );
|
||||||
|
|
||||||
|
WindbgGlobalSession::RestorePyState();
|
||||||
|
|
||||||
PyThreadState *globalInterpreter = PyThreadState_Swap( NULL );
|
PyThreadState *globalInterpreter = PyThreadState_Swap( NULL );
|
||||||
PyThreadState *localInterpreter = Py_NewInterpreter();
|
PyThreadState *localInterpreter = Py_NewInterpreter();
|
||||||
|
|
||||||
@ -385,6 +390,8 @@ py( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
Py_EndInterpreter( localInterpreter );
|
Py_EndInterpreter( localInterpreter );
|
||||||
PyThreadState_Swap( globalInterpreter );
|
PyThreadState_Swap( globalInterpreter );
|
||||||
|
|
||||||
|
WindbgGlobalSession::SavePyState();
|
||||||
|
|
||||||
DebugClient::setDbgClientCurrent( oldClient );
|
DebugClient::setDbgClientCurrent( oldClient );
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@ -399,6 +406,8 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
DebugClientPtr dbgClient = DebugClient::createDbgClient( client );
|
DebugClientPtr dbgClient = DebugClient::createDbgClient( client );
|
||||||
DebugClientPtr oldClient = DebugClient::setDbgClientCurrent( dbgClient );
|
DebugClientPtr oldClient = DebugClient::setDbgClientCurrent( dbgClient );
|
||||||
|
|
||||||
|
WindbgGlobalSession::RestorePyState();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
@ -408,9 +417,9 @@ pycmd( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
dbgClient->eprintln( "unexpected error" );
|
dbgClient->eprintln( "unexpected error" );
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugClient::setDbgClientCurrent( oldClient );
|
WindbgGlobalSession::SavePyState();
|
||||||
|
|
||||||
return S_OK;
|
DebugClient::setDbgClientCurrent( oldClient );
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,10 @@ Module::getTypeByName( const std::string typeName )
|
|||||||
{
|
{
|
||||||
pyDia::SymbolPtr typeSym = m_dia->getChildByName( typeName );
|
pyDia::SymbolPtr typeSym = m_dia->getChildByName( typeName );
|
||||||
|
|
||||||
return TypeInfo( typeSym );
|
if ( typeSym->getSymTag() == SymTagData )
|
||||||
|
return TypeInfo( typeSym->getType() );
|
||||||
|
else
|
||||||
|
return TypeInfo( typeSym );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -88,6 +88,11 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#include <string>
|
//#include <string>
|
||||||
//#include <map>
|
//#include <map>
|
||||||
//
|
//
|
||||||
|
@ -36,6 +36,11 @@ public:
|
|||||||
return m_offset;
|
return m_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ULONG64
|
||||||
|
getSize() {
|
||||||
|
return m_dia->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
pyDia::SymbolPtr m_dia;
|
pyDia::SymbolPtr m_dia;
|
||||||
|
@ -40,6 +40,18 @@ public:
|
|||||||
return windbgGlobalSession != NULL;
|
return windbgGlobalSession != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
RestorePyState() {
|
||||||
|
PyEval_RestoreThread( windbgGlobalSession->pyState );
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
SavePyState() {
|
||||||
|
windbgGlobalSession->pyState = PyEval_SaveThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -50,6 +62,8 @@ private:
|
|||||||
|
|
||||||
python::object main;
|
python::object main;
|
||||||
|
|
||||||
|
PyThreadState *pyState;
|
||||||
|
|
||||||
static volatile LONG sessionCount;
|
static volatile LONG sessionCount;
|
||||||
|
|
||||||
static WindbgGlobalSession *windbgGlobalSession;
|
static WindbgGlobalSession *windbgGlobalSession;
|
||||||
|
@ -49,3 +49,7 @@ class ModuleTest( unittest.TestCase ):
|
|||||||
def testSymbol( self ):
|
def testSymbol( self ):
|
||||||
self.assertEqual( target.module.rva("FuncWithName0"), target.module.offset("FuncWithName0") - target.module.begin() )
|
self.assertEqual( target.module.rva("FuncWithName0"), target.module.offset("FuncWithName0") - target.module.begin() )
|
||||||
self.assertEqual( target.module.rva("FuncWithName0"), target.module.FuncWithName0 - target.module.begin() )
|
self.assertEqual( target.module.rva("FuncWithName0"), target.module.FuncWithName0 - target.module.begin() )
|
||||||
|
|
||||||
|
def testType( self ):
|
||||||
|
self.assertEqual( "structTest", target.module.type("structTest").name() );
|
||||||
|
self.assertEqual( "structTest", target.module.type("g_structTest").name() );
|
||||||
|
@ -21,8 +21,8 @@ class TypeInfoTest( unittest.TestCase ):
|
|||||||
def testGetField( self ):
|
def testGetField( self ):
|
||||||
""" get field of the complex type """
|
""" get field of the complex type """
|
||||||
ti1 = target.module.type( "structTest" )
|
ti1 = target.module.type( "structTest" )
|
||||||
self.assertNotEqual( None, ti1.m_field0 ) # exsisting field
|
self.assertTrue( hasattr( ti1, "m_field0" ) )
|
||||||
try: ti1.m_field4 # non-exsisting field
|
try: hasattr(ti1, "m_field4" ) # non-exsisting field
|
||||||
except pykd.DiaException: pass
|
except pykd.DiaException: pass
|
||||||
|
|
||||||
def testName( self ):
|
def testName( self ):
|
||||||
@ -38,3 +38,7 @@ class TypeInfoTest( unittest.TestCase ):
|
|||||||
self.assertEqual( 12, ti1.m_field2.offset() )
|
self.assertEqual( 12, ti1.m_field2.offset() )
|
||||||
self.assertEqual( 14, ti1.m_field3.offset() )
|
self.assertEqual( 14, ti1.m_field3.offset() )
|
||||||
|
|
||||||
|
def testSize( self ):
|
||||||
|
ti1 = target.module.type( "structTest" )
|
||||||
|
self.assertEqual( 16, ti1.size() )
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@ struct structTest {
|
|||||||
USHORT m_field3;
|
USHORT m_field3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
structTest g_structTest = { 0, 500, true, 1 };
|
||||||
|
|
||||||
class classChild : public classBase {
|
class classChild : public classBase {
|
||||||
public:
|
public:
|
||||||
int m_childField;
|
int m_childField;
|
||||||
@ -75,6 +77,8 @@ void FuncWithName0()
|
|||||||
std::cout << g_ushortValue;
|
std::cout << g_ushortValue;
|
||||||
std::cout << g_ulongValue;
|
std::cout << g_ulongValue;
|
||||||
std::cout << g_ulonglongValue;
|
std::cout << g_ulonglongValue;
|
||||||
|
|
||||||
|
std::cout << g_structTest.m_field0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FuncWithName1(int a)
|
void FuncWithName1(int a)
|
||||||
|
Loading…
Reference in New Issue
Block a user