[llvm] 8129ba6 - [Minidump] Declare MinidumpFile::getListStream in the header instead of extern template (#112568)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 2 09:40:40 PDT 2024
Author: Thomas Fransham
Date: 2024-11-02T18:40:36+02:00
New Revision: 8129ba6c70aef54d87893adeb34e76f84fa69fe3
URL: https://github.com/llvm/llvm-project/commit/8129ba6c70aef54d87893adeb34e76f84fa69fe3
DIFF: https://github.com/llvm/llvm-project/commit/8129ba6c70aef54d87893adeb34e76f84fa69fe3.diff
LOG: [Minidump] Declare MinidumpFile::getListStream in the header instead of extern template (#112568)
This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM
plugins on window.
Added:
Modified:
llvm/include/llvm/Object/Minidump.h
llvm/lib/Object/Minidump.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Object/Minidump.h b/llvm/include/llvm/Object/Minidump.h
index e6b21979ccaa1d..831be1c51d5748 100644
--- a/llvm/include/llvm/Object/Minidump.h
+++ b/llvm/include/llvm/Object/Minidump.h
@@ -371,6 +371,28 @@ Expected<ArrayRef<T>> MinidumpFile::getDataSliceAs(ArrayRef<uint8_t> Data,
return ArrayRef<T>(reinterpret_cast<const T *>(Slice->data()), Count);
}
+template <typename T>
+Expected<ArrayRef<T>>
+MinidumpFile::getListStream(minidump::StreamType Type) const {
+ std::optional<ArrayRef<uint8_t>> Stream = getRawStream(Type);
+ if (!Stream)
+ return createError("No such stream");
+ auto ExpectedSize = getDataSliceAs<support::ulittle32_t>(*Stream, 0, 1);
+ if (!ExpectedSize)
+ return ExpectedSize.takeError();
+
+ size_t ListSize = ExpectedSize.get()[0];
+
+ size_t ListOffset = 4;
+ // Some producers insert additional padding bytes to align the list to an
+ // 8-byte boundary. Check for that by comparing the list size with the overall
+ // stream size.
+ if (ListOffset + sizeof(T) * ListSize < Stream->size())
+ ListOffset = 8;
+
+ return getDataSliceAs<T>(*Stream, ListOffset, ListSize);
+}
+
} // end namespace object
} // end namespace llvm
diff --git a/llvm/lib/Object/Minidump.cpp b/llvm/lib/Object/Minidump.cpp
index fe768c4c90711b..83c527e84365f8 100644
--- a/llvm/lib/Object/Minidump.cpp
+++ b/llvm/lib/Object/Minidump.cpp
@@ -78,33 +78,6 @@ MinidumpFile::getMemoryInfoList() const {
MemoryInfoIterator({}, H.SizeOfEntry));
}
-template <typename T>
-Expected<ArrayRef<T>> MinidumpFile::getListStream(StreamType Type) const {
- std::optional<ArrayRef<uint8_t>> Stream = getRawStream(Type);
- if (!Stream)
- return createError("No such stream");
- auto ExpectedSize = getDataSliceAs<support::ulittle32_t>(*Stream, 0, 1);
- if (!ExpectedSize)
- return ExpectedSize.takeError();
-
- size_t ListSize = ExpectedSize.get()[0];
-
- size_t ListOffset = 4;
- // Some producers insert additional padding bytes to align the list to an
- // 8-byte boundary. Check for that by comparing the list size with the overall
- // stream size.
- if (ListOffset + sizeof(T) * ListSize < Stream->size())
- ListOffset = 8;
-
- return getDataSliceAs<T>(*Stream, ListOffset, ListSize);
-}
-template Expected<ArrayRef<Module>>
- MinidumpFile::getListStream(StreamType) const;
-template Expected<ArrayRef<Thread>>
- MinidumpFile::getListStream(StreamType) const;
-template Expected<ArrayRef<MemoryDescriptor>>
- MinidumpFile::getListStream(StreamType) const;
-
Expected<ArrayRef<uint8_t>> MinidumpFile::getDataSlice(ArrayRef<uint8_t> Data,
uint64_t Offset,
uint64_t Size) {
More information about the llvm-commits
mailing list