Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / bindings / interface / SBBlockExtensions.i
blobe83a416b23189430d710dda191940c0902b0dc30
1 STRING_EXTENSION_OUTSIDE(SBBlock)
3 %extend lldb::SBBlock {
4 #ifdef SWIGPYTHON
5 %pythoncode %{
6 def get_range_at_index(self, idx):
7 if idx < self.GetNumRanges():
8 return [self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)]
9 return []
11 class ranges_access(object):
12 '''A helper object that will lazily hand out an array of lldb.SBAddress that represent address ranges for a block.'''
13 def __init__(self, sbblock):
14 self.sbblock = sbblock
16 def __len__(self):
17 if self.sbblock:
18 return int(self.sbblock.GetNumRanges())
19 return 0
21 def __getitem__(self, key):
22 count = len(self)
23 if type(key) is int:
24 return self.sbblock.get_range_at_index (key);
25 if isinstance(key, SBAddress):
26 range_idx = self.sbblock.GetRangeIndexForBlockAddress(key);
27 if range_idx < len(self):
28 return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)]
29 else:
30 print("error: unsupported item type: %s" % type(key))
31 return None
33 def get_ranges_access_object(self):
34 '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.'''
35 return self.ranges_access (self)
37 def get_ranges_array(self):
38 '''An accessor function that returns an array object that contains all ranges in this block object.'''
39 if not hasattr(self, 'ranges_array'):
40 self.ranges_array = []
41 for idx in range(self.num_ranges):
42 self.ranges_array.append ([self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)])
43 return self.ranges_array
45 def get_call_site(self):
46 return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn())
48 parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''')
49 first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''')
50 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.''')
51 sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')
52 name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')
53 inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')
54 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]").''')
55 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.''')
56 num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
58 #endif