blob: cdaf62cbeca30d45f8b2e4e2680bd8224db60bdb [file] [log] [blame]
Johnny Chen3cfd5e82011-07-18 21:30:21 +00001//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===//
2//
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 lexical block. SBFunction contains SBBlock(s)."
14) SBBlock;
15class SBBlock
16{
17public:
18
19 SBBlock ();
20
21 SBBlock (const lldb::SBBlock &rhs);
22
23 ~SBBlock ();
24
25 %feature("docstring",
26 "Does this block represent an inlined function?"
27 ) IsInlined;
28 bool
29 IsInlined () const;
30
31 bool
32 IsValid () const;
33
34 %feature("docstring", "
35 Get the function name if this block represents an inlined function;
36 otherwise, return None.
37 ") GetInlinedName;
38 const char *
39 GetInlinedName () const;
40
41 %feature("docstring", "
42 Get the call site file if this block represents an inlined function;
43 otherwise, return an invalid file spec.
44 ") GetInlinedCallSiteFile;
45 lldb::SBFileSpec
46 GetInlinedCallSiteFile () const;
47
48 %feature("docstring", "
49 Get the call site line if this block represents an inlined function;
50 otherwise, return 0.
51 ") GetInlinedCallSiteLine;
52 uint32_t
53 GetInlinedCallSiteLine () const;
54
55 %feature("docstring", "
56 Get the call site column if this block represents an inlined function;
57 otherwise, return 0.
58 ") GetInlinedCallSiteColumn;
59 uint32_t
60 GetInlinedCallSiteColumn () const;
61
62 %feature("docstring", "Get the parent block.") GetParent;
63 lldb::SBBlock
64 GetParent ();
65
Greg Clayton23b8abb2011-09-26 07:11:27 +000066 %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock;
67 lldb::SBBlock
68 GetContainingInlinedBlock ();
69
Johnny Chen3cfd5e82011-07-18 21:30:21 +000070 %feature("docstring", "Get the sibling block for this block.") GetSibling;
71 lldb::SBBlock
72 GetSibling ();
73
74 %feature("docstring", "Get the first child block.") GetFirstChild;
75 lldb::SBBlock
76 GetFirstChild ();
Greg Clayton23b8abb2011-09-26 07:11:27 +000077
78 uint32_t
79 GetNumRanges ();
80
81 lldb::SBAddress
82 GetRangeStartAddress (uint32_t idx);
83
84 lldb::SBAddress
85 GetRangeEndAddress (uint32_t idx);
86
87 uint32_t
88 GetRangeIndexForBlockAddress (lldb::SBAddress block_addr);
Johnny Chen3cfd5e82011-07-18 21:30:21 +000089
90 bool
91 GetDescription (lldb::SBStream &description);
Greg Clayton7dd5c512012-02-06 01:44:54 +000092
93 lldb::SBValueList
94 GetVariables (lldb::SBFrame& frame,
95 bool arguments,
96 bool locals,
97 bool statics,
98 lldb::DynamicValueType use_dynamic);
99
100 lldb::SBValueList
101 GetVariables (lldb::SBTarget& target,
102 bool arguments,
103 bool locals,
104 bool statics);
105
106 %pythoncode %{
107 def get_range_at_index(self, idx):
108 if idx < self.GetNumRanges():
109 return [self.sbblock.GetRangeStartAddress(key), self.sbblock.GetRangeEndAddress(key)]
110 return []
111
112 class ranges_access(object):
113 '''A helper object that will lazily hand out an array of lldb.SBAddress that represent address ranges for a block.'''
114 def __init__(self, sbblock):
115 self.sbblock = sbblock
116
117 def __len__(self):
118 if self.sbblock:
119 return self.sbblock.GetNumRanges()
120 return 0
121
122 def __getitem__(self, key):
123 count = len(self)
124 if type(key) is int:
125 return self.sbblock.get_range_at_index (key);
126 else:
127 print "error: unsupported item type: %s" % type(key)
128 return None
129
130 def get_ranges_access_object(self):
131 '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.'''
132 return self.ranges_access (self)
133
134 def get_ranges_array(self):
135 '''An accessor function that returns an array object that contains all ranges in this block object.'''
136 if not hasattr(self, 'ranges'):
137 self.ranges = []
138 for idx in range(self.num_ranges):
139 self.ranges.append (self.get_range_at_index (idx))
140 return self.ranges
141
142 def get_call_site(self):
143 return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn())
144
145 __swig_getmethods__["parent"] = GetParent
146 if _newclass: x = property(GetParent, None)
147
148 __swig_getmethods__["first_child"] = GetFirstChild
149 if _newclass: x = property(GetFirstChild, None)
150
151 __swig_getmethods__["call_site"] = get_call_site
152 if _newclass: x = property(get_call_site, None)
153
154 __swig_getmethods__["sibling"] = GetSibling
155 if _newclass: x = property(GetSibling, None)
156
157 __swig_getmethods__["name"] = GetInlinedName
158 if _newclass: x = property(GetInlinedName, None)
159
160 __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock
161 if _newclass: x = property(GetContainingInlinedBlock, None)
162
163 __swig_getmethods__["range"] = get_ranges_access_object
164 if _newclass: x = property(get_ranges_access_object, None)
165
166 __swig_getmethods__["ranges"] = get_ranges_array
167 if _newclass: x = property(get_ranges_array, None)
168
169 __swig_getmethods__["num_ranges"] = GetNumRanges
170 if _newclass: x = property(GetNumRanges, None)
171 %}
172
Johnny Chen3cfd5e82011-07-18 21:30:21 +0000173};
174
175} // namespace lldb