2 Make sure if we have two classes with the same base name the
3 dynamic value calculator doesn't confuse them
9 import lldbsuite.test.lldbutil as lldbutil
10 from lldbsuite.test.lldbtest import *
13 class DynamicValueSameBaseTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
17 # If your test case doesn't stress debug info, the
18 # set this to true. That way it won't be run once for
19 # each debug info format.
20 NO_DEBUG_INFO_TESTCASE = True
22 def test_same_basename_this(self):
23 """Test that the we use the full name to resolve dynamic types."""
25 self.main_source_file = lldb.SBFileSpec("main.cpp")
28 def sample_test(self):
29 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
30 "Break here to get started", self.main_source_file)
32 # Set breakpoints in the two class methods and run to them:
33 namesp_bkpt = target.BreakpointCreateBySourceRegex("namesp function did something.", self.main_source_file)
34 self.assertEqual(namesp_bkpt.GetNumLocations(), 1, "Namespace breakpoint invalid")
36 virtual_bkpt = target.BreakpointCreateBySourceRegex("Virtual function did something.", self.main_source_file)
37 self.assertEqual(virtual_bkpt.GetNumLocations(), 1, "Virtual breakpoint invalid")
39 threads = lldbutil.continue_to_breakpoint(process, namesp_bkpt)
40 self.assertEqual(len(threads), 1, "Didn't stop at namespace breakpoint")
42 frame = threads[0].frame[0]
43 namesp_this = frame.FindVariable("this", lldb.eDynamicCanRunTarget)
44 # Clang specifies the type of this as "T *", gcc as "T * const". This
45 # erases the difference.
46 namesp_type = namesp_this.GetType().GetUnqualifiedType()
47 self.assertEqual(namesp_type.GetName(), "namesp::Virtual *", "Didn't get the right dynamic type")
49 threads = lldbutil.continue_to_breakpoint(process, virtual_bkpt)
50 self.assertEqual(len(threads), 1, "Didn't stop at virtual breakpoint")
52 frame = threads[0].frame[0]
53 virtual_this = frame.FindVariable("this", lldb.eDynamicCanRunTarget)
54 virtual_type = virtual_this.GetType().GetUnqualifiedType()
55 self.assertEqual(virtual_type.GetName(), "Virtual *", "Didn't get the right dynamic type")