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