1 //===-- SWIG Interface for SBValueList --------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 "Represents a collection of SBValues. Both SBFrame's GetVariables() and
13 GetRegisters() return a SBValueList.
15 SBValueList supports SBValue iteration. For example (from test/lldbutil.py),
17 def get_registers(frame, kind):
18 '''Returns the registers given the frame and the kind of registers desired.
20 Returns None if there's no such kind.
22 registerSet = frame.GetRegisters() # Return type of SBValueList.
23 for value in registerSet:
24 if kind.lower() in value.GetName().lower():
30 '''Returns the general purpose registers of the frame as an SBValue.
32 The returned SBValue object is iterable. An example:
34 from lldbutil import get_GPRs
35 regs = get_GPRs(frame)
37 print('%s => %s' % (reg.GetName(), reg.GetValue()))
40 return get_registers(frame, 'general purpose')
43 '''Returns the floating point registers of the frame as an SBValue.
45 The returned SBValue object is iterable. An example:
47 from lldbutil import get_FPRs
48 regs = get_FPRs(frame)
50 print('%s => %s' % (reg.GetName(), reg.GetValue()))
53 return get_registers(frame, 'floating point')
56 '''Returns the exception state registers of the frame as an SBValue.
58 The returned SBValue object is iterable. An example:
60 from lldbutil import get_ESRs
61 regs = get_ESRs(frame)
63 print('%s => %s' % (reg.GetName(), reg.GetValue()))
66 return get_registers(frame, 'exception state')"
74 SBValueList (const lldb::SBValueList &rhs);
81 explicit operator bool() const;
87 Append (const lldb::SBValue &val_obj);
90 Append (const lldb::SBValueList& value_list);
96 GetValueAtIndex (uint32_t idx) const;
99 FindValueObjectByUID (lldb::user_id_t uid);
102 GetFirstValueByName (const char* name) const;
106 std::string lldb::SBValueList::__str__ (){
107 lldb::SBStream description;
108 const size_t n = $self->GetSize();
111 for (size_t i=0; i<n; ++i)
112 $self->GetValueAtIndex(i).GetDescription(description);
116 description.Printf("<empty> lldb.SBValueList()");
118 const char *desc = description.GetData();
119 size_t desc_len = description.GetSize();
120 if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
122 return std::string(desc, desc_len);
130 '''Iterate over all values in a lldb.SBValueList object.'''
131 return lldb_iter(self, 'GetSize', 'GetValueAtIndex')
134 return int(self.GetSize())
136 def __getitem__(self, key):
138 #------------------------------------------------------------
139 # Access with "int" to get Nth item in the list
140 #------------------------------------------------------------
143 return self.GetValueAtIndex(key)
144 #------------------------------------------------------------
145 # Access with "str" to get values by name
146 #------------------------------------------------------------
147 elif type(key) is str:
149 for idx in range(count):
150 value = self.GetValueAtIndex(idx)
151 if value.name == key:
152 matches.append(value)
154 #------------------------------------------------------------
156 #------------------------------------------------------------
157 elif isinstance(key, type(re.compile('.'))):
159 for idx in range(count):
160 value = self.GetValueAtIndex(idx)
161 re_match = key.search(value.name)
163 matches.append(value)