mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 20:03:33 +08:00
[0.2.x] fixed : get symbol name for decorated names
git-svn-id: https://pykd.svn.codeplex.com/svn@80273 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
f0fc6f3f86
commit
d11fd6a958
@ -473,22 +473,7 @@ std::string DiaSymbol::getName()
|
|||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DiaException("Call IDiaSymbol::get_symTag", hres);
|
throw DiaException("Call IDiaSymbol::get_symTag", hres);
|
||||||
|
|
||||||
if ( symTag == SymTagPublicSymbol )
|
if( symTag == SymTagData || symTag == SymTagFunction || symTag == SymTagPublicSymbol )
|
||||||
{
|
|
||||||
std::string retStr = autoBstr( callSymbol(get_name) ).asStr();
|
|
||||||
|
|
||||||
boost::cmatch matchResult;
|
|
||||||
|
|
||||||
if ( boost::regex_match( retStr.c_str(), matchResult, stdcallMatch ) )
|
|
||||||
return std::string( matchResult[1].first, matchResult[1].second );
|
|
||||||
|
|
||||||
if ( boost::regex_match( retStr.c_str(), matchResult, fastcallMatch ) )
|
|
||||||
return std::string( matchResult[1].first, matchResult[1].second );
|
|
||||||
|
|
||||||
return retStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( symTag == SymTagData || symTag == SymTagFunction )
|
|
||||||
{
|
{
|
||||||
hres = m_symbol->get_undecoratedNameEx( UNDNAME_NAME_ONLY, &bstrName);
|
hres = m_symbol->get_undecoratedNameEx( UNDNAME_NAME_ONLY, &bstrName);
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
|
@ -62,6 +62,8 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBp_, setHardwareBp, 3, 4 );
|
|||||||
|
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( CustomStruct_create, CustomStruct::create, 1, 2 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( CustomStruct_create, CustomStruct::create, 1, 2 );
|
||||||
|
|
||||||
|
BOOST_PYTHON_FUNCTION_OVERLOADS( findSymbol_, TypeInfo::findSymbol, 1, 2 );
|
||||||
|
|
||||||
BOOST_PYTHON_MODULE( pykd )
|
BOOST_PYTHON_MODULE( pykd )
|
||||||
{
|
{
|
||||||
python::scope().attr("version") = pykdVersion;
|
python::scope().attr("version") = pykdVersion;
|
||||||
@ -202,8 +204,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Return source file name, line and displacement by the specified offset" ) );
|
"Return source file name, line and displacement by the specified offset" ) );
|
||||||
python::def( "getOffset", &TypeInfo::getOffset,
|
python::def( "getOffset", &TypeInfo::getOffset,
|
||||||
"Return traget virtual address for specified symbol" );
|
"Return traget virtual address for specified symbol" );
|
||||||
python::def( "findSymbol", &TypeInfo::findSymbol,
|
python::def( "findSymbol", &TypeInfo::findSymbol, findSymbol_( python::args( "offset", "safe"),
|
||||||
"Find symbol by the target virtual memory offset" );
|
"Find symbol by the target virtual memory offset" ) );
|
||||||
python::def( "sizeof", &TypeInfo::getSymbolSize,
|
python::def( "sizeof", &TypeInfo::getSymbolSize,
|
||||||
"Return a size of the type or variable" );
|
"Return a size of the type or variable" );
|
||||||
python::def("typedVarList", &getTypedVarListByTypeName,
|
python::def("typedVarList", &getTypedVarListByTypeName,
|
||||||
|
@ -74,14 +74,31 @@ ULONG64 TypeInfo::getSymbolSize( const std::string &fullName )
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string TypeInfo::findSymbol( ULONG64 offset )
|
std::string TypeInfo::findSymbol( ULONG64 offset, bool safe)
|
||||||
{
|
{
|
||||||
|
if ( !safe )
|
||||||
|
{
|
||||||
|
ModulePtr module = Module::loadModuleByOffset( offset );
|
||||||
|
|
||||||
|
return module->getName() + '!' + module->getSymbolNameByVa( offset );
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ModulePtr module = Module::loadModuleByOffset( offset );
|
ModulePtr module = Module::loadModuleByOffset( offset );
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
return module->getName() + '!' + module->getSymbolNameByVa( offset );
|
return module->getName() + '!' + module->getSymbolNameByVa( offset );
|
||||||
|
|
||||||
|
}
|
||||||
|
catch( DbgException& )
|
||||||
|
{
|
||||||
|
std::stringstream sstr;
|
||||||
|
sstr << module->getName() << '!' << std::hex << ( offset - module->getBase() );
|
||||||
|
return sstr.str();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( DbgException& )
|
catch( DbgException& )
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
ULONG64 getSymbolSize( const std::string &symName );
|
ULONG64 getSymbolSize( const std::string &symName );
|
||||||
|
|
||||||
static
|
static
|
||||||
std::string findSymbol( ULONG64 offset );
|
std::string findSymbol( ULONG64 offset, bool safe = true );
|
||||||
|
|
||||||
static
|
static
|
||||||
ULONG64 getOffset( const std::string &symbolName );
|
ULONG64 getOffset( const std::string &symbolName );
|
||||||
|
Loading…
Reference in New Issue
Block a user