Commit a447202c authored by ussrhero's avatar ussrhero
Browse files

revert changes for #50

parent c8d153a1
...@@ -91,7 +91,16 @@ struct ModuleAdapter : public kdlib::Module ...@@ -91,7 +91,16 @@ struct ModuleAdapter : public kdlib::Module
catch (kdlib::DbgException&) 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) static python::object getItemByKey(kdlib::Module& module, const std::wstring &symbolName)
...@@ -113,7 +122,7 @@ struct ModuleAdapter : public kdlib::Module ...@@ -113,7 +122,7 @@ struct ModuleAdapter : public kdlib::Module
} }
std::wstringstream sstr; 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()); throw KeyException(std::string(_bstr_t(sstr.str().c_str())).c_str());
} }
......
...@@ -254,7 +254,19 @@ kdlib::TypedVarPtr TypedVarAdapter::getFieldAttr(kdlib::TypedVar& typedVar, cons ...@@ -254,7 +254,19 @@ kdlib::TypedVarPtr TypedVarAdapter::getFieldAttr(kdlib::TypedVar& typedVar, cons
catch (kdlib::TypeException&) 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());
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -273,7 +273,19 @@ kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, co ...@@ -273,7 +273,19 @@ kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, co
catch (kdlib::TypeException&) 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());
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -87,7 +87,7 @@ class TypedVarTest( unittest.TestCase ): ...@@ -87,7 +87,7 @@ class TypedVarTest( unittest.TestCase ):
self.assertEqual( True, tv1.m_field2 ) self.assertEqual( True, tv1.m_field2 )
self.assertEqual( 1, tv1.m_field3 ) self.assertEqual( 1, tv1.m_field3 )
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 self.assertRaises( KeyError, lambda t: t["not_exists"], tv1) # non-exsisting field
def testPtrField(self): def testPtrField(self):
...@@ -439,7 +439,7 @@ class TypedVarTest( unittest.TestCase ): ...@@ -439,7 +439,7 @@ class TypedVarTest( unittest.TestCase ):
var = target.module.typedVar("structTest", [0x55] * 20 ) var = target.module.typedVar("structTest", [0x55] * 20 )
setattr(var, "m_field1", 11) setattr(var, "m_field1", 11)
self.assertEqual(11, getattr(var, "m_field1")) 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): def testEvalPyScope(self):
var = target.module.typedVar("structTest", [0x55] * 20 ) var = target.module.typedVar("structTest", [0x55] * 20 )
......
...@@ -42,7 +42,7 @@ class TypeInfoTest( unittest.TestCase ): ...@@ -42,7 +42,7 @@ class TypeInfoTest( unittest.TestCase ):
self.assertTrue( "UInt4B", ti1.m_field0.name() ) self.assertTrue( "UInt4B", ti1.m_field0.name() )
self.assertTrue( "m_field0" in ti1 ) self.assertTrue( "m_field0" in ti1 )
self.assertFalse( "not_exist" in ti1) # non-exsisting field 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 ): def testBaseTypes( self ):
...@@ -354,7 +354,7 @@ class TypeInfoTest( unittest.TestCase ): ...@@ -354,7 +354,7 @@ class TypeInfoTest( unittest.TestCase ):
typeProvider = pykd.getTypeInfoProviderFromPdb(pdb) typeProvider = pykd.getTypeInfoProviderFromPdb(pdb)
self.assertEqual("structTest", typeProvider.getTypeByName("structTest").name()) self.assertEqual("structTest", typeProvider.getTypeByName("structTest").name())
self.assertEqual("structTest", typeProvider.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): def testScopeName(self):
self.assertEqual( target.module.name(), pykd.typeInfo( "structTest" ).scopeName() ) self.assertEqual( target.module.name(), pykd.typeInfo( "structTest" ).scopeName() )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment