================
@@ -0,0 +1,27 @@
+%extend lldb::SBAddressRangeList {
+#ifdef SWIGPYTHON
+    %pythoncode%{
+    def __len__(self):
+      '''Return the number of address ranges in a lldb.SBAddressRangeList 
object.'''
+      return self.GetSize()
+
+    def __iter__(self):
+      '''Iterate over all the address ranges in a lldb.SBAddressRangeList 
object.'''
+      return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex')
+
+    def __getitem__(self, idx):
+      '''Get the address range at a given index in an lldb.SBAddressRangeList 
object.'''
+      if type(idx) == int:
+        if idx >= self.GetSize():
----------------
clayborg wrote:

`idx` can be negative. If we want to support the typical python indexing 
negative numbers start at the end, so `-1` is the last entry, `-2` is the 
second to last entry as well. So either check if `idx >= 0` or add support for 
negative indexes.

https://github.com/llvm/llvm-project/pull/92014
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to