199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest lldb data formatter subsystem. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprecht 699451b44SJordan Rupprechtimport lldb 799451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 899451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 999451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 1099451b44SJordan Rupprecht 1199451b44SJordan Rupprecht 1299451b44SJordan Rupprechtclass NSArraySyntheticTestCase(TestBase): 1399451b44SJordan Rupprecht def setUp(self): 1499451b44SJordan Rupprecht # Call super's setUp(). 1599451b44SJordan Rupprecht TestBase.setUp(self) 1699451b44SJordan Rupprecht # Find the line number to break at. 17*2238dcc3SJonas Devlieghere self.line = line_number("main.m", "// Set break point at this line.") 1899451b44SJordan Rupprecht 1999451b44SJordan Rupprecht @skipUnlessDarwin 2099451b44SJordan Rupprecht def test_rdar11086338_with_run_command(self): 2199451b44SJordan Rupprecht """Test that NSArray reports its synthetic children properly.""" 2299451b44SJordan Rupprecht self.build() 2399451b44SJordan Rupprecht self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 2499451b44SJordan Rupprecht 2599451b44SJordan Rupprecht lldbutil.run_break_set_by_file_and_line( 26*2238dcc3SJonas Devlieghere self, "main.m", self.line, num_expected_locations=1, loc_exact=True 27*2238dcc3SJonas Devlieghere ) 2899451b44SJordan Rupprecht 2999451b44SJordan Rupprecht self.runCmd("run", RUN_SUCCEEDED) 3099451b44SJordan Rupprecht 3199451b44SJordan Rupprecht # The stop reason of the thread should be breakpoint. 32*2238dcc3SJonas Devlieghere self.expect( 33*2238dcc3SJonas Devlieghere "thread list", 34*2238dcc3SJonas Devlieghere STOPPED_DUE_TO_BREAKPOINT, 35*2238dcc3SJonas Devlieghere substrs=["stopped", "stop reason = breakpoint"], 36*2238dcc3SJonas Devlieghere ) 3799451b44SJordan Rupprecht 3899451b44SJordan Rupprecht # This is the function to remove the custom formats in order to have a 3999451b44SJordan Rupprecht # clean slate for the next test case. 4099451b44SJordan Rupprecht def cleanup(): 41*2238dcc3SJonas Devlieghere self.runCmd("type format clear", check=False) 42*2238dcc3SJonas Devlieghere self.runCmd("type summary clear", check=False) 43*2238dcc3SJonas Devlieghere self.runCmd("type synth clear", check=False) 4499451b44SJordan Rupprecht 4599451b44SJordan Rupprecht # Execute the cleanup function during test case tear down. 4699451b44SJordan Rupprecht self.addTearDownHook(cleanup) 4799451b44SJordan Rupprecht 4899451b44SJordan Rupprecht # Now check that we are displaying Cocoa classes correctly 49*2238dcc3SJonas Devlieghere self.expect("frame variable arr", substrs=['@"6 elements"']) 50*2238dcc3SJonas Devlieghere self.expect("frame variable other_arr", substrs=['@"4 elements"']) 51*2238dcc3SJonas Devlieghere self.expect("frame variable empty_arr", substrs=['@"0 elements"']) 5299451b44SJordan Rupprecht self.expect( 53*2238dcc3SJonas Devlieghere "frame variable arr --ptr-depth 1", 5499451b44SJordan Rupprecht substrs=[ 5599451b44SJordan Rupprecht '@"6 elements"', 56*2238dcc3SJonas Devlieghere "[0] = 0x", 57*2238dcc3SJonas Devlieghere "[1] = 0x", 58*2238dcc3SJonas Devlieghere "[2] = 0x", 59*2238dcc3SJonas Devlieghere "[3] = 0x", 60*2238dcc3SJonas Devlieghere "[4] = 0x", 61*2238dcc3SJonas Devlieghere "[5] = 0x", 62*2238dcc3SJonas Devlieghere ], 63*2238dcc3SJonas Devlieghere ) 6499451b44SJordan Rupprecht self.expect( 65*2238dcc3SJonas Devlieghere "frame variable other_arr --ptr-depth 1", 66*2238dcc3SJonas Devlieghere substrs=['@"4 elements"', "[0] = 0x", "[1] = 0x", "[2] = 0x", "[3] = 0x"], 67*2238dcc3SJonas Devlieghere ) 68*2238dcc3SJonas Devlieghere self.expect("frame variable empty_arr --ptr-depth 1", substrs=['@"0 elements"']) 6999451b44SJordan Rupprecht self.expect( 70*2238dcc3SJonas Devlieghere "frame variable arr --ptr-depth 1", 7199451b44SJordan Rupprecht substrs=[ 7299451b44SJordan Rupprecht '@"6 elements"', 7399451b44SJordan Rupprecht '@"hello"', 7499451b44SJordan Rupprecht '@"world"', 7599451b44SJordan Rupprecht '@"this"', 7699451b44SJordan Rupprecht '@"is"', 7799451b44SJordan Rupprecht '@"me"', 78*2238dcc3SJonas Devlieghere '@"http://www.apple.com', 79*2238dcc3SJonas Devlieghere ], 80*2238dcc3SJonas Devlieghere ) 8199451b44SJordan Rupprecht self.expect( 82*2238dcc3SJonas Devlieghere "frame variable other_arr --ptr-depth 1", 83*2238dcc3SJonas Devlieghere substrs=['@"4 elements"', "(int)5", '@"a string"', '@"6 elements"'], 84*2238dcc3SJonas Devlieghere ) 8599451b44SJordan Rupprecht self.expect( 86*2238dcc3SJonas Devlieghere "frame variable other_arr --ptr-depth 2", 8799451b44SJordan Rupprecht substrs=[ 8899451b44SJordan Rupprecht '@"4 elements"', 8999451b44SJordan Rupprecht '@"6 elements" {', 9099451b44SJordan Rupprecht '@"hello"', 9199451b44SJordan Rupprecht '@"world"', 9299451b44SJordan Rupprecht '@"this"', 9399451b44SJordan Rupprecht '@"is"', 9499451b44SJordan Rupprecht '@"me"', 95*2238dcc3SJonas Devlieghere '@"http://www.apple.com', 96*2238dcc3SJonas Devlieghere ], 97*2238dcc3SJonas Devlieghere ) 9899451b44SJordan Rupprecht 9999451b44SJordan Rupprecht self.assertTrue( 10099451b44SJordan Rupprecht self.frame().FindVariable("arr").MightHaveChildren(), 101*2238dcc3SJonas Devlieghere "arr says it does not have children!", 102*2238dcc3SJonas Devlieghere ) 10399451b44SJordan Rupprecht self.assertTrue( 10499451b44SJordan Rupprecht self.frame().FindVariable("other_arr").MightHaveChildren(), 105*2238dcc3SJonas Devlieghere "arr says it does not have children!", 106*2238dcc3SJonas Devlieghere ) 107b8ff0daeSJonas Devlieghere self.assertFalse( 108b8ff0daeSJonas Devlieghere self.frame().FindVariable("empty_arr").MightHaveChildren(), 109*2238dcc3SJonas Devlieghere "arr says it does have children!", 110*2238dcc3SJonas Devlieghere ) 111