1""" 2Test that variables with unsigned types display correctly. 3""" 4 5import os, time 6import re 7import unittest2 8import lldb 9from lldbtest import * 10import lldbutil 11 12class UnsignedTypesTestCase(TestBase): 13 14 mydir = os.path.join("lang", "cpp", "unsigned_types") 15 16 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 17 @dsym_test 18 def test_with_dsym(self): 19 """Test that variables with unsigned types display correctly.""" 20 self.buildDsym() 21 self.unsigned_types() 22 23 @dwarf_test 24 def test_with_dwarf(self): 25 """Test that variables with unsigned types display correctly.""" 26 self.buildDwarf() 27 self.unsigned_types() 28 29 def setUp(self): 30 # Call super's setUp(). 31 TestBase.setUp(self) 32 # Find the line number to break inside main(). 33 self.line = line_number('main.cpp', '// Set break point at this line.') 34 35 def unsigned_types(self): 36 """Test that variables with unsigned types display correctly.""" 37 exe = os.path.join(os.getcwd(), "a.out") 38 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 39 40 # GCC puts a breakpoint on the last line of a multi-line expression, so 41 # if GCC is the target compiler, we cannot rely on an exact line match. 42 need_exact = "gcc" not in self.getCompiler() 43 # Break on line 19 in main() aftre the variables are assigned values. 44 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=need_exact) 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', 'stop reason = breakpoint']) 51 52 # The breakpoint should have a hit count of 1. 53 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, 54 substrs = [' resolved, hit count = 1']) 55 56 # Test that unsigned types display correctly. 57 self.expect("frame variable --show-types --no-args", VARIABLES_DISPLAYED_CORRECTLY, 58 startstr = "(unsigned char) the_unsigned_char = 'c'", 59 patterns = ["\((short unsigned int|unsigned short)\) the_unsigned_short = 99"], 60 substrs = ["(unsigned int) the_unsigned_int = 99", 61 "(unsigned long) the_unsigned_long = 99", 62 "(unsigned long long) the_unsigned_long_long = 99", 63 "(uint32_t) the_uint32 = 99"]) 64 65 66if __name__ == '__main__': 67 import atexit 68 lldb.SBDebugger.Initialize() 69 atexit.register(lambda: lldb.SBDebugger.Terminate()) 70 unittest2.main() 71