[Lldb-commits] [PATCH] D115073: Modify DataEncoder to be able to encode data in an object owned buffer.

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 3 12:40:55 PST 2021


clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, aadsm, wallace.
Herald added a subscriber: mgorny.
clayborg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

DataEncoder was previously made to modify data within an existing buffer. As the code progressed, new clients started using DataEncoder to create binary data. In these cases the use of this class was possibly, but only if you knew exactly how large your buffer would be ahead of time. This patchs adds the ability for DataEncoder to own a buffer that can be dynamically resized as data is appended to the buffer.

Change in this patch:

- Allow a DataEncoder object to be created that owns a DataBufferHeap object that can dynamically grow as data is appended
- Add new methods that start with "Append" to append data to the buffer and grow it as needed
- Adds full testing of the API to assure modifications don't regress any functionality
- Has two constructors: one that uses caller owned data and one that creates an object with object owned data
- "Append" methods only work if the object owns it own data
- Removes the ability to specify a shared memory buffer as no one was using this functionality. This allows us to switch to a case where the object owns its own data in a DataBufferHeap that can be resized as data is added

"Put" methods work on both caller and object owned data.
"Append" methods work on only object owned data where we can grow the buffer. These methods will return false if called on a DataEncoder object that has caller owned data.

The main reason for these modifications is to be able to use the DateEncoder objects instead of llvm::gsym::FileWriter in https://reviews.llvm.org/D113789. This patch wants to add the ability to create symbol table caching to LLDB and the code needs to build binary caches and save them to disk.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115073

Files:
  lldb/include/lldb/Utility/DataEncoder.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/Platform/Android/AdbClient.cpp
  lldb/source/Utility/DataEncoder.cpp
  lldb/unittests/Process/POSIX/NativeProcessELFTest.cpp
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/DataEncoderTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115073.391711.patch
Type: text/x-patch
Size: 45708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211203/dbadfa9d/attachment-0001.bin>


More information about the lldb-commits mailing list