================
@@ -7,7 +7,12 @@
 
     def __iter__(self):
       '''Iterate over all the memory regions in a lldb.SBMemoryRegionInfoList 
object.'''
-      return lldb_iter(self, 'GetSize', 'GetMemoryRegionAtIndex')
+      import lldb
+      size = self.GetSize()
+      region = lldb.SBMemoryRegionInfo()
+      for i in range(size):
+        self.GetMemoryRegionAtIndex(i, region)
+        yield region
----------------
clayborg wrote:

We might want to add a __getitem__ and __repr__ like found in 
SBAddressRangeListExtensions.i:
```
    def __getitem__(self, idx):
      '''Get the address range at a given index in an lldb.SBAddressRangeList 
object.'''
      if not isinstance(idx, int):
        raise TypeError("unsupported index type: %s" % type(idx))
      count = len(self)
      if not (-count <= idx < count):
        raise IndexError("list index out of range")
      idx %= count
      return self.GetAddressRangeAtIndex(idx)

    def __repr__(self):
      import lldb
      stream = lldb.SBStream()
      self.GetDescription(stream, lldb.target if lldb.target else 
lldb.SBTarget())
      return stream.GetData()
```

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

Reply via email to