diff --git a/pykd/dia/diawrapper.cpp b/pykd/dia/diawrapper.cpp index 59f9021..62b94b2 100644 --- a/pykd/dia/diawrapper.cpp +++ b/pykd/dia/diawrapper.cpp @@ -304,6 +304,20 @@ ULONG DiaSymbol::getDataKind() //////////////////////////////////////////////////////////////////////////////// +ULONG DiaSymbol::getIndexId() +{ + return callSymbol(get_symIndexId); +} + +//////////////////////////////////////////////////////////////////////////////// + +SymbolPtr DiaSymbol::getIndexType() +{ + return SymbolPtr( new DiaSymbol(callSymbol(get_arrayIndexType) ) ); +} + +//////////////////////////////////////////////////////////////////////////////// + ULONG DiaSymbol::getLocType() { return callSymbol(get_locationType); @@ -372,6 +386,13 @@ SymbolPtr DiaSymbol::getType() //////////////////////////////////////////////////////////////////////////////// +ULONG DiaSymbol::getUdtKind() +{ + return callSymbol(get_udtKind); +} + +//////////////////////////////////////////////////////////////////////////////// + ULONGLONG DiaSymbol::getVa() { return callSymbol(get_virtualAddress); @@ -466,6 +487,30 @@ ULONG DiaSymbol::getVirtualBaseDispSize() ////////////////////////////////////////////////////////////////////////////// +bool DiaSymbol::isBasicType() +{ + DWORD baseType = btNoType; + return + SUCCEEDED( m_symbol->get_baseType(&baseType) ) && + (btNoType != baseType); +} + +////////////////////////////////////////////////////////////////////////////// + +bool DiaSymbol::isConstant() +{ + return !!callSymbol(get_constType); +} + +////////////////////////////////////////////////////////////////////////////// + +bool DiaSymbol::isIndirectVirtualBaseClass() +{ + return !!callSymbol(get_indirectVirtualBaseClass); +} + +////////////////////////////////////////////////////////////////////////////// + bool DiaSymbol::isVirtualBaseClass() { return !!callSymbol(get_virtualBaseClass); diff --git a/pykd/dia/diawrapper.h b/pykd/dia/diawrapper.h index c76f88c..bd40afa 100644 --- a/pykd/dia/diawrapper.h +++ b/pykd/dia/diawrapper.h @@ -66,22 +66,6 @@ public: bool caseSensitive = FALSE ); - //python::list findChildrenEx( - // ULONG symTag, - // const std::string &name = "", - // DWORD nameCmpFlags = 0 - //) - //{ - // return toPyList( findChildrenImpl(symTag, name, nameCmpFlags) ); - //} - - //python::list findChildren( - // const std::string &name - //) - //{ - // return toPyList( findChildrenImpl(SymTagNull, name, nsfCaseSensitive) ); - //} - ULONGLONG getSize(); std::string getName(); @@ -90,7 +74,7 @@ public: SymbolPtr getType(); - //SymbolPtr getIndexType(); + SymbolPtr getIndexType(); ULONG getSymTag(); @@ -102,24 +86,21 @@ public: ULONG getCount(); - //static void getValueImpl(IDiaSymbol *_symbol, VARIANT &vtValue); - //python::object getValue(); - void getValue( BaseTypeVariant &vtValue ); - //bool isBasicType(); + bool isBasicType(); + + bool isIndirectVirtualBaseClass(); bool isVirtualBaseClass(); - //bool isIndirectVirtualBaseClass(); - ULONG getBaseType(); ULONG getBitPosition(); - //ULONG getIndexId(); + ULONG getIndexId(); - //ULONG getUdtKind(); + ULONG getUdtKind(); ULONG getDataKind(); @@ -142,8 +123,8 @@ public: SymbolPtr getChildByIndex(ULONG _index ) { return getChildByIndex( SymTagNull, _index ); } - // - //bool isConstant(); + + bool isConstant(); //std::string print(); @@ -267,404 +248,3 @@ private: } // end pykd namespace - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//#include -// -//#include -// -//#include -// -//#include "utils.h" -//#include "dbgexcept.h" -// -//namespace pyDia { -// -//typedef CComPtr< IDiaSymbol > DiaSymbolPtr; -//typedef CComPtr< IDiaEnumSymbols > DiaEnumSymbolsPtr; -//typedef CComPtr< IDiaDataSource > DiaDataSourcePtr; -//typedef CComPtr< IDiaSession > DiaSessionPtr; -// -////////////////////////////////////////////////////////////////////////////////// -//// DIA Exceptions -////////////////////////////////////////////////////////////////////////////////// -//class Exception : public pykd::SymbolException { -//public: -// Exception(const std::string &desc, HRESULT hres) -// : SymbolException( makeFullDesc(desc, hres) ) -// , m_hres(hres) -// { -// } -// -// Exception(const std::string &desc) -// : SymbolException(descPrefix + desc) -// , m_hres(S_FALSE) -// { -// } -// -// HRESULT getRes() const { -// return m_hres; -// } -//private: -// -// static const std::string descPrefix; -// -// static std::string makeFullDesc(const std::string &desc, HRESULT hres); -// -// HRESULT m_hres; -//}; -// -//class Symbol; -//typedef boost::shared_ptr< Symbol > SymbolPtr; -//typedef std::list< SymbolPtr > SymbolPtrList; -// -////////////////////////////////////////////////////////////////////////////////// -//// Symbol -////////////////////////////////////////////////////////////////////////////////// -//class Symbol { -//public: -// Symbol() -// { -// throw Exception("DiaSymbol must be created over factory from DiaScope::..."); -// } -// Symbol(__inout DiaSymbolPtr &_symbol, DWORD machineType) -// : m_machineType(machineType) -// { -// m_symbol = _symbol.Detach(); -// } -// Symbol(__in IDiaSymbol *_symbol, DWORD machineType) -// : m_machineType(machineType) -// { -// m_symbol = _symbol; -// } -// -// -// SymbolPtrList findChildrenImpl( -// ULONG symTag, -// const std::string &name = "", -// DWORD nameCmpFlags = 0 -// ); -// -// python::list findChildrenEx( -// ULONG symTag, -// const std::string &name = "", -// DWORD nameCmpFlags = 0 -// ) -// { -// return toPyList( findChildrenImpl(symTag, name, nameCmpFlags) ); -// } -// -// python::list findChildren( -// const std::string &name -// ) -// { -// return toPyList( findChildrenImpl(SymTagNull, name, nsfCaseSensitive) ); -// } -// -// ULONGLONG getSize(); -// -// std::string getName(); -// std::string getUndecoratedName(); -// -// SymbolPtr getType(); -// -// SymbolPtr getIndexType(); -// -// ULONG getSymTag(); -// -// ULONG getRva(); -// ULONGLONG getVa(); -// -// ULONG getLocType(); -// -// LONG getOffset(); -// -// ULONG getCount(); -// -// static void getValueImpl(IDiaSymbol *_symbol, VARIANT &vtValue); -// python::object getValue(); -// void getValue( VARIANT &vtValue); -// -// bool isBasicType(); -// -// bool isVirtualBaseClass(); -// -// bool isIndirectVirtualBaseClass(); -// -// ULONG getBaseType(); -// -// ULONG getBitPosition(); -// -// ULONG getIndexId(); -// -// ULONG getUdtKind(); -// -// ULONG getDataKind(); -// -// ULONG getRegisterId(); -// -// ULONG getMachineType() const { -// return m_machineType; -// } -// -// SymbolPtr getChildByName(const std::string &_name); -// -// template -// ULONG getChildCount(); -// -// ULONG getChildCount() { -// return getChildCount(); -// } -// -// template -// SymbolPtr getChildByIndex(ULONG _index ); -// -// SymbolPtr getChildByIndex(ULONG _index ) { -// return getChildByIndex( _index ); -// } -// -// bool isConstant(); -// -// std::string print(); -// -// bool eq(Symbol &rhs); -// -// int getVirtualBasePointerOffset(); -// -// ULONG getVirtualBaseDispIndex(); -// -// ULONG getVirtualBaseDispSize(); -// -// ULONG getSection(); -// -//public: -// typedef std::pair ValueNameEntry; -// -// static const ValueNameEntry dataKindName[DataIsConstant + 1]; -// -// static const ValueNameEntry symTagName[SymTagMax]; -// -// static const ValueNameEntry locTypeName[LocTypeMax]; -// -// static const ValueNameEntry basicTypeName[]; -// static const size_t cntBasicTypeName; -// -// static const ValueNameEntry udtKindName[]; -// static const size_t cntUdtKindName; -// -// static const ValueNameEntry i386RegName[]; -// static const size_t cntI386RegName; -// -// static const ValueNameEntry amd64RegName[]; -// static const size_t cntAmd64RegName; -// -// static std::string getBasicTypeName( ULONG basicType ); -// -//protected: -// -// // Check symbols loop -// class checkSymLoop -// { -// public: -// checkSymLoop(checkSymLoop *prev) -// : m_symSetPtr( prev ? prev->m_symSetPtr : symSetPtr(new symSet) ) -// { -// } -// -// bool check(IDiaSymbol *_symbol) -// { -// DWORD symIndexId = 0; -// _symbol->get_symIndexId(&symIndexId); -// return !m_symSetPtr->insert(symIndexId).second; -// } -// -// private: -// typedef std::set symSet; -// typedef boost::shared_ptr symSetPtr; -// symSetPtr m_symSetPtr; -// }; -// -// static std::string printImpl( -// IDiaSymbol *_symbol, -// DWORD machineType, -// ULONG indent = 0, -// checkSymLoop *checkLoopPrev = NULL, -// const char *prefix = NULL -// ); -// -// template -// TRet callSymbolT( -// HRESULT(STDMETHODCALLTYPE IDiaSymbol::*method)(TRet *), -// const char *methodName -// ) -// { -// TRet retValue; -// HRESULT hres = (m_symbol->*method)(&retValue); -// if (S_OK != hres) -// throw Exception(std::string("Call IDiaSymbol::") + methodName, hres); -// -// return retValue; -// } -// -// DiaSymbolPtr m_symbol; -// DWORD m_machineType; -//}; -// -//class GlobalScope; -//typedef boost::shared_ptr< GlobalScope > GlobalScopePtr; -// -////////////////////////////////////////////////////////////////////////////////// -//// Global scope: source + sessions -////////////////////////////////////////////////////////////////////////////////// -//class GlobalScope : public Symbol { -//public: -// GlobalScope() {} -// -// // GlobalScope factory -// static GlobalScopePtr loadPdb(const std::string &filePath); -// static GlobalScopePtr loadExe(const std::string &filePath, PCSTR searchPath = NULL); -// -// // RVA -> Symbol -// python::tuple findByRva( -// ULONG rva, -// ULONG symTag -// ) -// { -// LONG displacement; -// SymbolPtr child = findByRvaImpl(rva, symTag, displacement); -// return python::make_tuple(child, displacement); -// } -// SymbolPtr findByRvaImpl( -// __in ULONG rva, -// __in ULONG symTag, -// __out LONG &displacement -// ); -// -// // VA -> Symbol -// python::tuple findByVa( -// ULONG va, -// ULONG symTag -// ) -// { -// LONG displacement; -// SymbolPtr child = findByVaImpl(va, symTag, displacement); -// return python::make_tuple(child, displacement); -// } -// SymbolPtr findByVaImpl( -// __in ULONGLONG va, -// __in ULONG symTag, -// __out LONG &displacement -// ); -// -// // get symbol by unique index -// SymbolPtr getSymbolById(ULONG symId); -// -// // get/set load address -// ULONGLONG getLoadAddress(); -// void setLoadAddress(ULONGLONG loadAddress); -// -//private: -// interface IScopeDataLoader { -// virtual ~IScopeDataLoader() {} -// virtual void loadData(IDiaDataSource *dataSource) = 0; -// }; -// static GlobalScopePtr loadImpl(IScopeDataLoader &ScopeDataLoader); -// -// GlobalScope( -// __inout DiaDataSourcePtr &dataSource, -// __inout DiaSessionPtr &_session, -// __inout DiaSymbolPtr &_globalScope -// ); -// -// DiaDataSourcePtr m_dataSource; -// DiaSessionPtr m_session; -//}; -// -////////////////////////////////////////////////////////////////////////////////// -// -//template -//ULONG Symbol::getChildCount() -//{ -// DiaEnumSymbolsPtr symbols; -// HRESULT hres = -// m_symbol->findChildren( -// static_cast(symTag), -// NULL, -// nsCaseSensitive, -// &symbols); -// if (S_OK != hres) -// throw Exception("Call IDiaSymbol::findChildren", hres); -// -// LONG count; -// hres = symbols->get_Count(&count); -// if (S_OK != hres) -// throw Exception("Call IDiaEnumSymbols::get_Count", hres); -// -// return count; -//} -// -////////////////////////////////////////////////////////////////////////////////// -// -//template -//SymbolPtr Symbol::getChildByIndex(ULONG _index ) -//{ -// DiaEnumSymbolsPtr symbols; -// HRESULT hres = -// m_symbol->findChildren( -// static_cast(symTag), -// NULL, -// nsCaseSensitive, -// &symbols); -// if (S_OK != hres) -// throw Exception("Call IDiaSymbol::findChildren", hres); -// -// LONG count; -// hres = symbols->get_Count(&count); -// if (S_OK != hres) -// throw Exception("Call IDiaEnumSymbols::get_Count", hres); -// -// if (LONG(_index) >= count) -// { -// PyErr_SetString(PyExc_IndexError, "Index out of range"); -// boost::python::throw_error_already_set(); -// } -// -// DiaSymbolPtr child; -// hres = symbols->Item(_index, &child); -// if (S_OK != hres) -// throw Exception("Call IDiaEnumSymbols::Item", hres); -// -// return SymbolPtr( new Symbol(child, m_machineType) ); -//} -// -////////////////////////////////////////////////////////////////////////////////// -// -//}; diff --git a/pykd/symengine.h b/pykd/symengine.h index c049eec..1bb85d6 100644 --- a/pykd/symengine.h +++ b/pykd/symengine.h @@ -124,6 +124,7 @@ public: virtual ULONG getChildCount(ULONG symTag ) = 0; virtual ULONG getCount() = 0; virtual ULONG getDataKind() = 0; + virtual SymbolPtr getIndexType() = 0; virtual ULONG getLocType() = 0; virtual ULONG getMachineType() = 0; virtual std::string getName() = 0; @@ -132,13 +133,18 @@ public: virtual ULONGLONG getSize() = 0; virtual ULONG getSymTag() = 0; virtual SymbolPtr getType() = 0; + virtual ULONG getUdtKind() = 0; virtual std::string getUndecoratedName() = 0; virtual ULONGLONG getVa() = 0; virtual void getValue( BaseTypeVariant &vtValue) = 0; virtual ULONG getVirtualBaseDispIndex() = 0; virtual int getVirtualBasePointerOffset() = 0; - virtual bool isVirtualBaseClass() = 0; virtual ULONG getVirtualBaseDispSize() = 0; + virtual bool isBasicType() = 0; + virtual bool isConstant() = 0; + virtual bool isIndirectVirtualBaseClass() = 0; + virtual bool isVirtualBaseClass() = 0; + }; ///////////////////////////////////////////////////////////////////////////////