1# coding=utf8 2""" 3Test that the C++11 support for char16_t and char32_t works correctly. 4""" 5 6 7 8import lldb 9from lldbsuite.test.decorators import * 10from lldbsuite.test.lldbtest import * 11from lldbsuite.test import lldbutil 12 13 14class Char1632TestCase(TestBase): 15 16 mydir = TestBase.compute_mydir(__file__) 17 18 def setUp(self): 19 # Call super's setUp(). 20 TestBase.setUp(self) 21 # Find the line number to break for main.cpp. 22 self.source = 'main.cpp' 23 self.lines = [line_number(self.source, '// breakpoint1'), 24 line_number(self.source, '// breakpoint2')] 25 26 @expectedFailureAll( 27 compiler="icc", 28 bugnumber="ICC (13.1) does not emit the DW_TAG_base_type for char16_t and char32_t.") 29 def test(self): 30 """Test that the C++11 support for char16_t and char32_t works correctly.""" 31 self.build() 32 exe = self.getBuildArtifact("a.out") 33 34 # Create a target by the debugger. 35 target = self.dbg.CreateTarget(exe) 36 self.assertTrue(target, VALID_TARGET) 37 38 # Set breakpoints 39 for line in self.lines: 40 lldbutil.run_break_set_by_file_and_line(self, "main.cpp", line) 41 42 # Now launch the process, and do not stop at entry point and stop at 43 # breakpoint1 44 process = target.LaunchSimple( 45 None, None, self.get_process_working_directory()) 46 47 if not process: 48 self.fail("SBTarget.Launch() failed") 49 50 if self.TraceOn(): 51 self.runCmd("frame variable") 52 53 # Check that we correctly report the const types 54 self.expect( 55 "frame variable cs16 cs32", 56 substrs=[ 57 '(const char16_t *) cs16 = ', 58 'u"hello world ྒྙྐ"', 59 '(const char32_t *) cs32 = ', 60 'U"hello world ྒྙྐ"']) 61 62 # Check that we correctly report the non-const types 63 self.expect( 64 "frame variable s16 s32", 65 substrs=[ 66 '(char16_t *) s16 = ', 67 'u"ﺸﺵۻ"', 68 '(char32_t *) s32 = ', 69 'U"ЕЙРГЖО"']) 70 71 # Check that we correctly report the array types 72 self.expect( 73 "frame variable as16 as32", 74 patterns=[ 75 '\(char16_t\[[0-9]+\]\) as16 = ', 76 '\(char32_t\[[0-9]+\]\) as32 = '], 77 substrs=[ 78 'u"ﺸﺵۻ"', 79 'U"ЕЙРГЖО"']) 80 81 self.runCmd("next") # step to after the string is nullified 82 83 # check that we don't crash on NULL 84 self.expect("frame variable s32", 85 substrs=['(char32_t *) s32 = 0x00000000']) 86 87 # continue and hit breakpoint2 88 self.runCmd("continue") 89 90 # check that the new strings show 91 self.expect( 92 "frame variable s16 s32", 93 substrs=[ 94 '(char16_t *) s16 = 0x', 95 '"色ハ匂ヘト散リヌルヲ"', 96 '(char32_t *) s32 = ', 97 '"෴"']) 98 99 # check the same as above for arrays 100 self.expect( 101 "frame variable as16 as32", 102 patterns=[ 103 '\(char16_t\[[0-9]+\]\) as16 = ', 104 '\(char32_t\[[0-9]+\]\) as32 = '], 105 substrs=[ 106 '"色ハ匂ヘト散リヌルヲ"', 107 '"෴"']) 108 109 # check that zero values are properly handles 110 self.expect_expr('cs16_zero', result_summary="U+0000 u'\\0'") 111 self.expect_expr('cs32_zero', result_summary="U+0x00000000 U'\\0'") 112 113 # Check that we can run expressions that return charN_t 114 self.expect_expr("u'a'", result_type="char16_t", result_summary="U+0061 u'a'") 115 self.expect_expr("U'a'", result_type="char32_t", result_summary="U+0x00000061 U'a'") 116