xref: /llvm-project/lldb/test/API/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Tests that frame variable looks into anonymous unions
3"""
4import lldb
5from lldbsuite.test.lldbtest import *
6import lldbsuite.test.lldbutil as lldbutil
7
8
9class FrameVariableAnonymousUnionsTestCase(TestBase):
10    def test_with_run_command(self):
11        """Tests that frame variable looks into anonymous unions"""
12        self.build()
13        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
14
15        line = line_number("main.cpp", "// break here")
16        lldbutil.run_break_set_by_file_and_line(
17            self, "main.cpp", line, num_expected_locations=-1, loc_exact=False
18        )
19
20        self.runCmd("process launch", RUN_SUCCEEDED)
21
22        process = self.dbg.GetSelectedTarget().GetProcess()
23
24        if process.GetByteOrder() == lldb.eByteOrderLittle:
25            self.expect("frame variable -f x i", substrs=["ffffff41"])
26        else:
27            self.expect("frame variable -f x i", substrs=["41ffff00"])
28
29        self.expect("frame variable c", substrs=["'A"])
30