1*99451b44SJordan Rupprecht"""
2*99451b44SJordan RupprechtTest that the expression evaluator can access members of nested classes even if
3*99451b44SJordan Rupprechtthe parents of the nested classes were imported from another compilation unit.
4*99451b44SJordan Rupprecht"""
5*99451b44SJordan Rupprechtimport lldb
6*99451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
7*99451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
8*99451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
9*99451b44SJordan Rupprecht
10*99451b44SJordan Rupprecht
11*99451b44SJordan Rupprechtclass TestNestedClassWithParentInAnotherCU(TestBase):
12*99451b44SJordan Rupprecht
13*99451b44SJordan Rupprecht    def test_nested_class_with_parent_in_another_cu(self):
14*99451b44SJordan Rupprecht        self.main_source_file = lldb.SBFileSpec("main.cpp")
15*99451b44SJordan Rupprecht        self.build()
16*99451b44SJordan Rupprecht        (_, _, thread, _) = lldbutil.run_to_source_breakpoint(self, "// break here", self.main_source_file)
17*99451b44SJordan Rupprecht        frame = thread.GetSelectedFrame()
18*99451b44SJordan Rupprecht        # Parse the DIEs of the parent classes and the nested classes from
19*99451b44SJordan Rupprecht        # other.cpp's CU.
20*99451b44SJordan Rupprecht        warmup_result = frame.EvaluateExpression("b")
21*99451b44SJordan Rupprecht        self.assertTrue(warmup_result.IsValid())
22*99451b44SJordan Rupprecht        # Inspect fields of the nested classes. This will reuse the types that
23*99451b44SJordan Rupprecht        # were parsed during the evaluation above. By accessing a chain of
24*99451b44SJordan Rupprecht        # fields, we try to verify that all the DIEs, reused types and
25*99451b44SJordan Rupprecht        # declaration contexts were wired properly into lldb's parser's state.
26*99451b44SJordan Rupprecht        expr_result = frame.EvaluateExpression("a.y.oY_inner.oX_inner")
27*99451b44SJordan Rupprecht        self.assertTrue(expr_result.IsValid())
28*99451b44SJordan Rupprecht        self.assertEqual(expr_result.GetValue(), "42")
29