1import lldb
2from lldbsuite.test.decorators import *
3from lldbsuite.test.lldbtest import *
4from lldbsuite.test import lldbutil
5
6class TestCase(TestBase):
7
8    @no_debug_info_test
9    def test(self):
10        self.build()
11        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
12
13        m_val = self.expect_expr("m", result_type="WithMember", result_children=[
14            ValueCheck(name="i", value="1")
15        ])
16        # FIXME: The non-display name doesn't include the function, so users
17        # can't actually match specific classes by their name. Either document
18        # or fix this.
19        self.assertEqual(m_val.GetType().GetName(), "WithMember")
20        # Try accessing the type in the expression evaluator.
21        self.expect_expr("m.i", result_type="int", result_value="1")
22
23        self.expect_expr("typedef_unnamed", result_type="TypedefUnnamed", result_children=[
24            ValueCheck(name="a", value="2")
25        ])
26        self.expect_expr("typedef_unnamed2", result_type="TypedefUnnamed2", result_children=[
27            ValueCheck(name="b", value="3")
28        ])
29        self.expect_expr("unnamed", result_type="(unnamed struct)", result_children=[
30            ValueCheck(name="i", value="4")
31        ])
32        self.expect_expr("unnamed2", result_type="(unnamed struct)", result_children=[
33            ValueCheck(name="j", value="5")
34        ])
35
36        # Try a class that is only forward declared.
37        self.expect_expr("fwd", result_type="Forward *")
38        self.expect("expression -- fwd->i", error=True, substrs=[
39            "member access into incomplete type 'Forward'"
40        ])
41        self.expect("expression -- *fwd", error=True, substrs=[
42            "incomplete type 'Forward' where a complete type is required"
43        ])
44
45        # Try a class that has a name that matches a class in the global scope.
46        self.expect_expr("fwd_conflict", result_type="ForwardConflict *")
47        # FIXME: This pulls in the unrelated type with the same name from the
48        # global scope.
49        self.expect("expression -- fwd_conflict->i", error=True, substrs=[
50            # This should point out that ForwardConflict is incomplete.
51            "no member named 'i' in 'ForwardConflict'"
52        ])
53        self.expect("expression -- *fwd_conflict", error=True, substrs=[
54            # This should fail to parse instead.
55            "couldn't read its memory"
56        ])
57