brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 42399bf Raw
67 lines · python
1"""2Make sure if we have two classes with the same base name the3dynamic value calculator doesn't confuse them4"""5 6 7import lldb8import lldbsuite.test.lldbutil as lldbutil9from lldbsuite.test.lldbtest import *10 11 12class DynamicValueSameBaseTestCase(TestBase):13    # If your test case doesn't stress debug info, then14    # set this to true.  That way it won't be run once for15    # each debug info format.16    NO_DEBUG_INFO_TESTCASE = True17 18    def test_same_basename_this(self):19        """Test that the we use the full name to resolve dynamic types."""20        self.build()21        self.main_source_file = lldb.SBFileSpec("main.cpp")22        self.sample_test()23 24    def sample_test(self):25        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(26            self, "Break here to get started", self.main_source_file27        )28 29        # Set breakpoints in the two class methods and run to them:30        namesp_bkpt = target.BreakpointCreateBySourceRegex(31            "namesp function did something.", self.main_source_file32        )33        self.assertEqual(34            namesp_bkpt.GetNumLocations(), 1, "Namespace breakpoint invalid"35        )36 37        virtual_bkpt = target.BreakpointCreateBySourceRegex(38            "Virtual function did something.", self.main_source_file39        )40        self.assertEqual(41            virtual_bkpt.GetNumLocations(), 1, "Virtual breakpoint invalid"42        )43 44        threads = lldbutil.continue_to_breakpoint(process, namesp_bkpt)45        self.assertEqual(len(threads), 1, "Didn't stop at namespace breakpoint")46 47        frame = threads[0].frame[0]48        namesp_this = frame.FindVariable("this", lldb.eDynamicCanRunTarget)49        # Clang specifies the type of this as "T *", gcc as "T * const". This50        # erases the difference.51        namesp_type = namesp_this.GetType().GetUnqualifiedType()52        self.assertEqual(53            namesp_type.GetName(),54            "namesp::Virtual *",55            "Didn't get the right dynamic type",56        )57 58        threads = lldbutil.continue_to_breakpoint(process, virtual_bkpt)59        self.assertEqual(len(threads), 1, "Didn't stop at virtual breakpoint")60 61        frame = threads[0].frame[0]62        virtual_this = frame.FindVariable("this", lldb.eDynamicCanRunTarget)63        virtual_type = virtual_this.GetType().GetUnqualifiedType()64        self.assertEqual(65            virtual_type.GetName(), "Virtual *", "Didn't get the right dynamic type"66        )67