Commit 3aab657b authored by Aleksey R.'s avatar Aleksey R.

Merge branch 'fix-scope-names' into 'dev-1.0'

module name as scope names for DiaSymbol

See merge request !7
parents 2616b468 0e4eed02
...@@ -177,14 +177,14 @@ std::wstring getBasicTypeName( ULONG basicType ) ...@@ -177,14 +177,14 @@ std::wstring getBasicTypeName( ULONG basicType )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
DiaSymbol::DiaSymbol(DiaSymbolPtr &_symbol, DiaSymbolPtr &_scope, MachineTypes machineType) DiaSymbol::DiaSymbol(DiaSymbolPtr &_symbol, const std::wstring &_scope, MachineTypes machineType)
: m_symbol(_symbol), m_scope(_scope), m_machineType(machineType) : m_symbol(_symbol), m_scope(_scope), m_machineType(machineType)
{ {
} }
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
SymbolPtr DiaSymbol::fromGlobalScope( IDiaSymbol *_symbol ) SymbolPtr DiaSymbol::fromGlobalScope( IDiaSymbol *_symbol, const std::wstring& _scope )
{ {
MachineTypes machineType; MachineTypes machineType;
HRESULT hres = _symbol->get_machineType( (DWORD*)&machineType); HRESULT hres = _symbol->get_machineType( (DWORD*)&machineType);
...@@ -193,7 +193,7 @@ SymbolPtr DiaSymbol::fromGlobalScope( IDiaSymbol *_symbol ) ...@@ -193,7 +193,7 @@ SymbolPtr DiaSymbol::fromGlobalScope( IDiaSymbol *_symbol )
if (!machineType) if (!machineType)
machineType = machine_I386; machineType = machine_I386;
return SymbolPtr( new DiaSymbol(DiaSymbolPtr(_symbol), DiaSymbolPtr(_symbol), machineType) ); return SymbolPtr(new DiaSymbol(DiaSymbolPtr(_symbol), _scope, machineType));
} }
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
...@@ -562,12 +562,7 @@ std::wstring DiaSymbol::getName() ...@@ -562,12 +562,7 @@ std::wstring DiaSymbol::getName()
std::wstring DiaSymbol::getScopeName() std::wstring DiaSymbol::getScopeName()
{ {
HRESULT hres; return m_scope;
BSTR bstrName = NULL;
hres = m_scope->get_name(&bstrName);
if (S_OK == hres)
return std::wstring(_bstr_t(bstrName, false));
return L"";
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -770,6 +765,18 @@ unsigned long DiaSymbol::getVirtualBaseOffset() ...@@ -770,6 +765,18 @@ unsigned long DiaSymbol::getVirtualBaseOffset()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
std::wstring DiaSession::getScopeName( IDiaSession* session )
{
ULONGLONG loadBase;
HRESULT hres = session->get_loadAddress(&loadBase);
if (S_OK != hres)
return L"";
return getModuleName(loadBase);
}
//////////////////////////////////////////////////////////////////////////////
SymbolPtr DiaSession::findByRva( ULONG rva, ULONG symTag, LONG* pdisplacement ) SymbolPtr DiaSession::findByRva( ULONG rva, ULONG symTag, LONG* pdisplacement )
{ {
DiaSymbolPtr child; DiaSymbolPtr child;
...@@ -792,7 +799,7 @@ SymbolPtr DiaSession::findByRva( ULONG rva, ULONG symTag, LONG* pdisplacement ) ...@@ -792,7 +799,7 @@ SymbolPtr DiaSession::findByRva( ULONG rva, ULONG symTag, LONG* pdisplacement )
if (pdisplacement) if (pdisplacement)
*pdisplacement = displacement; *pdisplacement = displacement;
return SymbolPtr( new DiaSymbol(child, m_globalScope, m_globalSymbol->getMachineType() ) ); return SymbolPtr( new DiaSymbol(child, getScopeName( m_session ), m_globalSymbol->getMachineType() ) );
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -55,9 +55,9 @@ private: ...@@ -55,9 +55,9 @@ private:
class DiaSymbol : public Symbol { class DiaSymbol : public Symbol {
public: public:
DiaSymbol( DiaSymbolPtr &_symbol, DiaSymbolPtr &_scope, MachineTypes machineType ); DiaSymbol( DiaSymbolPtr &_symbol, const std::wstring &_scope, MachineTypes machineType );
static SymbolPtr fromGlobalScope( IDiaSymbol *_symbol ); static SymbolPtr fromGlobalScope( IDiaSymbol *_symbol, const std::wstring &_scope );
SymbolPtr getChildByName(const std::wstring &_name ); SymbolPtr getChildByName(const std::wstring &_name );
...@@ -190,7 +190,7 @@ protected: ...@@ -190,7 +190,7 @@ protected:
} }
DiaSymbolPtr m_symbol; DiaSymbolPtr m_symbol;
DiaSymbolPtr m_scope; std::wstring m_scope;
MachineTypes m_machineType; MachineTypes m_machineType;
}; };
...@@ -203,7 +203,7 @@ public: ...@@ -203,7 +203,7 @@ public:
DiaSession( IDiaSession* session, IDiaSymbol *globalScope, const std::wstring symbolFile ) : DiaSession( IDiaSession* session, IDiaSymbol *globalScope, const std::wstring symbolFile ) :
m_globalScope( globalScope ), m_globalScope( globalScope ),
m_globalSymbol( DiaSymbol::fromGlobalScope( globalScope ) ), m_globalSymbol( DiaSymbol::fromGlobalScope( globalScope, getScopeName( session ) ) ),
m_session( session ), m_session( session ),
m_symbolFileName( symbolFile ) m_symbolFileName( symbolFile )
{} {}
...@@ -222,6 +222,8 @@ public: ...@@ -222,6 +222,8 @@ public:
private: private:
static std::wstring getScopeName( IDiaSession* session );
ULONG findRvaByName( const std::string &name ); ULONG findRvaByName( const std::string &name );
DiaSymbolPtr m_globalScope; DiaSymbolPtr m_globalScope;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment