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