• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- 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 
10 namespace lldb {
11 
12 %feature("docstring",
13 "Represents a lexical block. SBFunction contains SBBlock(s)."
14 ) SBBlock;
15 class SBBlock
16 {
17 public:
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 
66     %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock;
67     lldb::SBBlock
68     GetContainingInlinedBlock ();
69 
70     %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 ();
77 
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);
89 
90     bool
91     GetDescription (lldb::SBStream &description);
92 
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.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)]
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 int(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                 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)]
130                 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_array'):
141                 self.ranges_array = []
142                 for idx in range(self.num_ranges):
143                     self.ranges_array.append ([self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)])
144             return self.ranges_array
145 
146         def get_call_site(self):
147             return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn())
148 
149         __swig_getmethods__["parent"] = GetParent
150         if _newclass: parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''')
151 
152         __swig_getmethods__["first_child"] = GetFirstChild
153         if _newclass: first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''')
154 
155         __swig_getmethods__["call_site"] = get_call_site
156         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.''')
157 
158         __swig_getmethods__["sibling"] = GetSibling
159         if _newclass: sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')
160 
161         __swig_getmethods__["name"] = GetInlinedName
162         if _newclass: name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')
163 
164         __swig_getmethods__["inlined_block"] = GetContainingInlinedBlock
165         if _newclass: inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')
166 
167         __swig_getmethods__["range"] = get_ranges_access_object
168         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]").''')
169 
170         __swig_getmethods__["ranges"] = get_ranges_array
171         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.''')
172 
173         __swig_getmethods__["num_ranges"] = GetNumRanges
174         if _newclass: num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
175     %}
176 
177 };
178 
179 } // namespace lldb
180