|
| 1 | +"""Show bitfields and check that they display correctly.""" |
| 2 | + |
| 3 | +import lldb |
| 4 | +from lldbsuite.test.decorators import * |
| 5 | +from lldbsuite.test.lldbtest import * |
| 6 | +from lldbsuite.test import lldbutil |
| 7 | + |
| 8 | + |
| 9 | +class CppBitfieldsTestCase(TestBase): |
| 10 | + |
| 11 | + mydir = TestBase.compute_mydir(__file__) |
| 12 | + |
| 13 | + def setUp(self): |
| 14 | + # Call super's setUp(). |
| 15 | + TestBase.setUp(self) |
| 16 | + # Find the line number to break inside main(). |
| 17 | + self.line = line_number('main.cpp', '// Set break point at this line.') |
| 18 | + |
| 19 | + # BitFields exhibit crashes in record layout on Windows |
| 20 | + # (http://llvm.org/pr21800) |
| 21 | + @skipIfWindows |
| 22 | + def test_and_run_command(self): |
| 23 | + """Test 'frame variable ...' on a variable with bitfields.""" |
| 24 | + self.build() |
| 25 | + |
| 26 | + lldbutil.run_to_source_breakpoint(self, '// Set break point at this line.', |
| 27 | + lldb.SBFileSpec("main.cpp", False)) |
| 28 | + |
| 29 | + # The stop reason of the thread should be breakpoint. |
| 30 | + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 31 | + substrs=['stopped', |
| 32 | + 'stop reason = breakpoint']) |
| 33 | + |
| 34 | + # The breakpoint should have a hit count of 1. |
| 35 | + self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, |
| 36 | + substrs=[' resolved, hit count = 1']) |
| 37 | + |
| 38 | + self.expect("expr (lba.a)", VARIABLES_DISPLAYED_CORRECTLY, |
| 39 | + substrs=['unsigned int', '2']) |
| 40 | + self.expect("expr (lbb.b)", VARIABLES_DISPLAYED_CORRECTLY, |
| 41 | + substrs=['unsigned int', '3']) |
| 42 | + self.expect("expr (lbc.c)", VARIABLES_DISPLAYED_CORRECTLY, |
| 43 | + substrs=['unsigned int', '4']) |
| 44 | + self.expect("expr (lbd.a)", VARIABLES_DISPLAYED_CORRECTLY, |
| 45 | + substrs=['unsigned int', '5']) |
| 46 | + self.expect("expr (clang_example.f.a)", VARIABLES_DISPLAYED_CORRECTLY, |
| 47 | + substrs=['uint64_t', '1']) |
| 48 | + |
| 49 | + self.expect( |
| 50 | + "frame variable --show-types lba", |
| 51 | + VARIABLES_DISPLAYED_CORRECTLY, |
| 52 | + substrs=[ |
| 53 | + '(int:32) = ', |
| 54 | + '(unsigned int:20) a = 2', |
| 55 | + ]) |
| 56 | + |
| 57 | + self.expect( |
| 58 | + "frame variable --show-types lbb", |
| 59 | + VARIABLES_DISPLAYED_CORRECTLY, |
| 60 | + substrs=[ |
| 61 | + '(unsigned int:1) a = 1', |
| 62 | + '(int:31) =', |
| 63 | + '(unsigned int:20) b = 3', |
| 64 | + ]) |
| 65 | + |
| 66 | + self.expect( |
| 67 | + "frame variable --show-types lbc", |
| 68 | + VARIABLES_DISPLAYED_CORRECTLY, |
| 69 | + substrs=[ |
| 70 | + '(int:22) =', |
| 71 | + '(unsigned int:1) a = 1', |
| 72 | + '(unsigned int:1) b = 0', |
| 73 | + '(unsigned int:5) c = 4', |
| 74 | + '(unsigned int:1) d = 1', |
| 75 | + '(int:2) =', |
| 76 | + '(unsigned int:20) e = 20', |
| 77 | + ]) |
| 78 | + |
| 79 | + self.expect( |
| 80 | + "frame variable --show-types lbd", |
| 81 | + VARIABLES_DISPLAYED_CORRECTLY, |
| 82 | + substrs=[ |
| 83 | + '(char [3]) arr = "abc"', |
| 84 | + '(int:32) =', |
| 85 | + '(unsigned int:20) a = 5', |
| 86 | + ]) |
| 87 | + |
| 88 | + self.expect( |
| 89 | + "frame variable --show-types clang_example", |
| 90 | + VARIABLES_DISPLAYED_CORRECTLY, |
| 91 | + substrs=[ |
| 92 | + '(int:22) =', |
| 93 | + '(uint64_t:1) a = 1', |
| 94 | + '(uint64_t:1) b = 0', |
| 95 | + '(uint64_t:1) c = 1', |
| 96 | + '(uint64_t:1) d = 0', |
| 97 | + '(uint64_t:1) e = 1', |
| 98 | + '(uint64_t:1) f = 0', |
| 99 | + '(uint64_t:1) g = 1', |
| 100 | + '(uint64_t:1) h = 0', |
| 101 | + '(uint64_t:1) i = 1', |
| 102 | + '(uint64_t:1) j = 0', |
| 103 | + '(uint64_t:1) k = 1', |
| 104 | + ]) |
| 105 | + |
0 commit comments