[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)

Jacob Lalonde via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 6 11:18:55 PDT 2024


================
@@ -132,6 +140,79 @@ class MinidumpFile : public Binary {
     size_t Stride;
   };
 
+class Memory64Iterator {
+  public:
+    static Memory64Iterator begin(ArrayRef<uint8_t> Storage, ArrayRef<minidump::MemoryDescriptor_64> Descriptors, uint64_t BaseRVA) {
+      return Memory64Iterator(Storage, Descriptors, BaseRVA);
+    }
+
+    static Memory64Iterator end() {
+      return Memory64Iterator();
+    }
+
+    std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> Current;
+
+    bool operator==(const Memory64Iterator &R) const {
+      return isEnd == R.isEnd;
+    }
+
+    bool operator!=(const Memory64Iterator &R) const { return !(*this == R); }
+
+    const std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> &operator*() const {
+      return Current;
+    }
+
+    const std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>> *operator->() const {
+      return &Current;
+    }
+
+    Error inc() {
+      if (Storage.size() == 0 || Descriptors.size() == 0)
----------------
Jlalond wrote:

@labath This is my last concern. I tried to base this off of `Archive.cpp`'s implementation of Fallible iterator, but if the iterator is dereferenced before being advanced we'll get a default value of {0, 0}.

Currently you just have to use the `++It` operator in both classes, but I'm not sure if this is best practice.

https://github.com/llvm/llvm-project/pull/101272


More information about the lldb-commits mailing list