Modify the ranges_access() helper function to be able to lookup the address range in a block given an address. Since blocks can have multiple discontiguous ranges, it helps to be able to get the current address range for the current block in a frame. This can be used in code like:
curr_block_range = lldb.frame.block.range[lldb.frame.addr]
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@159289 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/scripts/Python/interface/SBBlock.i b/scripts/Python/interface/SBBlock.i
index c8435df..fbab974 100644
--- a/scripts/Python/interface/SBBlock.i
+++ b/scripts/Python/interface/SBBlock.i
@@ -123,6 +123,10 @@
count = len(self)
if type(key) is int:
return self.sbblock.get_range_at_index (key);
+ if isinstance(key, SBAddress):
+ range_idx = self.sbblock.GetRangeIndexForBlockAddress(key);
+ if range_idx < len(self):
+ return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)]
else:
print "error: unsupported item type: %s" % type(key)
return None