xref: /llvm-project/lldb/test/API/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTests that frame variable looks into anonymous unions
399451b44SJordan Rupprecht"""
499451b44SJordan Rupprechtimport lldb
599451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
699451b44SJordan Rupprechtimport lldbsuite.test.lldbutil as lldbutil
799451b44SJordan Rupprecht
899451b44SJordan Rupprecht
999451b44SJordan Rupprechtclass FrameVariableAnonymousUnionsTestCase(TestBase):
1099451b44SJordan Rupprecht    def test_with_run_command(self):
1199451b44SJordan Rupprecht        """Tests that frame variable looks into anonymous unions"""
1299451b44SJordan Rupprecht        self.build()
1399451b44SJordan Rupprecht        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
1499451b44SJordan Rupprecht
15*2238dcc3SJonas Devlieghere        line = line_number("main.cpp", "// break here")
1699451b44SJordan Rupprecht        lldbutil.run_break_set_by_file_and_line(
17*2238dcc3SJonas Devlieghere            self, "main.cpp", line, num_expected_locations=-1, loc_exact=False
18*2238dcc3SJonas Devlieghere        )
1999451b44SJordan Rupprecht
2099451b44SJordan Rupprecht        self.runCmd("process launch", RUN_SUCCEEDED)
2199451b44SJordan Rupprecht
2299451b44SJordan Rupprecht        process = self.dbg.GetSelectedTarget().GetProcess()
2399451b44SJordan Rupprecht
2499451b44SJordan Rupprecht        if process.GetByteOrder() == lldb.eByteOrderLittle:
25*2238dcc3SJonas Devlieghere            self.expect("frame variable -f x i", substrs=["ffffff41"])
2699451b44SJordan Rupprecht        else:
27*2238dcc3SJonas Devlieghere            self.expect("frame variable -f x i", substrs=["41ffff00"])
2899451b44SJordan Rupprecht
29*2238dcc3SJonas Devlieghere        self.expect("frame variable c", substrs=["'A"])
30