[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / lang / cpp / diamond / TestCppDiamond.py
blob49a4740d0caf0773a86bdefbfbf429c33dbdf02e
1 """
2 Test diamond inheritance.
3 """
5 import lldb
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test.decorators import *
8 import lldbsuite.test.lldbutil as lldbutil
11 class TestCase(TestBase):
12 @no_debug_info_test
13 def test_with_sbvalue(self):
14 """
15 Test that virtual base classes work in when SBValue objects are
16 used to explore the class.
17 """
18 self.build()
19 lldbutil.run_to_source_breakpoint(
20 self, "// breakpoint 1", lldb.SBFileSpec("main.cpp")
23 self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
25 j1 = self.frame().FindVariable("j1")
26 j1_Derived1 = j1.GetChildAtIndex(0)
27 j1_Derived2 = j1.GetChildAtIndex(1)
28 j1_Derived1_VBase = j1_Derived1.GetChildAtIndex(0)
29 j1_Derived2_VBase = j1_Derived2.GetChildAtIndex(0)
30 j1_Derived1_VBase_m_value = j1_Derived1_VBase.GetChildAtIndex(0)
31 j1_Derived2_VBase_m_value = j1_Derived2_VBase.GetChildAtIndex(0)
33 self.assertEqual(
34 j1_Derived1_VBase.GetLoadAddress(),
35 j1_Derived2_VBase.GetLoadAddress(),
36 "ensure virtual base class is the same between Derived1 and Derived2",
38 self.assertEqual(
39 j1_Derived1_VBase_m_value.GetValueAsUnsigned(1),
40 j1_Derived2_VBase_m_value.GetValueAsUnsigned(2),
41 "ensure m_value in VBase is the same",
43 self.assertEqual(
44 self.frame()
45 .FindVariable("d")
46 .GetChildAtIndex(0)
47 .GetChildAtIndex(0)
48 .GetValueAsUnsigned(0),
49 12345,
50 "ensure Derived2 from j1 is correct",
53 # This reassigns 'd' to point to 'j2'.
54 self.thread().StepOver()
56 self.assertEqual(
57 self.frame()
58 .FindVariable("d")
59 .GetChildAtIndex(0)
60 .GetChildAtIndex(0)
61 .GetValueAsUnsigned(0),
62 12346,
63 "ensure Derived2 from j2 is correct",
66 @no_debug_info_test
67 def test(self):
68 self.build()
69 lldbutil.run_to_source_breakpoint(
70 self, "// breakpoint 1", lldb.SBFileSpec("main.cpp")
73 # All the children of j1.
74 children = [
75 ValueCheck(
76 type="Derived1",
77 children=[
78 ValueCheck(
79 type="VBase",
80 children=[
81 ValueCheck(type="int", name="m_value", value="12345")
86 ValueCheck(
87 type="Derived2",
88 children=[
89 ValueCheck(
90 type="VBase",
91 children=[
92 ValueCheck(type="int", name="m_value", value="12345")
97 ValueCheck(type="long", value="1"),
99 # Try using the class with expression evaluator/variable paths.
100 self.expect_expr("j1", result_type="Joiner1", result_children=children)
101 self.expect_var_path("j1", type="Joiner1", children=children)
103 # Use the expression evaluator to access the members.
104 self.expect_expr("j1.x", result_type="long", result_value="1")
105 self.expect_expr("j1.m_value", result_type="int", result_value="12345")
107 # Use variable paths to access the members.
108 self.expect_var_path("j1.x", type="long", value="1")
110 @expectedFailureAll
111 @no_debug_info_test
112 def test(self):
113 self.build()
114 lldbutil.run_to_source_breakpoint(
115 self, "// breakpoint 1", lldb.SBFileSpec("main.cpp")
117 # FIXME: This is completely broken and 'succeeds' with an error that
118 # there is noch such value/member in Joiner1. Move this up to the test
119 # above when fixed.
120 self.expect_var_path("j1.m_value", type="int", value="12345")