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
11    def test_with_run_command(self):
12        """Tests that frame variable looks into anonymous unions"""
13        self.build()
14        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
15
16        line = line_number('main.cpp', '// break here')
17        lldbutil.run_break_set_by_file_and_line(
18            self, "main.cpp", line, num_expected_locations=-1, loc_exact=False)
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