diff --git a/pykd/dbgexcept.cpp b/pykd/dbgexcept.cpp index 2997b7d..a3ba94b 100644 --- a/pykd/dbgexcept.cpp +++ b/pykd/dbgexcept.cpp @@ -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; /////////////////////////////////////////////////////////////////////////////////// diff --git a/pykd/dbgexcept.h b/pykd/dbgexcept.h index a81b12a..e94a14c 100644 --- a/pykd/dbgexcept.h +++ b/pykd/dbgexcept.h @@ -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 diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index 750879d..d246b88 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -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() + ); // diff --git a/pykd/synsymbol.cpp b/pykd/synsymbol.cpp index b8ffefe..5e83778 100644 --- a/pykd/synsymbol.cpp +++ b/pykd/synsymbol.cpp @@ -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); diff --git a/test/scripts/synsymtest.py b/test/scripts/synsymtest.py index ab768cd..ee54df0 100644 --- a/test/scripts/synsymtest.py +++ b/test/scripts/synsymtest.py @@ -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)