199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest lldb data formatter subsystem. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprecht 699451b44SJordan Rupprechtimport lldb 799451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 899451b44SJordan Rupprechtimport lldbsuite.test.lldbutil as lldbutil 999451b44SJordan Rupprecht 1099451b44SJordan Rupprecht 1199451b44SJordan Rupprechtclass PtrToArrayDataFormatterTestCase(TestBase): 1299451b44SJordan Rupprecht def test_with_run_command(self): 1399451b44SJordan Rupprecht """Test that LLDB handles the clang typeclass Paren correctly.""" 1499451b44SJordan Rupprecht self.build() 1599451b44SJordan Rupprecht self.data_formatter_commands() 1699451b44SJordan Rupprecht 1799451b44SJordan Rupprecht def setUp(self): 1899451b44SJordan Rupprecht # Call super's setUp(). 1999451b44SJordan Rupprecht TestBase.setUp(self) 2099451b44SJordan Rupprecht # Find the line number to break at. 21*2238dcc3SJonas Devlieghere self.line = line_number("main.cpp", "// Set break point at this line.") 2299451b44SJordan Rupprecht 2399451b44SJordan Rupprecht def data_formatter_commands(self): 2499451b44SJordan Rupprecht """Test that LLDB handles the clang typeclass Paren correctly.""" 2599451b44SJordan Rupprecht self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 2699451b44SJordan Rupprecht 2799451b44SJordan Rupprecht lldbutil.run_break_set_by_file_and_line( 28*2238dcc3SJonas Devlieghere self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True 29*2238dcc3SJonas Devlieghere ) 3099451b44SJordan Rupprecht 3199451b44SJordan Rupprecht self.runCmd("run", RUN_SUCCEEDED) 3299451b44SJordan Rupprecht 3399451b44SJordan Rupprecht # The stop reason of the thread should be breakpoint. 34*2238dcc3SJonas Devlieghere self.expect( 35*2238dcc3SJonas Devlieghere "thread list", 36*2238dcc3SJonas Devlieghere STOPPED_DUE_TO_BREAKPOINT, 37*2238dcc3SJonas Devlieghere substrs=["stopped", "stop reason = breakpoint"], 38*2238dcc3SJonas Devlieghere ) 3999451b44SJordan Rupprecht 4099451b44SJordan Rupprecht # This is the function to remove the custom formats in order to have a 4199451b44SJordan Rupprecht # clean slate for the next test case. 4299451b44SJordan Rupprecht def cleanup(): 43*2238dcc3SJonas Devlieghere self.runCmd("type format delete hex", check=False) 44*2238dcc3SJonas Devlieghere self.runCmd("type summary clear", check=False) 4599451b44SJordan Rupprecht 4699451b44SJordan Rupprecht # Execute the cleanup function during test case tear down. 4799451b44SJordan Rupprecht self.addTearDownHook(cleanup) 4899451b44SJordan Rupprecht 49*2238dcc3SJonas Devlieghere self.expect( 50*2238dcc3SJonas Devlieghere "expression *(int (*)[3])foo", 51*2238dcc3SJonas Devlieghere substrs=["(int[3]) $", "[0] = 1", "[1] = 2", "[2] = 3"], 52*2238dcc3SJonas Devlieghere ) 5399451b44SJordan Rupprecht 54*2238dcc3SJonas Devlieghere self.expect( 55*2238dcc3SJonas Devlieghere "expression *(int (*)[3])foo", 56*2238dcc3SJonas Devlieghere matching=False, 57*2238dcc3SJonas Devlieghere substrs=["01 00 00 00 02 00 00 00 03 00 00 00"], 58*2238dcc3SJonas Devlieghere ) 59*2238dcc3SJonas Devlieghere self.expect( 60*2238dcc3SJonas Devlieghere "expression *(int (*)[3])foo", 61*2238dcc3SJonas Devlieghere matching=False, 62*2238dcc3SJonas Devlieghere substrs=["0x000000030000000200000001"], 63*2238dcc3SJonas Devlieghere ) 64