[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 5 02:05:41 PDT 2024
================
@@ -132,6 +140,71 @@ class MinidumpFile : public Binary {
size_t Stride;
};
+ class Memory64ListFacade {
+ struct Memory64Iterator {
+ public:
+ Memory64Iterator(size_t Count, uint64_t BaseRVA,
+ const Memory64ListFacade *Parent)
+ : Parent(Parent), BaseRVA(BaseRVA), Count(Count) {};
+
+ const std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>>
+ operator*() {
+ return Parent->Next(this);
+ }
+
+ bool operator==(const Memory64Iterator &R) const {
+ return Parent == R.Parent && Count == R.Count;
+ }
+
+ bool operator!=(const Memory64Iterator &R) const { return !(*this == R); }
+
+ private:
+ friend class Memory64ListFacade;
+ const Memory64ListFacade *Parent;
+ uint64_t BaseRVA;
+ size_t Count;
+ };
+
+ public:
+ Memory64ListFacade(ArrayRef<uint8_t> Storage,
+ std::vector<minidump::MemoryDescriptor_64> Descriptors,
+ uint64_t BaseRVA)
+ : BaseRVA(BaseRVA), Storage(Storage),
+ Descriptors(std::move(Descriptors)) {};
+
+ Memory64Iterator begin() const {
+ return Memory64Iterator(0, BaseRVA, this);
+ }
+
+ Memory64Iterator end() const {
+ return Memory64Iterator(Descriptors.size(), BaseRVA, this);
+ }
+
+ size_t size() const { return Descriptors.size(); }
+
+ private:
+ uint64_t BaseRVA;
+ ArrayRef<uint8_t> Storage;
+ std::vector<minidump::MemoryDescriptor_64> Descriptors;
+
+ const std::pair<minidump::MemoryDescriptor_64, ArrayRef<uint8_t>>
+ Next(Memory64Iterator *Iterator) const {
+ assert(Descriptors.size() > Iterator->Count);
+ minidump::MemoryDescriptor_64 Descriptor = Descriptors[Iterator->Count];
+ ArrayRef<uint8_t> Content =
+ Storage.slice(Iterator->BaseRVA, Descriptor.DataSize);
----------------
labath wrote:
I think it's worth dropping a short comment saying that the bounds of this array were checked when this iterator was constructed.
https://github.com/llvm/llvm-project/pull/101272
More information about the lldb-commits
mailing list