diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index f3a4e2f..95f1505 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -468,7 +468,8 @@ BOOST_PYTHON_MODULE( pykd ) .def( "bitOffset", &TypeInfo::getBitOffset ) .def( "bitWidth", &TypeInfo::getBitWidth ) .def( "field", &TypeInfo::getField ) - .def( "__getattr__", &TypeInfo::getField ); + .def( "__getattr__", &TypeInfo::getField ) + .def( "asMap", &TypeInfo::asMap ); python::class_, boost::noncopyable >("typedVar", "Class of non-primitive type object, child class of typeClass. Data from target is copied into object instance", diff --git a/pykd/diawrapper.cpp b/pykd/diawrapper.cpp index 976edff..51ccfc6 100644 --- a/pykd/diawrapper.cpp +++ b/pykd/diawrapper.cpp @@ -66,12 +66,26 @@ std::list< SymbolPtr > Symbol::findChildrenImpl( ) { DiaEnumSymbolsPtr symbols; - HRESULT hres = - m_symbol->findChildren( - static_cast(symTag), - toWStr(name), - nameCmpFlags, - &symbols); + HRESULT hres; + + if ( name.empty() ) + { + hres = m_symbol->findChildren( + static_cast(symTag), + NULL, + nameCmpFlags, + &symbols); + + } + else + { + hres = m_symbol->findChildren( + static_cast(symTag), + toWStr(name), + nameCmpFlags, + &symbols); + } + if (S_OK != hres) throw Exception("Call IDiaSymbol::findChildren", hres); diff --git a/pykd/pykd.rc b/pykd/pykd.rc index 750c6af..d616026 100644 --- a/pykd/pykd.rc +++ b/pykd/pykd.rc @@ -53,8 +53,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,1,0,3 - PRODUCTVERSION 0,1,0,3 + FILEVERSION 0,1,0,4 + PRODUCTVERSION 0,1,0,4 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -70,11 +70,11 @@ BEGIN BLOCK "041904b0" BEGIN VALUE "FileDescription", "pykd - python extension for windbg" - VALUE "FileVersion", "0, 1, 0, 3" + VALUE "FileVersion", "0, 1, 0, 4" VALUE "InternalName", "pykd" VALUE "OriginalFilename", "pykd.dll" VALUE "ProductName", "pykd - python extension for windbg" - VALUE "ProductVersion", "0, 1, 0, 3" + VALUE "ProductVersion", "0, 1, 0, 4" END END BLOCK "VarFileInfo" diff --git a/pykd/typeinfo.cpp b/pykd/typeinfo.cpp index 8c307a4..c0e07b9 100644 --- a/pykd/typeinfo.cpp +++ b/pykd/typeinfo.cpp @@ -388,6 +388,27 @@ TypeInfoPtr TypeInfo::getRecurciveComplexType( TypeInfoPtr &lowestType, std::str return lowestType; } +///////////////////////////////////////////////////////////////////////////////////// + +python::dict EnumTypeInfo::asMap() +{ + python::dict dct; + + std::list< pyDia::SymbolPtr > symbolsList = m_dia->findChildrenImpl(SymTagData, "", nsfCaseSensitive ); + + for ( std::list< pyDia::SymbolPtr >::iterator it = symbolsList.begin(); it != symbolsList.end(); it++ ) + { + CComVariant val; + + (*it)->getValue( val ); + + dct[val.ulVal] = (*it)->getName(); + } + + return dct; +} + + ///////////////////////////////////////////////////////////////////////////////////// }; // end namespace pykd \ No newline at end of file diff --git a/pykd/typeinfo.h b/pykd/typeinfo.h index 03ad8c7..2463e8b 100644 --- a/pykd/typeinfo.h +++ b/pykd/typeinfo.h @@ -82,6 +82,9 @@ public: return 8 * getSize(); } + virtual python::dict asMap() { + throw DbgException( "there is no fields" ); + } ULONG getOffset() { return m_offset; @@ -243,6 +246,8 @@ protected: return ti; } + virtual python::dict asMap(); + virtual bool isEnum() { return true; } diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index f27f008..23b0bca 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -101,3 +101,7 @@ class TypeInfoTest( unittest.TestCase ): self.assertEqual( 0, ti.m_doubleValue.offset() ) self.assertEqual( 0, ti.m_bits.offset() ) self.assertEqual( ti.size(), ti.m_doubleValue.size() ) + + def testAsMap(self): + ti = target.module.type("enumType") + self.assertEqual( { 1 : "ONE", 2 : "TWO", 3 : "THREE" }, ti.asMap() )