blob: 0ba9b7962b7d0f2ef448c71d4d911da5fe55716c [file] [log] [blame]
Johnny Chen9a5b16b2011-07-18 19:15:22 +00001//===-- SWIG Interface for SBValueList --------------------------*- C++ -*-===//
Johnny Chen67ae7bd2011-07-18 19:08:30 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10namespace lldb {
11
12%feature("docstring",
13"Represents a collection of SBValues. Both SBFrame's GetVariables() and
14GetRegisters() return a SBValueList.
15
16SBValueList supports SBValue iteration. For example (from test/lldbutil.py),
17
18def get_registers(frame, kind):
19 '''Returns the registers given the frame and the kind of registers desired.
20
21 Returns None if there's no such kind.
22 '''
23 registerSet = frame.GetRegisters() # Return type of SBValueList.
24 for value in registerSet:
25 if kind.lower() in value.GetName().lower():
26 return value
27
28 return None
29
30def get_GPRs(frame):
31 '''Returns the general purpose registers of the frame as an SBValue.
32
33 The returned SBValue object is iterable. An example:
34 ...
35 from lldbutil import get_GPRs
36 regs = get_GPRs(frame)
37 for reg in regs:
38 print '%s => %s' % (reg.GetName(), reg.GetValue())
39 ...
40 '''
41 return get_registers(frame, 'general purpose')
42
43def get_FPRs(frame):
44 '''Returns the floating point registers of the frame as an SBValue.
45
46 The returned SBValue object is iterable. An example:
47 ...
48 from lldbutil import get_FPRs
49 regs = get_FPRs(frame)
50 for reg in regs:
51 print '%s => %s' % (reg.GetName(), reg.GetValue())
52 ...
53 '''
54 return get_registers(frame, 'floating point')
55
56def get_ESRs(frame):
57 '''Returns the exception state registers of the frame as an SBValue.
58
59 The returned SBValue object is iterable. An example:
60 ...
61 from lldbutil import get_ESRs
62 regs = get_ESRs(frame)
63 for reg in regs:
64 print '%s => %s' % (reg.GetName(), reg.GetValue())
65 ...
66 '''
Johnny Chen357033b2011-07-18 20:13:38 +000067 return get_registers(frame, 'exception state')"
68) SBValueList;
Johnny Chen67ae7bd2011-07-18 19:08:30 +000069class SBValueList
70{
71public:
72
73 SBValueList ();
74
75 SBValueList (const lldb::SBValueList &rhs);
76
77 ~SBValueList();
78
79 bool
80 IsValid() const;
Jim Ingham5d3bca42011-12-19 20:39:44 +000081
82 void
83 Clear();
Johnny Chen67ae7bd2011-07-18 19:08:30 +000084
85 void
86 Append (const lldb::SBValue &val_obj);
87
88 void
89 Append (const lldb::SBValueList& value_list);
90
91 uint32_t
92 GetSize() const;
93
94 lldb::SBValue
95 GetValueAtIndex (uint32_t idx) const;
96
97 lldb::SBValue
98 FindValueObjectByUID (lldb::user_id_t uid);
Enrico Granatae9a09c72014-11-21 21:45:03 +000099
100 lldb::SBValue
Enrico Granata49a67462014-11-21 22:23:08 +0000101 GetFirstValueByName (const char* name) const;
Enrico Granatae9a09c72014-11-21 21:45:03 +0000102
Greg Clayton7edbdfc2012-02-03 07:02:37 +0000103 %pythoncode %{
104 def __len__(self):
Filipe Cabecinhas1a96ef82012-05-11 20:39:42 +0000105 return int(self.GetSize())
106
Greg Clayton7edbdfc2012-02-03 07:02:37 +0000107 def __getitem__(self, key):
108 count = len(self)
109 #------------------------------------------------------------
110 # Access with "int" to get Nth item in the list
111 #------------------------------------------------------------
112 if type(key) is int:
113 if key < count:
114 return self.GetValueAtIndex(key)
115 #------------------------------------------------------------
116 # Access with "str" to get values by name
117 #------------------------------------------------------------
118 elif type(key) is str:
119 matches = []
120 for idx in range(count):
121 value = self.GetValueAtIndex(idx)
122 if value.name == key:
123 matches.append(value)
124 return matches
125 #------------------------------------------------------------
126 # Match with regex
127 #------------------------------------------------------------
128 elif isinstance(key, type(re.compile('.'))):
129 matches = []
130 for idx in range(count):
131 value = self.GetValueAtIndex(idx)
132 re_match = key.search(value.name)
133 if re_match:
134 matches.append(value)
135 return matches
136
137 %}
138
139
Johnny Chen67ae7bd2011-07-18 19:08:30 +0000140};
141
142} // namespace lldb