[0.2.x] ~getName now return undecorated name

git-svn-id: https://pykd.svn.codeplex.com/svn@79579 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2012-09-14 17:17:44 +00:00 committed by Mikhail I. Izmestev
parent bd94e142d1
commit eef5cf7596
3 changed files with 54 additions and 34 deletions

View File

@ -40,10 +40,54 @@ DiaRegToRegRelativeI386::DiaRegToRegRelativeI386()
const std::string DiaException::descPrefix("pyDia: ");
std::string DiaException::makeFullDesc(const std::string &desc, HRESULT hres)
std::string DiaException::makeFullDesc(const std::string &desc, HRESULT hres, IDiaSymbol *symbol /*= NULL*/)
{
std::stringstream sstream;
sstream << descPrefix << desc << " failed" << std::endl;
if (symbol)
{
BSTR bstrName = NULL;
HRESULT locRes = symbol->get_undecoratedName(&bstrName);
if (S_OK == locRes && bstrName)
{
autoBstr freeBstr(bstrName);
sstream << "Symbol name: \"" << autoBstr::asStr(bstrName) << "\"";
}
else
{
locRes = symbol->get_name(&bstrName);
if (S_OK == locRes && bstrName)
{
autoBstr freeBstr(bstrName);
sstream << "Symbol name: " << autoBstr::asStr(bstrName);
}
else
{
sstream << "Symbol: ";
}
}
DWORD dwValue;
locRes = symbol->get_relativeVirtualAddress(&dwValue);
if (S_OK == locRes)
{
sstream << ", RVA= 0x" << std::hex << dwValue;
}
locRes = symbol->get_symTag(&dwValue);
if (S_OK == locRes)
{
sstream << ", tag= " << std::dec << dwValue;
}
locRes = symbol->get_locationType(&dwValue);
if (S_OK == locRes)
{
sstream << ", location: " << std::dec << dwValue;
}
sstream << std::endl;
}
sstream << "Return value is 0x" << std::hex << hres;
PCHAR errMessage = NULL;
@ -392,32 +436,11 @@ static const boost::regex stdcallMatch("^_(\\w+)@.+$");
std::string DiaSymbol::getName()
{
autoBstr retValue( callSymbol(get_name) );
boost::cmatch matchResult;
std::string retStr = retValue.asStr();
if ( boost::regex_match( retStr.c_str(), matchResult, stdcallMatch ) )
{
retStr= std::string( matchResult[1].first, matchResult[1].second );
}
else if (IMAGE_FILE_MACHINE_I386 == m_machineType)
{
DWORD symTag;
HRESULT hres = m_symbol->get_symTag(&symTag);
if (S_OK == hres && SymTagPublicSymbol == symTag)
retStr.erase( retStr.begin() );
}
return retStr;
}
///////////////////////////////////////////////////////////////////////////////
std::string DiaSymbol::getUndecoratedName()
{
autoBstr retValue( callSymbol(get_undecoratedName) );
BSTR bstrName = NULL;
HRESULT hres = m_symbol->get_undecoratedName(&bstrName);
if (S_OK != hres)
bstrName = callSymbol(get_name);
autoBstr retValue( bstrName );
return retValue.asStr();
}

View File

@ -25,8 +25,8 @@ typedef std::map<ULONG, ULONG> DiaRegToRegRelativeBase;
class DiaException : public SymbolException {
public:
DiaException(const std::string &desc, HRESULT hres)
: SymbolException( makeFullDesc(desc, hres) )
DiaException(const std::string &desc, HRESULT hres, IDiaSymbol *symbol = NULL)
: SymbolException( makeFullDesc(desc, hres, symbol) )
, m_hres(hres)
{
}
@ -44,7 +44,7 @@ private:
static const std::string descPrefix;
static std::string makeFullDesc(const std::string &desc, HRESULT hres);
static std::string makeFullDesc(const std::string &desc, HRESULT hres, IDiaSymbol *symbol = NULL);
HRESULT m_hres;
};
@ -71,8 +71,6 @@ public:
std::string getName();
std::string getUndecoratedName();
SymbolPtr getType();
SymbolPtr getIndexType();
@ -208,7 +206,7 @@ protected:
TRet retValue;
HRESULT hres = (m_symbol->*method)(&retValue);
if (S_OK != hres)
throw DiaException(std::string("Call IDiaSymbol::") + methodName, hres);
throw DiaException(std::string("Call IDiaSymbol::") + methodName, hres, m_symbol);
return retValue;
}

View File

@ -143,7 +143,6 @@ public:
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;