From 0a9c658da62f3ac3ebac7fddc53ed5fc0aa57400 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Thu, 27 Dec 2012 09:35:16 +0000 Subject: [PATCH] [0.2.x] added: typeInfo::arrayOf method ( contruct array type ) git-svn-id: https://pykd.svn.codeplex.com/svn@82052 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/pykdver.h | 2 +- pykd/python/pymod.cpp | 1 + pykd/typeinfo.cpp | 7 +++++++ pykd/typeinfo.h | 2 ++ pykd/win/dbgeng.cpp | 6 +++--- test/scripts/typedvar.py | 11 +++++++++++ test/scripts/typeinfo.py | 7 +++++++ 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/pykd/pykdver.h b/pykd/pykdver.h index 14e1e2d..262c7fe 100644 --- a/pykd/pykdver.h +++ b/pykd/pykdver.h @@ -2,7 +2,7 @@ #define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MINOR 2 #define PYKD_VERSION_SUBVERSION 0 -#define PYKD_VERSION_BUILDNO 10 +#define PYKD_VERSION_BUILDNO 11 #define __VER_STR2__(x) #x diff --git a/pykd/python/pymod.cpp b/pykd/python/pymod.cpp index d62794a..fc33949 100644 --- a/pykd/python/pymod.cpp +++ b/pykd/python/pymod.cpp @@ -410,6 +410,7 @@ BOOST_PYTHON_MODULE( pykd ) .def( "deref", &TypeInfo::deref ) .def( "append", &TypeInfo::appendField ) .def( "ptrTo", &TypeInfo::ptrTo ) + .def( "arrayOf", &TypeInfo::arrayOf ) .def( "__str__", &TypeInfo::print ) .def( "__getattr__", &TypeInfo::getField ) .def("__len__", &TypeInfo::getElementCount ) diff --git a/pykd/typeinfo.cpp b/pykd/typeinfo.cpp index 48ad70b..370e617 100644 --- a/pykd/typeinfo.cpp +++ b/pykd/typeinfo.cpp @@ -609,6 +609,13 @@ TypeInfoPtr TypeInfo::ptrTo() ///////////////////////////////////////////////////////////////////////////////////// +TypeInfoPtr TypeInfo::arrayOf( ULONG count ) +{ + return TypeInfoPtr( new ArrayTypeInfo(shared_from_this(), count ) ); +} + +///////////////////////////////////////////////////////////////////////////////////// + std::string UdtTypeInfoBase::print() { std::stringstream sstr; diff --git a/pykd/typeinfo.h b/pykd/typeinfo.h index 3678ab5..6888212 100644 --- a/pykd/typeinfo.h +++ b/pykd/typeinfo.h @@ -201,6 +201,8 @@ public: TypeInfoPtr ptrTo(); + TypeInfoPtr arrayOf( ULONG count ); + virtual ULONG getAlignReq() { return 1; } diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index f3f6d67..580a948 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -482,10 +482,10 @@ std::string getModuleSymbolFileName( ULONG64 baseOffset ) if (!*moduleInfo.LoadedPdbName) { - std::wstring param = L"/f "; - param += moduleInfo.ImageName; + std::wstringstream sstr; + sstr << L"/f \"" << moduleInfo.ImageName << L"\""; - hres = g_dbgEng->symbols->ReloadWide( param.c_str() ); + hres = g_dbgEng->symbols->ReloadWide( sstr.str().c_str() ); if ( FAILED( hres ) ) throw DbgException("IDebugSymbols::Reload failed" ); diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index 408d7dd..7695c7f 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -46,6 +46,17 @@ class TypedVarTest( unittest.TestCase ): customStructTest.append("m_field1", pykd.typeInfo("UInt8B")) tvCustomStruct = pykd.typedVar( customStructTest.ptrTo(), target.module.offset("g_structTestPtr") ) self.assertEqual( 500, tvCustomStruct.deref().m_field1 ) + + def testArrayOf(self): + arrayType = pykd.typeInfo("UInt8B").arrayOf(5) + arrayVar = pykd.typedVar( arrayType, target.module.offset("ulonglongArray") ) + self.assertEqual( 0xFF, arrayVar[1] ) + self.assertEqual( 0xFFFFFFFFFFFFFFFF, arrayVar[4] ) + + arrayStructType = pykd.typeInfo("structTest").arrayOf(2) + arrayStructVar = pykd.typedVar( arrayStructType, target.module.offset("g_testArray") ) + self.assertEqual( True, arrayStructVar[0].m_field2 ) + self.assertEqual( 1, arrayStructVar[1].m_field3 ) def testConst(self): self.assertEqual( True, target.module.typedVar( "g_constBoolValue" ) ) diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index b3da326..7c9d8a1 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -221,4 +221,11 @@ class TypeInfoTest( unittest.TestCase ): entry = pykd.typedVar("entry1").Flink self.assertEqual( "_LIST_ENTRY*", entry.type().name() ) + def testPtrTo(self): + ti = pykd.typeInfo("UInt8B").ptrTo() + self.assertTrue( "UInt8B*", ti.name() ) + + def testArrayOf(self): + ti = pykd.typeInfo("UInt8B").arrayOf(10) + self.assertTrue( "UInt8B[10]", ti.name() )