diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index 36fb439..e75644a 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -513,10 +513,11 @@ BOOST_PYTHON_MODULE( pykd ) .def( "bitOffset", &TypeInfo::getBitOffset ) .def( "bitWidth", &TypeInfo::getBitWidth ) .def( "field", &TypeInfo::getField ) - .def( "__getattr__", &TypeInfo::getField ) .def( "asMap", &TypeInfo::asMap ) - .def( "deref", &TypeInfo::deref ); - + .def( "deref", &TypeInfo::deref ) + .def( "__str__", &TypeInfo::print ) + .def( "__getattr__", &TypeInfo::getField ); + python::class_, boost::noncopyable >("typedVar", "Class of non-primitive type object, child class of typeClass. Data from target is copied into object instance", python::no_init ) diff --git a/pykd/typeinfo.h b/pykd/typeinfo.h index d4cc505..a1e10b4 100644 --- a/pykd/typeinfo.h +++ b/pykd/typeinfo.h @@ -35,6 +35,13 @@ public: public: + virtual std::string print() { + std::stringstream sstr; + sstr << "Type name: " << getName(); + sstr << " Size: 0x" << std::hex << getSize() << " (" << std::dec << getSize() << ")"; + return sstr.str(); + } + virtual std::string getName() = 0; virtual ULONG getSize() = 0; diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index c74f741..f3472be 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -147,3 +147,25 @@ class TypeInfoTest( unittest.TestCase ): ti = target.module.type("StructWithNested::Nested") self.assertTrue( hasattr( ti, "m_nestedFiled" ) ) + + def testPrint(self): + self.assertTrue( str(target.module.type( "g_ucharValue" ) ) ) + self.assertTrue( str(target.module.type( "g_ushortValue" ) ) ) + self.assertTrue( str(target.module.type( "g_ulongValue" ) ) ) + self.assertTrue( str(target.module.type( "g_ulonglongValue" ) ) ) + self.assertTrue( str(target.module.type( "g_structWithBits" ) ) ) + self.assertTrue( str(target.module.type( "g_structTest" ) ) ) + self.assertTrue( str(target.module.type( "g_structTest1" ) ) ) + self.assertTrue( str(target.module.type( "g_testArray" ) ) ) + self.assertTrue( str(target.module.type( "g_structTestPtr" ) ) ) + self.assertTrue( str(target.module.type( "g_structTestPtrPtr" ) ) ) + self.assertTrue( str(target.module.type( "longlongArray" ) ) ) + self.assertTrue( str(target.module.type( "intMatrix4" ) ) ) + self.assertTrue( str(target.module.type( "ptrIntMatrix" ) ) ) + self.assertTrue( str(target.module.type( "g_classChild" ) ) ) + self.assertTrue( str(target.module.type( "g_struct3" ) ) ) + self.assertTrue( str(target.module.type( "g_listHead" ) ) ) + self.assertTrue( str(target.module.type( "g_voidPtr" ) ) ) + self.assertTrue( str(target.module.type( "g_arrOfPtrToFunc" ) ) ) + self.assertTrue( str(target.module.type( "g_unTypedPtrToFunction" ) ) ) +