[llvm] [Minidump] Support multiple exceptions in a minidump (PR #107319)

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 01:22:39 PDT 2024


================
@@ -216,8 +219,68 @@ class MinidumpFile : public Binary {
     bool IsEnd;
   };
 
+  class ExceptionStreamsIterator {
+  public:
+    static ExceptionStreamsIterator begin(ArrayRef<minidump::Directory> Streams,
+                                          const MinidumpFile *File) {
+      return ExceptionStreamsIterator(Streams, File);
+    }
+
+    static ExceptionStreamsIterator end() { return ExceptionStreamsIterator(); }
+
+    bool operator==(const ExceptionStreamsIterator &R) const {
+      return Streams.empty() && R.Streams.empty();
+    }
+
+    bool operator!=(const ExceptionStreamsIterator &R) const {
+      return !(*this == R);
+    }
+
+    Expected<const minidump::ExceptionStream &> operator*() {
+      return ReadCurrent();
+    }
+
+    Expected<const minidump::ExceptionStream &> operator->() {
+      return ReadCurrent();
+    }
+
+    ExceptionStreamsIterator &operator++() {
+      if (!Streams.empty())
+        Streams = Streams.drop_front();
----------------
labath wrote:

```suggestion
      assert (!Streams.empty() && "Incrementing end iterator");
      Streams = Streams.drop_front();
```
Or even drop the assert, as `drop_front()` already contains something similar.

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


More information about the llvm-commits mailing list