================
@@ -86,6 +86,122 @@ const void *VirtualDataExtractor::GetData(offset_t
*offset_ptr,
return result;
}
+offset_t VirtualDataExtractor::SetData(const void *bytes, lldb::offset_t
length,
+ lldb::ByteOrder byte_order) {
+ // Invoked from the base class ctor
+ if (!m_data_sp || m_start == nullptr)
+ return DataExtractor::SetData(bytes, length, byte_order);
+
+ // A no-op SetData that is setting the same data buffer again
+ if (!m_data_sp && m_start == bytes && length == GetVirtualByteSize())
+ return GetVirtualByteSize();
+
+ assert("SetData(1) called on VirtualDataExtractor that already had data" &&
+ false);
+
+ // FIXME calling SetData on a VirtualDataExtractor that already has a
+ // data buffer means the LookupTable needs to be either replaced, or
+ // if we assume the buffer is a subset of the original, we need to
+ // update all the entries to have correct new offsets into the buffer
+ // and remove entries that are outside the new range.
+ // For now, zero out the LookupTable and behave as if this is a simple
+ // DataExtractor.
+ DataExtractor::SetData(bytes, length, byte_order);
+ m_lookup_table.Clear();
+ m_lookup_table.Append(
+ VirtualDataExtractor::LookupTable::Entry{0, GetPhysicalByteSize(), 0});
+
+ return GetVirtualByteSize();
----------------
JDevlieghere wrote:
The code duplication between these methods stands out, especially with the long
FIXME. It seems like these 3 methods could be reimplemented in terms of one
helper method once you've extracted the underlying data. The only downside to
that is that would make your assertion less precise. The alternative would be
do unify only the code following the assertion.
https://github.com/llvm/llvm-project/pull/179858
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits