[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / packages / Python / lldbsuite / test / python_api / formatters / synth.py
blob75a8d6cfc65fff2ffea9a25570816b41ef69f0cf
1 import lldb
4 class jasSynthProvider:
6 def __init__(self, valobj, dict):
7 self.valobj = valobj
9 def num_children(self):
10 return 2
12 def get_child_at_index(self, index):
13 child = None
14 if index == 0:
15 child = self.valobj.GetChildMemberWithName('A')
16 if index == 1:
17 child = self.valobj.CreateValueFromExpression('X', '(int)1')
18 return child
20 def get_child_index(self, name):
21 if name == 'A':
22 return 0
23 if name == 'X':
24 return 1
25 return None
28 def ccc_summary(sbvalue, internal_dict):
29 sbvalue = sbvalue.GetNonSyntheticValue()
30 # This tests that the SBValue.GetNonSyntheticValue() actually returns a
31 # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a")
32 # in the following statement will call the 'get_child_index' method of the
33 # synthetic child provider CCCSynthProvider below (which raises an
34 # exception).
35 return "CCC object with leading value " + \
36 str(sbvalue.GetChildMemberWithName("a"))
39 class CCCSynthProvider(object):
41 def __init__(self, sbvalue, internal_dict):
42 self._sbvalue = sbvalue
44 def num_children(self):
45 return 3
47 def get_child_index(self, name):
48 raise RuntimeError("I don't want to be called!")
50 def get_child_at_index(self, index):
51 if index == 0:
52 return self._sbvalue.GetChildMemberWithName("a")
53 if index == 1:
54 return self._sbvalue.GetChildMemberWithName("b")
55 if index == 2:
56 return self._sbvalue.GetChildMemberWithName("c")
59 def empty1_summary(sbvalue, internal_dict):
60 return "I am an empty Empty1"
63 class Empty1SynthProvider(object):
65 def __init__(self, sbvalue, internal_dict):
66 self._sbvalue = sbvalue
68 def num_children(self):
69 return 0
71 def get_child_at_index(self, index):
72 return None
75 def empty2_summary(sbvalue, internal_dict):
76 return "I am an empty Empty2"
79 class Empty2SynthProvider(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 __lldb_init_module(debugger, dict):
92 debugger.CreateCategory("JASSynth").AddTypeSynthetic(
93 lldb.SBTypeNameSpecifier("JustAStruct"),
94 lldb.SBTypeSynthetic.CreateWithClassName("synth.jasSynthProvider"))
95 cat = debugger.CreateCategory("CCCSynth")
96 cat.AddTypeSynthetic(
97 lldb.SBTypeNameSpecifier("CCC"),
98 lldb.SBTypeSynthetic.CreateWithClassName("synth.CCCSynthProvider",
99 lldb.eTypeOptionCascade))
100 cat.AddTypeSummary(
101 lldb.SBTypeNameSpecifier("CCC"),
102 lldb.SBTypeSummary.CreateWithFunctionName("synth.ccc_summary",
103 lldb.eTypeOptionCascade))
104 cat.AddTypeSynthetic(
105 lldb.SBTypeNameSpecifier("Empty1"),
106 lldb.SBTypeSynthetic.CreateWithClassName("synth.Empty1SynthProvider"))
107 cat.AddTypeSummary(
108 lldb.SBTypeNameSpecifier("Empty1"),
109 lldb.SBTypeSummary.CreateWithFunctionName("synth.empty1_summary"))
110 cat.AddTypeSynthetic(
111 lldb.SBTypeNameSpecifier("Empty2"),
112 lldb.SBTypeSynthetic.CreateWithClassName("synth.Empty2SynthProvider"))
113 cat.AddTypeSummary(
114 lldb.SBTypeNameSpecifier("Empty2"),
115 lldb.SBTypeSummary.CreateWithFunctionName(
116 "synth.empty2_summary",
117 lldb.eTypeOptionHideEmptyAggregates))