From 14e20d47f2686bb5d03fad8736e4d9122db3a703 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Thu, 10 Jan 2013 06:34:58 +0000 Subject: [PATCH] [0.2.x] added: method deref() may be skip ( struct.field1.deref().field2 -> struct.field1.field2 ) git-svn-id: https://pykd.svn.codeplex.com/svn@82220 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/typedvar.cpp | 8 ++++++++ pykd/typedvar.h | 2 ++ test/scripts/typedvar.py | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pykd/typedvar.cpp b/pykd/typedvar.cpp index 184ebbb..4275574 100644 --- a/pykd/typedvar.cpp +++ b/pykd/typedvar.cpp @@ -199,6 +199,14 @@ TypedVarPtr PtrTypedVar::deref() /////////////////////////////////////////////////////////////////////////////////// +TypedVarPtr PtrTypedVar::getField( const std::string &fieldName ) +{ + TypedVarPtr derefPtr = deref(); + return derefPtr->getField( fieldName ); +} + +/////////////////////////////////////////////////////////////////////////////////// + std::string PtrTypedVar::print() { std::stringstream sstr; diff --git a/pykd/typedvar.h b/pykd/typedvar.h index 880d93a..f429aff 100644 --- a/pykd/typedvar.h +++ b/pykd/typedvar.h @@ -134,6 +134,8 @@ public: virtual BaseTypeVariant getValue(); + virtual TypedVarPtr getField( const std::string &fieldName ); + }; /////////////////////////////////////////////////////////////////////////////////// diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index 7695c7f..6b0db3f 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -219,6 +219,10 @@ class TypedVarTest( unittest.TestCase ): self.assertTrue(False) except pykd.BaseException: pass + + def testSkipDeref(self): + tv = target.module.typedVar( "g_structTest1" ) + self.assertEqual( tv.m_field4.deref().m_field1, tv.m_field4.m_field1 ) def testUnNamedStruct(self): tv = target.module.typedVar( "g_unNamedStruct" ) @@ -267,7 +271,7 @@ class TypedVarTest( unittest.TestCase ): self.assertTrue( str(target.module.typedVar( "g_unTypedPtrToFunction" ) ) ) def testNotValidPrint(self): - types = ("structTest", ) #, "ULong[100]", "Ulong*" ) + types = ("structTest", "ULong[100]", "ULong*" ) for ti in types: self.assertTrue( str(pykd.typedVar( target.module.type(ti), 0 ) ) )