blob: 4898ffb47da812814ed3333ace2525b7379194cf [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:
Filipe Cabecinhas3cae38b2012-05-11 20:39:42 +0000119 return int(self.sbblock.GetNumRanges())
Greg Clayton7dd5c512012-02-06 01:44:54 +0000120 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);
Greg Clayton698e94a2012-06-27 20:23:09 +0000126 if isinstance(key, SBAddress):
127 range_idx = self.sbblock.GetRangeIndexForBlockAddress(key);
128 if range_idx < len(self):
129 return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)]
Greg Clayton7dd5c512012-02-06 01:44:54 +0000130 else:
131 print "error: unsupported item type: %s" % type(key)
132 return None
133
134 def get_ranges_access_object(self):
135 '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.'''
136 return self.ranges_access (self)
137
138 def get_ranges_array(self):
139 '''An accessor function that returns an array object that contains all ranges in this block object.'''
140 if not hasattr(self, 'ranges'):
141 self.ranges = []
142 for idx in range(self.num_ranges):
143 self.ranges.append (self.get_range_at_index (idx))
144 return self.ranges
145
146 def get_call_site(self):
147 return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn())
148
149 __swig_getmethods__["parent"] = GetParent
Greg Clayton2a94be12012-06-29 22:00:42 +0000150 if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000151
152 __swig_getmethods__["first_child"] = GetFirstChild
Greg Clayton2a94be12012-06-29 22:00:42 +0000153 if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000154
155 __swig_getmethods__["call_site"] = get_call_site
Greg Clayton2a94be12012-06-29 22:00:42 +0000156 if _newclass: call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000157
158 __swig_getmethods__["sibling"] = GetSibling
Greg Clayton2a94be12012-06-29 22:00:42 +0000159 if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000160
161 __swig_getmethods__["name"] = GetInlinedName
Greg Clayton2a94be12012-06-29 22:00:42 +0000162 if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000163
164 __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock
Greg Clayton2a94be12012-06-29 22:00:42 +0000165 if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000166
167 __swig_getmethods__["range"] = get_ranges_access_object
Greg Clayton2a94be12012-06-29 22:00:42 +0000168 if _newclass: range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000169
170 __swig_getmethods__["ranges"] = get_ranges_array
Greg Clayton2a94be12012-06-29 22:00:42 +0000171 if _newclass: ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000172
173 __swig_getmethods__["num_ranges"] = GetNumRanges
Greg Clayton2a94be12012-06-29 22:00:42 +0000174 if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
Greg Clayton7dd5c512012-02-06 01:44:54 +0000175 %}
176
Johnny Chen3cfd5e82011-07-18 21:30:21 +0000177};
178
179} // namespace lldb