+ AddSynSymbolException: different exception for addSynSymbols
 + Test adding a two synthetic symbols with equal address

git-svn-id: https://pykd.svn.codeplex.com/svn@73137 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2012-01-13 12:12:31 +00:00 committed by Mikhail I. Izmestev
parent e69047ac19
commit fc9014b440
5 changed files with 41 additions and 3 deletions

View File

@ -10,6 +10,7 @@ PyObject *ExceptionTranslator<DbgException>::exceptTypeObject = NULL;
PyObject *ExceptionTranslator<MemoryException>::exceptTypeObject = NULL;
PyObject *ExceptionTranslator<WaitEventException>::exceptTypeObject = NULL;
PyObject *ExceptionTranslator<pyDia::Exception>::exceptTypeObject = NULL;
PyObject *ExceptionTranslator<AddSyntheticSymbolException>::exceptTypeObject = NULL;
///////////////////////////////////////////////////////////////////////////////////

View File

@ -127,5 +127,25 @@ private:
/////////////////////////////////////////////////////////////////////////////////
class AddSyntheticSymbolException : public DbgException
{
public:
AddSyntheticSymbolException(HRESULT hres)
: DbgException( buildDesc(hres) )
{
}
private:
std::string buildDesc(HRESULT hres) {
std::stringstream sstream;
sstream << "Add synthetic symbol faield\n";
sstream << "HRESULT 0x" << std::hex << hres;
return sstream.str();
}
};
/////////////////////////////////////////////////////////////////////////////////
}; // namespace pykd

View File

@ -829,8 +829,12 @@ BOOST_PYTHON_MODULE( pykd )
.ptr()
);
// AddSyntheticSymbolException
ExceptionTranslator<AddSyntheticSymbolException>::setTypeObject(
python::class_<AddSyntheticSymbolException, python::bases<DbgException> >(
"AddSynSymbolException", "Add new synthetic symbol exception", python::no_init)
.ptr()
);
//

View File

@ -42,7 +42,7 @@ void SyntheticSymbols::add(
DEBUG_ADDSYNTHSYM_DEFAULT,
&dbgModuleAndId);
if ( FAILED( hres ) )
throw DbgException("IDebugSymbols3::AddSyntheticSymbol", hres);
throw AddSyntheticSymbolException( hres );
// add/update symbol for target module (in internal map)
SymbolsScopedLock lock(*m_allSymbolsLock);

View File

@ -66,3 +66,16 @@ class SynSymTest(unittest.TestCase):
self.assertEqual(
target.module.offset("FuncWithName0")-5,
target.module.offset("synSym5"))
def testAddSynSymbolException(self):
"""Test of AddSynSymbolException"""
pykd.addSynSymbol(
target.module.offset("FuncWithName0")-6, 1, "synSym6")
exceptionOccurred = False
try:
pykd.addSynSymbol(
target.module.offset("FuncWithName0")-6, 1, "synSym7")
except pykd.AddSynSymbolException:
exceptionOccurred = True
self.assertTrue(exceptionOccurred)