1 //===-- SWIG Interface for SBBlock ------------------------------*- 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 lexical block. SBFunction contains SBBlock(s)."
20 SBBlock (const lldb::SBBlock &rhs);
25 "Does this block represent an inlined function?"
33 explicit operator bool() const;
35 %feature("docstring", "
36 Get the function name if this block represents an inlined function;
37 otherwise, return None.") GetInlinedName;
39 GetInlinedName () const;
41 %feature("docstring", "
42 Get the call site file if this block represents an inlined function;
43 otherwise, return an invalid file spec.") GetInlinedCallSiteFile;
45 GetInlinedCallSiteFile () const;
47 %feature("docstring", "
48 Get the call site line if this block represents an inlined function;
49 otherwise, return 0.") GetInlinedCallSiteLine;
51 GetInlinedCallSiteLine () const;
53 %feature("docstring", "
54 Get the call site column if this block represents an inlined function;
55 otherwise, return 0.") GetInlinedCallSiteColumn;
57 GetInlinedCallSiteColumn () const;
59 %feature("docstring", "Get the parent block.") GetParent;
63 %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock;
65 GetContainingInlinedBlock ();
67 %feature("docstring", "Get the sibling block for this block.") GetSibling;
71 %feature("docstring", "Get the first child block.") GetFirstChild;
79 GetRangeStartAddress (uint32_t idx);
82 GetRangeEndAddress (uint32_t idx);
85 GetRangeIndexForBlockAddress (lldb::SBAddress block_addr);
88 GetDescription (lldb::SBStream &description);
91 GetVariables (lldb::SBFrame& frame,
95 lldb::DynamicValueType use_dynamic);
98 GetVariables (lldb::SBTarget& target,
103 STRING_EXTENSION(SBBlock)
107 def get_range_at_index(self, idx):
108 if idx < self.GetNumRanges():
109 return [self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)]
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
119 return int(self.sbblock.GetNumRanges())
122 def __getitem__(self, key):
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)]
131 print("error: unsupported item type: %s" % type(key))
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)
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
146 def get_call_site(self):
147 return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn())
149 parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''')
150 first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''')
151 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.''')
152 sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')
153 name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')
154 inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')
155 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.SBAddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''')
156 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.''')
157 num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')