diff --git a/pykd/pymodule.h b/pykd/pymodule.h index 1a5b1b2..f33882b 100644 --- a/pykd/pymodule.h +++ b/pykd/pymodule.h @@ -91,7 +91,16 @@ struct ModuleAdapter : public kdlib::Module catch (kdlib::DbgException&) { } - return python::object(module.getTypeByName(symbolName)); + + try { + return python::object(module.getTypeByName(symbolName)); + } + catch (kdlib::DbgException&) + { } + + std::wstringstream sstr; + sstr << L'\'' << module.getName() << L'\'' << L" module has not a symbol " << L'\'' << symbolName << L'\''; + throw AttributeException(std::string(_bstr_t(sstr.str().c_str())).c_str()); } static python::object getItemByKey(kdlib::Module& module, const std::wstring &symbolName) @@ -113,7 +122,7 @@ struct ModuleAdapter : public kdlib::Module } std::wstringstream sstr; - sstr << L"module hase symbol " << L'\'' << symbolName << L'\''; + sstr << L"module has not a symbol " << L'\'' << symbolName << L'\''; throw KeyException(std::string(_bstr_t(sstr.str().c_str())).c_str()); } diff --git a/pykd/pytypedvar.cpp b/pykd/pytypedvar.cpp index b71a35d..4a0e7bd 100644 --- a/pykd/pytypedvar.cpp +++ b/pykd/pytypedvar.cpp @@ -254,7 +254,19 @@ kdlib::TypedVarPtr TypedVarAdapter::getFieldAttr(kdlib::TypedVar& typedVar, cons catch (kdlib::TypeException&) {} - return typedVar.getMethod(name); + + try + { + return typedVar.getMethod(name); + } + catch (kdlib::TypeException&) + { + } + + + std::stringstream sstr; + sstr << "typed var has no field " << '\'' << _bstr_t(name.c_str()) << '\''; + throw AttributeException(sstr.str().c_str()); } /////////////////////////////////////////////////////////////////////////////// diff --git a/pykd/pytypeinfo.cpp b/pykd/pytypeinfo.cpp index 6436897..59fc431 100644 --- a/pykd/pytypeinfo.cpp +++ b/pykd/pytypeinfo.cpp @@ -273,7 +273,19 @@ kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, co catch (kdlib::TypeException&) {} - return typeInfo.getMethod(name); + try + { + return typeInfo.getMethod(name); + } + catch (kdlib::TypeException&) + { + } + + std::stringstream sstr; + sstr << '\'' << _bstr_t(typeInfo.getName().c_str()) << '\'' + << " type has no field " << '\'' << _bstr_t(name.c_str()) << '\''; + throw AttributeException(sstr.str().c_str()); + } /////////////////////////////////////////////////////////////////////////////// diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index 251fef7..0624e4f 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -87,7 +87,7 @@ class TypedVarTest( unittest.TestCase ): self.assertEqual( True, tv1.m_field2 ) self.assertEqual( 1, tv1.m_field3 ) self.assertEqual( 1, tv1["m_field3"] ) - self.assertRaises( pykd.SymbolException, lambda t: t.not_exists, tv1) # non-exsisting field + self.assertRaises( AttributeError, lambda t: t.not_exists, tv1) # non-exsisting field self.assertRaises( KeyError, lambda t: t["not_exists"], tv1) # non-exsisting field def testPtrField(self): @@ -439,7 +439,7 @@ class TypedVarTest( unittest.TestCase ): var = target.module.typedVar("structTest", [0x55] * 20 ) setattr(var, "m_field1", 11) self.assertEqual(11, getattr(var, "m_field1")) - self.assertRaises(pykd.SymbolException, lambda x: getattr(x, "noexists"), var) + self.assertRaises(AttributeError, lambda x: getattr(x, "noexists"), var) def testEvalPyScope(self): var = target.module.typedVar("structTest", [0x55] * 20 ) diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index b376b1d..9f661f2 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -42,7 +42,7 @@ class TypeInfoTest( unittest.TestCase ): self.assertTrue( "UInt4B", ti1.m_field0.name() ) self.assertTrue( "m_field0" in ti1 ) self.assertFalse( "not_exist" in ti1) # non-exsisting field - self.assertRaises( pykd.SymbolException, lambda t: t.not_exists, ti1) # non-exsisting field + self.assertRaises( AttributeError, lambda t: t.not_exists, ti1) # non-exsisting field def testBaseTypes( self ): @@ -354,7 +354,7 @@ class TypeInfoTest( unittest.TestCase ): typeProvider = pykd.getTypeInfoProviderFromPdb(pdb) self.assertEqual("structTest", typeProvider.getTypeByName("structTest").name()) self.assertEqual("structTest", typeProvider.structTest.name()) - self.assertEqual(16, len(list(typeProvider.typeIterator("*struct*")))) + self.assertEqual(15, len(list(typeProvider.typeIterator("*struct*")))) def testScopeName(self): self.assertEqual( target.module.name(), pykd.typeInfo( "structTest" ).scopeName() )