]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/TestDynamicValueSameBase.py
Vendor import of lldb trunk r338536:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / dynamic-value-same-basename / TestDynamicValueSameBase.py
1 """
2 Make sure if we have two classes with the same base name the
3 dynamic value calculator doesn't confuse them
4 """
5
6 from __future__ import print_function
7
8
9 import os
10 import time
11 import re
12 import lldb
13 import lldbsuite.test.lldbutil as lldbutil
14 from lldbsuite.test.lldbtest import *
15
16
17 class DynamicValueSameBaseTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
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
25
26     def test_same_basename_this(self):
27         """Test that the we use the full name to resolve dynamic types."""
28         self.build()
29         self.main_source_file = lldb.SBFileSpec("main.cpp")
30         self.sample_test()
31
32     def setUp(self):
33         # Call super's setUp().
34         TestBase.setUp(self)
35
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)
39
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")
43
44         virtual_bkpt = target.BreakpointCreateBySourceRegex("Virtual function did something.", self.main_source_file)
45         self.assertEqual(virtual_bkpt.GetNumLocations(), 1, "Virtual breakpoint invalid")
46
47         threads = lldbutil.continue_to_breakpoint(process, namesp_bkpt)
48         self.assertEqual(len(threads), 1, "Didn't stop at namespace breakpoint")
49
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")
56
57         threads = lldbutil.continue_to_breakpoint(process, virtual_bkpt)
58         self.assertEqual(len(threads), 1, "Didn't stop at virtual breakpoint")
59
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")
64
65
66