Changeset View
Changeset View
Standalone View
Standalone View
lldb/test/API/functionalities/var_path/TestVarPath.py
Show All 19 Lines | class TestVarPath(TestBase): | ||||
def test_frame_var(self): | def test_frame_var(self): | ||||
self.build() | self.build() | ||||
self.do_test() | self.do_test() | ||||
def verify_point(self, frame, var_name, var_typename, x_value, y_value): | def verify_point(self, frame, var_name, var_typename, x_value, y_value): | ||||
v = frame.GetValueForVariablePath(var_name) | v = frame.GetValueForVariablePath(var_name) | ||||
self.assertTrue(v.GetError().Success(), "Make sure we find '%s'" % (var_name)) | self.assertTrue(v.GetError().Success(), "Make sure we find '%s'" % (var_name)) | ||||
self.assertEquals(v.GetType().GetName(), var_typename, | self.assertEquals(v.GetType().GetName(), var_typename, | ||||
"Make sure '%s' has type '%s'" % (var_name, var_typename)) | "Make sure '%s' has type '%s'" % (var_name, var_typename)) | ||||
if '*' in var_typename: | if '*' in var_typename: | ||||
valid_prefix = var_name + '->' | valid_prefix = var_name + '->' | ||||
invalid_prefix = var_name + '.' | invalid_prefix = var_name + '.' | ||||
else: | else: | ||||
valid_prefix = var_name + '.' | valid_prefix = var_name + '.' | ||||
invalid_prefix = var_name + '->' | invalid_prefix = var_name + '->' | ||||
Show All 34 Lines | def do_test(self): | ||||
# Test a pointer | # Test a pointer | ||||
self.verify_point(frame, 'pt_ptr', 'Point *', 3030, 4040) | self.verify_point(frame, 'pt_ptr', 'Point *', 3030, 4040) | ||||
# Test using a pointer as an array | # Test using a pointer as an array | ||||
self.verify_point(frame, 'pt_ptr[-1]', 'Point', 1010, 2020) | self.verify_point(frame, 'pt_ptr[-1]', 'Point', 1010, 2020) | ||||
self.verify_point(frame, 'pt_ptr[0]', 'Point', 3030, 4040) | self.verify_point(frame, 'pt_ptr[0]', 'Point', 3030, 4040) | ||||
self.verify_point(frame, 'pt_ptr[1]', 'Point', 5050, 6060) | self.verify_point(frame, 'pt_ptr[1]', 'Point', 5050, 6060) | ||||
# Test arrays | # Test arrays | ||||
v = frame.GetValueForVariablePath('points') | v = frame.GetValueForVariablePath('points') | ||||
self.assertTrue(v.GetError().Success(), | self.assertTrue(v.GetError().Success(), | ||||
"Make sure we find 'points'") | "Make sure we find 'points'") | ||||
self.verify_point(frame, 'points[0]', 'Point', 1010, 2020) | self.verify_point(frame, 'points[0]', 'Point', 1010, 2020) | ||||
self.verify_point(frame, 'points[1]', 'Point', 3030, 4040) | self.verify_point(frame, 'points[1]', 'Point', 3030, 4040) | ||||
self.verify_point(frame, 'points[2]', 'Point', 5050, 6060) | self.verify_point(frame, 'points[2]', 'Point', 5050, 6060) | ||||
v = frame.GetValueForVariablePath('points[0]+5') | |||||
self.assertTrue(v.GetError().Fail(), | |||||
"Make sure we do not ignore characters between ']' and the end") | |||||
# Test a reference | # Test a reference | ||||
self.verify_point(frame, 'pt_ref', 'Point &', 1, 2) | self.verify_point(frame, 'pt_ref', 'Point &', 1, 2) | ||||
v = frame.GetValueForVariablePath('pt_sp') | v = frame.GetValueForVariablePath('pt_sp') | ||||
self.assertTrue(v.GetError().Success(), "Make sure we find 'pt_sp'") | self.assertTrue(v.GetError().Success(), "Make sure we find 'pt_sp'") | ||||
# Make sure we don't crash when looking for non existant child | # Make sure we don't crash when looking for non existant child | ||||
# in type with synthetic children. This used to cause a crash. | # in type with synthetic children. This used to cause a crash. | ||||
v = frame.GetValueForVariablePath('pt_sp->not_valid_child') | v = frame.GetValueForVariablePath('pt_sp->not_valid_child') | ||||
self.assertTrue(v.GetError().Fail(), | self.assertTrue(v.GetError().Fail(), | ||||
"Make sure we don't find 'pt_sp->not_valid_child'") | "Make sure we don't find 'pt_sp->not_valid_child'") | ||||