From e2b5cfd826d486c22148d770406b24d81c7480ad Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Thu, 9 Jun 2011 22:04:56 +0000 Subject: [PATCH] Add rich comparison methods for the SBAddress object. If two SBAddress's have the same module and file address, they are considered equal. Add a test snippet 'sa1 == sa2' to exercise the rich comparison methods for SBAddress. llvm-svn: 132807 --- lldb/scripts/Python/modify-python-lldb.py | 3 ++- lldb/test/python_api/function_symbol/TestDisasmAPI.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py index 4f198c881d14..efd4fb6f5e7e 100644 --- a/lldb/scripts/Python/modify-python-lldb.py +++ b/lldb/scripts/Python/modify-python-lldb.py @@ -88,7 +88,8 @@ d = { 'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'), # # This dictionary defines a mapping from classname to equality method name(s). # -e = { 'SBBreakpoint': ['GetID'], +e = { 'SBAddress': ['GetFileAddress', 'GetModule'], + 'SBBreakpoint': ['GetID'], 'SBFileSpec': ['GetFilename', 'GetDirectory'], 'SBModule': ['GetFileSpec', 'GetUUIDString'] } diff --git a/lldb/test/python_api/function_symbol/TestDisasmAPI.py b/lldb/test/python_api/function_symbol/TestDisasmAPI.py index 1ac0d206650c..e25754961cef 100644 --- a/lldb/test/python_api/function_symbol/TestDisasmAPI.py +++ b/lldb/test/python_api/function_symbol/TestDisasmAPI.py @@ -102,18 +102,23 @@ class DisasmAPITestCase(TestBase): sa1 = symbol.GetStartAddress() #print "sa1:", sa1 + print "sa1.GetFileAddress():", sa1.GetFileAddress() #ea1 = symbol.GetEndAddress() #print "ea1:", ea1 + print "ea1.GetFileAddress():", sa1.GetFileAddress() sa2 = function.GetStartAddress() #print "sa2:", sa2 + print "sa2.GetFileAddress():", sa2.GetFileAddress() #ea2 = function.GetEndAddress() #print "ea2:", ea2 + self.assertTrue(sa1 and sa2 and sa1 == sa2, + "The two starting addresses should be the same") from lldbutil import get_description desc1 = get_description(sa1) desc2 = get_description(sa2) self.assertTrue(desc1 and desc2 and desc1 == desc2, - "The two starting addresses should be the same") + "SBAddress.GetDescription() API of sa1 and sa2 should return the same string") if __name__ == '__main__':