1""" 2Test lldb data formatter subsystem. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class PyObjectSynthProviderTestCase(TestBase): 14 NO_DEBUG_INFO_TESTCASE = True 15 16 def test_print_array(self): 17 """Test that expr -Z works""" 18 self.build() 19 self.provider_data_formatter_commands() 20 21 def setUp(self): 22 # Call super's setUp(). 23 TestBase.setUp(self) 24 # Find the line number to break at. 25 self.line = line_number('main.cpp', 'break here') 26 27 def provider_data_formatter_commands(self): 28 """Test that the PythonObjectSyntheticChildProvider helper class works""" 29 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 30 31 lldbutil.run_break_set_by_file_and_line( 32 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 33 34 self.runCmd("run", RUN_SUCCEEDED) 35 36 # The stop reason of the thread should be breakpoint. 37 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 38 substrs=['stopped', 39 'stop reason = breakpoint']) 40 41 # This is the function to remove the custom formats in order to have a 42 # clean slate for the next test case. 43 def cleanup(): 44 self.runCmd('type format clear', check=False) 45 self.runCmd('type summary clear', check=False) 46 self.runCmd('type synth clear', check=False) 47 48 # Execute the cleanup function during test case tear down. 49 self.addTearDownHook(cleanup) 50 51 self.runCmd('command script import provider.py') 52 self.runCmd( 53 'type synthetic add Foo --python-class provider.SyntheticChildrenProvider') 54 self.expect('frame variable f.Name', substrs=['"Enrico"']) 55 self.expect( 56 'frame variable f', 57 substrs=[ 58 'ID = 123456', 59 'Name = "Enrico"', 60 'Rate = 1.25']) 61 self.expect( 62 'expression f', 63 substrs=[ 64 'ID = 123456', 65 'Name = "Enrico"', 66 'Rate = 1.25']) 67