From fc9014b4403969050308dc3f7aab1b6e884fe9c2 Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Fri, 13 Jan 2012 12:12:31 +0000 Subject: [PATCH] [0.1.x] + 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 --- pykd/dbgexcept.cpp | 1 + pykd/dbgexcept.h | 20 ++++++++++++++++++++ pykd/dbgext.cpp | 8 ++++++-- pykd/synsymbol.cpp | 2 +- test/scripts/synsymtest.py | 13 +++++++++++++ 5 files changed, 41 insertions(+), 3 deletions(-) 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::exceptTypeObject = NULL; PyObject *ExceptionTranslator::exceptTypeObject = NULL; PyObject *ExceptionTranslator::exceptTypeObject = NULL; PyObject *ExceptionTranslator::exceptTypeObject = NULL; +PyObject *ExceptionTranslator::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::setTypeObject( + python::class_ >( + "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)