19400432fca9e7404efc4de94c4022a13394018e0Johnny Chen""" 29400432fca9e7404efc4de94c4022a13394018e0Johnny ChenRegression test for <rdar://problem/8981098>: 39400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 49400432fca9e7404efc4de94c4022a13394018e0Johnny ChenThe expression parser's type search only looks in the current compilation unit for types. 59400432fca9e7404efc4de94c4022a13394018e0Johnny Chen""" 69400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 79400432fca9e7404efc4de94c4022a13394018e0Johnny Chenimport unittest2 89400432fca9e7404efc4de94c4022a13394018e0Johnny Chenimport lldb 99400432fca9e7404efc4de94c4022a13394018e0Johnny Chenfrom lldbtest import * 10431d839a33e9a274e705f7a268a1c9de2ffc2da2Jim Inghamimport lldbutil 119400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 129400432fca9e7404efc4de94c4022a13394018e0Johnny Chenclass ObjCTypeQueryTestCase(TestBase): 139400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 149400432fca9e7404efc4de94c4022a13394018e0Johnny Chen mydir = os.path.join("expression_command", "two-files") 159400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 169400432fca9e7404efc4de94c4022a13394018e0Johnny Chen def setUp(self): 179400432fca9e7404efc4de94c4022a13394018e0Johnny Chen # Call super's setUp(). 189400432fca9e7404efc4de94c4022a13394018e0Johnny Chen TestBase.setUp(self) 19e15cf29be30f7222c7f9ef1184d750128a9acce7Johnny Chen # Find the line number to break for main.m. 20e15cf29be30f7222c7f9ef1184d750128a9acce7Johnny Chen self.line = line_number('main.m', 219400432fca9e7404efc4de94c4022a13394018e0Johnny Chen "// Set breakpoint here, then do 'expr (NSArray*)array_token'.") 229400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 239400432fca9e7404efc4de94c4022a13394018e0Johnny Chen @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 24a3ed7d834b0e0c6924ac95629e740682bbcd15baJohnny Chen @dsym_test 259400432fca9e7404efc4de94c4022a13394018e0Johnny Chen def test_with_dsym(self): 269400432fca9e7404efc4de94c4022a13394018e0Johnny Chen """The expression parser's type search should be wider than the current compilation unit.""" 279400432fca9e7404efc4de94c4022a13394018e0Johnny Chen self.buildDsym() 289400432fca9e7404efc4de94c4022a13394018e0Johnny Chen self.type_query_from_other_cu() 299400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 3046a645f8194b19c83345ed20cfdcf583dac9755bDaniel Malea @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 31a3ed7d834b0e0c6924ac95629e740682bbcd15baJohnny Chen @dwarf_test 329400432fca9e7404efc4de94c4022a13394018e0Johnny Chen def test_with_dwarf(self): 339400432fca9e7404efc4de94c4022a13394018e0Johnny Chen """The expression parser's type search should be wider than the current compilation unit.""" 349400432fca9e7404efc4de94c4022a13394018e0Johnny Chen self.buildDwarf() 359400432fca9e7404efc4de94c4022a13394018e0Johnny Chen self.type_query_from_other_cu() 369400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 379400432fca9e7404efc4de94c4022a13394018e0Johnny Chen def type_query_from_other_cu(self): 389400432fca9e7404efc4de94c4022a13394018e0Johnny Chen """The expression parser's type search should be wider than the current compilation unit.""" 399400432fca9e7404efc4de94c4022a13394018e0Johnny Chen self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) 409400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 41431d839a33e9a274e705f7a268a1c9de2ffc2da2Jim Ingham lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) 429400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 439400432fca9e7404efc4de94c4022a13394018e0Johnny Chen self.runCmd("run", RUN_SUCCEEDED) 449400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 45e15cf29be30f7222c7f9ef1184d750128a9acce7Johnny Chen # Now do a NSArry type query from the 'main.m' compile uint. 469400432fca9e7404efc4de94c4022a13394018e0Johnny Chen self.expect("expression (NSArray*)array_token", 47c77306044339c1b375c112ae5fd2911e2b9e33bbJohnny Chen substrs = ['(NSArray *) $0 = 0x']) 489400432fca9e7404efc4de94c4022a13394018e0Johnny Chen # (NSArray *) $0 = 0x00007fff70118398 499400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 509400432fca9e7404efc4de94c4022a13394018e0Johnny Chen 519400432fca9e7404efc4de94c4022a13394018e0Johnny Chenif __name__ == '__main__': 529400432fca9e7404efc4de94c4022a13394018e0Johnny Chen import atexit 539400432fca9e7404efc4de94c4022a13394018e0Johnny Chen lldb.SBDebugger.Initialize() 549400432fca9e7404efc4de94c4022a13394018e0Johnny Chen atexit.register(lambda: lldb.SBDebugger.Terminate()) 559400432fca9e7404efc4de94c4022a13394018e0Johnny Chen unittest2.main() 56