1 """ 2 Test that template instaniations of std::vector<long> and <short> in the same module have the correct types. 3 """ 4 5 import unittest2 6 import lldb 7 import lldbutil 8 from lldbtest import * 9 10 class UniqueTypesTestCase(TestBase): 11 12 mydir = os.path.join("lang", "cpp", "unique-types") 13 14 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 15 @dsym_test 16 def test_with_dsym(self): 17 """Test for unique types of std::vector<long> and std::vector<short>.""" 18 self.buildDsym() 19 self.unique_types() 20 21 @dwarf_test 22 def test_with_dwarf(self): 23 """Test for unique types of std::vector<long> and std::vector<short>.""" 24 self.buildDwarf() 25 self.unique_types() 26 27 def setUp(self): 28 # Call super's setUp(). 29 TestBase.setUp(self) 30 # Find the line number inside main.cpp. 31 self.line = line_number("main.cpp", 32 "// Set breakpoint here to verify that std::vector 'longs' and 'shorts' have unique types.") 33 34 def unique_types(self): 35 """Test for unique types of std::vector<long> and std::vector<short>.""" 36 37 compiler = self.getCompiler() 38 compiler_basename = os.path.basename(compiler) 39 if "clang" in compiler_basename and int(self.getCompilerVersion().split('.')[0]) < 3: 40 self.skipTest("rdar://problem/9173060 lldb hangs while running unique-types for clang version < 3") 41 42 exe = os.path.join(os.getcwd(), "a.out") 43 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 44 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) 45 46 self.runCmd("run", RUN_SUCCEEDED) 47 48 # The stop reason of the thread should be breakpoint. 49 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 50 substrs = ['stopped', 51 'stop reason = breakpoint']) 52 53 # Do a "frame variable --show-types longs" and verify "long" is in each line of output. 54 self.runCmd("frame variable --show-types longs") 55 output = self.res.GetOutput() 56 for x in [line.strip() for line in output.split(os.linesep)]: 57 # Skip empty line, closing brace, and messages about more variables than can be displayed. 58 if not x or x == '}' or x == '...' or "Some of your variables have more members than the debugger will show by default" in x: 59 continue 60 self.expect(x, "Expect type 'long'", exe=False, 61 substrs = ['long']) 62 63 # Do a "frame variable --show-types shorts" and verify "short" is in each line of output. 64 self.runCmd("frame variable --show-types shorts") 65 output = self.res.GetOutput() 66 for x in [line.strip() for line in output.split(os.linesep)]: 67 # Skip empty line, closing brace, and messages about more variables than can be displayed. 68 if not x or x == '}' or x == '...' or "Some of your variables have more members than the debugger will show by default" in x: 69 continue 70 self.expect(x, "Expect type 'short'", exe=False, 71 substrs = ['short']) 72 73 74 if __name__ == '__main__': 75 import atexit 76 lldb.SBDebugger.Initialize() 77 atexit.register(lambda: lldb.SBDebugger.Terminate()) 78 unittest2.main() 79