Revert "[LoongArch] Eliminate the redundant sign extension of division (#107971)"
[llvm-project.git] / lldb / test / API / python_api / formatters / synth.py
blob91afb26af843613cfd5210a0fed9bd8088cd63e0
1 import lldb
4 class jasSynthProvider:
5 def __init__(self, valobj, dict):
6 self.valobj = valobj
8 def num_children(self):
9 return 2
11 def get_child_at_index(self, index):
12 child = None
13 if index == 0:
14 child = self.valobj.GetChildMemberWithName("A")
15 if index == 1:
16 child = self.valobj.CreateValueFromExpression("X", "(int)1")
17 return child
19 def get_child_index(self, name):
20 if name == "A":
21 return 0
22 if name == "X":
23 return 1
24 return None
27 def ccc_summary(sbvalue, internal_dict):
28 sbvalue = sbvalue.GetNonSyntheticValue()
29 # This tests that the SBValue.GetNonSyntheticValue() actually returns a
30 # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a")
31 # in the following statement will call the 'get_child_index' method of the
32 # synthetic child provider CCCSynthProvider below (which return the "b" field").
33 return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a"))
36 def ccc_synthetic(sbvalue, internal_dict):
37 sbvalue = sbvalue.GetSyntheticValue()
38 # This tests that the SBValue.GetSyntheticValue() actually returns a
39 # synthetic value. If it does, then sbvalue.GetChildMemberWithName("a")
40 # in the following statement will call the 'get_child_index' method of the
41 # synthetic child provider CCCSynthProvider below (which return the "b" field").
42 return "CCC object with leading synthetic value " + str(
43 sbvalue.GetChildMemberWithName("a")
47 def bar_int_synthetic(sbvalue, internal_dict):
48 sbvalue = sbvalue.GetSyntheticValue()
49 # This tests that the SBValue.GetSyntheticValue() actually returns no
50 # value when the value has no synthetic representation.
51 return "bar_int synthetic: " + str(sbvalue)
54 class CCCSynthProvider(object):
55 def __init__(self, sbvalue, internal_dict):
56 self._sbvalue = sbvalue
58 def num_children(self):
59 return 3
61 def get_child_index(self, name):
62 if name == "a":
63 # Return b for test.
64 return 1
65 raise RuntimeError("I don't want to be called!")
67 def get_child_at_index(self, index):
68 if index == 0:
69 return self._sbvalue.GetChildMemberWithName("a")
70 if index == 1:
71 return self._sbvalue.GetChildMemberWithName("b")
72 if index == 2:
73 return self._sbvalue.GetChildMemberWithName("c")
76 def empty1_summary(sbvalue, internal_dict):
77 return "I am an empty Empty1"
80 class Empty1SynthProvider(object):
81 def __init__(self, sbvalue, internal_dict):
82 self._sbvalue = sbvalue
84 def num_children(self):
85 return 0
87 def get_child_at_index(self, index):
88 return None
91 def empty2_summary(sbvalue, internal_dict):
92 return "I am an empty Empty2"
95 class Empty2SynthProvider(object):
96 def __init__(self, sbvalue, internal_dict):
97 self._sbvalue = sbvalue
99 def num_children(self):
100 return 0
102 def get_child_at_index(self, index):
103 return None
106 def __lldb_init_module(debugger, dict):
107 debugger.CreateCategory("JASSynth").AddTypeSynthetic(
108 lldb.SBTypeNameSpecifier("JustAStruct"),
109 lldb.SBTypeSynthetic.CreateWithClassName("synth.jasSynthProvider"),
111 cat = debugger.CreateCategory("CCCSynth")
112 cat.AddTypeSynthetic(
113 lldb.SBTypeNameSpecifier("CCC"),
114 lldb.SBTypeSynthetic.CreateWithClassName(
115 "synth.CCCSynthProvider", lldb.eTypeOptionCascade
118 cat.AddTypeSummary(
119 lldb.SBTypeNameSpecifier("CCC"),
120 lldb.SBTypeSummary.CreateWithFunctionName(
121 "synth.ccc_summary", lldb.eTypeOptionCascade
124 cat.AddTypeSynthetic(
125 lldb.SBTypeNameSpecifier("Empty1"),
126 lldb.SBTypeSynthetic.CreateWithClassName("synth.Empty1SynthProvider"),
128 cat.AddTypeSummary(
129 lldb.SBTypeNameSpecifier("Empty1"),
130 lldb.SBTypeSummary.CreateWithFunctionName("synth.empty1_summary"),
132 cat.AddTypeSynthetic(
133 lldb.SBTypeNameSpecifier("Empty2"),
134 lldb.SBTypeSynthetic.CreateWithClassName("synth.Empty2SynthProvider"),
136 cat.AddTypeSummary(
137 lldb.SBTypeNameSpecifier("Empty2"),
138 lldb.SBTypeSummary.CreateWithFunctionName(
139 "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates
142 cat2 = debugger.CreateCategory("CCCSynth2")
143 cat2.AddTypeSynthetic(
144 lldb.SBTypeNameSpecifier("CCC"),
145 lldb.SBTypeSynthetic.CreateWithClassName(
146 "synth.CCCSynthProvider", lldb.eTypeOptionCascade
149 cat2.AddTypeSummary(
150 lldb.SBTypeNameSpecifier("CCC"),
151 lldb.SBTypeSummary.CreateWithFunctionName(
152 "synth.ccc_synthetic", lldb.eTypeOptionCascade
155 cat3 = debugger.CreateCategory("BarIntSynth")
156 cat3.AddTypeSummary(
157 lldb.SBTypeNameSpecifier("int"),
158 lldb.SBTypeSummary.CreateWithFunctionName(
159 "synth.bar_int_synthetic", lldb.eTypeOptionCascade