Commit e1c23a11 authored by ussrhero's avatar ussrhero
Browse files

Merge branch 'find_symbol_bug' into 'dev-1.0'

fixed a bug in findSymbol routine

See merge request !35
parents af784481 4e4f9f33
......@@ -213,6 +213,7 @@ public:
virtual unsigned long getVirtualBaseOffset() = 0;
virtual SymbolPtrList findInlineFramesByVA(MEMOFFSET_64) = 0;
virtual void getInlineSourceLine(MEMOFFSET_64, std::wstring &fileName, unsigned long &lineNo) = 0;
virtual SymbolPtr getLexicalParent() = 0;
};
///////////////////////////////////////////////////////////////////////////////
......
......@@ -544,6 +544,11 @@ public:
{
NOT_IMPLEMENTED();
}
SymbolPtr getLexicalParent() override
{
NOT_IMPLEMENTED();
}
};
......
......@@ -826,6 +826,14 @@ void DiaSymbol::getInlineSourceLine(MEMOFFSET_64 offset, std::wstring &fileName,
//////////////////////////////////////////////////////////////////////////////
SymbolPtr DiaSymbol::getLexicalParent()
{
DiaSymbolPtr diaSymbol(callSymbol(get_lexicalParent));
return SymbolPtr(new DiaSymbol(diaSymbol, m_scope, m_machineType));
}
//////////////////////////////////////////////////////////////////////////////
std::wstring DiaSession::getScopeName( IDiaSession* session, IDiaSymbol *globalScope )
{
std::wstring scopeName;
......
......@@ -152,6 +152,8 @@ public:
void getInlineSourceLine(MEMOFFSET_64, std::wstring &fileName, unsigned long &lineNo) override;
SymbolPtr getLexicalParent() override;
public:
typedef std::pair<ULONG, const wchar_t *> ValueNameEntry;
static const ValueNameEntry basicTypeName[];
......
......@@ -267,6 +267,11 @@ class ExportSymbolBase : public Symbol
{
NOT_IMPLEMENTED();
}
SymbolPtr getLexicalParent() override
{
NOT_IMPLEMENTED();
}
};
///////////////////////////////////////////////////////////////////////////////
......
......@@ -596,26 +596,31 @@ void ModuleImp::getFileVersion(unsigned long& majorVersion, unsigned long& minor
void ModuleImp::findSymSessionSymbol(MEMOFFSET_64 offset, std::wstring &name, MEMDISPLACEMENT &displacement)
{
displacement = 0;
name.clear();
offset = addr64(offset);
try
{
while ( name.empty() )
{
SymbolPtr sym = getSymSession()->findByRva( (MEMDISPLACEMENT)(offset - m_base), SymTagNull, &displacement );
name = sym->getName();
if ( !name.empty() )
break;
long tempdisp;
SymbolPtr sym = getSymSession()->findByRva( static_cast<MEMDISPLACEMENT>(offset - m_base), SymTagNull, &tempdisp );
offset = offset - displacement - 1;
auto tag = sym->getSymTag();
while (tag == SymTagBlock)
{
sym = sym->getLexicalParent();
tag = sym->getSymTag();
}
name = sym->getName();
displacement = static_cast<MEMDISPLACEMENT>(offset - m_base) - sym->getRva();
}
catch (const DbgException &)
{
name.clear();
}
}
///////////////////////////////////////////////////////////////////////////////
ScopePtr ModuleImp::getScope()
......
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