diff --git a/pykd/dia/diawrapper.cpp b/pykd/dia/diawrapper.cpp index 8781fc9..76c0f75 100644 --- a/pykd/dia/diawrapper.cpp +++ b/pykd/dia/diawrapper.cpp @@ -472,23 +472,8 @@ std::string DiaSymbol::getName() if ( FAILED( hres ) ) throw DiaException("Call IDiaSymbol::get_symTag", hres); - - if ( 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 ) + + if( symTag == SymTagData || symTag == SymTagFunction || symTag == SymTagPublicSymbol ) { hres = m_symbol->get_undecoratedNameEx( UNDNAME_NAME_ONLY, &bstrName); if ( FAILED( hres ) ) diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 44c1bdd..d14e685 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -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( findSymbol_, TypeInfo::findSymbol, 1, 2 ); + BOOST_PYTHON_MODULE( pykd ) { python::scope().attr("version") = pykdVersion; @@ -202,8 +204,8 @@ BOOST_PYTHON_MODULE( pykd ) "Return source file name, line and displacement by the specified offset" ) ); python::def( "getOffset", &TypeInfo::getOffset, "Return traget virtual address for specified symbol" ); - python::def( "findSymbol", &TypeInfo::findSymbol, - "Find symbol by the target virtual memory offset" ); + python::def( "findSymbol", &TypeInfo::findSymbol, findSymbol_( python::args( "offset", "safe"), + "Find symbol by the target virtual memory offset" ) ); python::def( "sizeof", &TypeInfo::getSymbolSize, "Return a size of the type or variable" ); python::def("typedVarList", &getTypedVarListByTypeName, diff --git a/pykd/typeinfo.cpp b/pykd/typeinfo.cpp index 19dd6b5..182896c 100644 --- a/pykd/typeinfo.cpp +++ b/pykd/typeinfo.cpp @@ -74,13 +74,30 @@ 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 { ModulePtr module = Module::loadModuleByOffset( offset ); - return module->getName() + '!' + module->getSymbolNameByVa( offset ); + try { + + return module->getName() + '!' + module->getSymbolNameByVa( offset ); + + } + catch( DbgException& ) + { + std::stringstream sstr; + sstr << module->getName() << '!' << std::hex << ( offset - module->getBase() ); + return sstr.str(); + } } catch( DbgException& ) diff --git a/pykd/typeinfo.h b/pykd/typeinfo.h index fe033ef..96680da 100644 --- a/pykd/typeinfo.h +++ b/pykd/typeinfo.h @@ -29,7 +29,7 @@ public: ULONG64 getSymbolSize( const std::string &symName ); static - std::string findSymbol( ULONG64 offset ); + std::string findSymbol( ULONG64 offset, bool safe = true ); static ULONG64 getOffset( const std::string &symbolName );