Modify DataEncoder to be able to encode data in an object owned buffer.
authorGreg Clayton <gclayton@fb.com>
Tue, 7 Dec 2021 17:44:22 +0000 (09:44 -0800)
committerGreg Clayton <gclayton@fb.com>
Tue, 7 Dec 2021 17:44:57 +0000 (09:44 -0800)
commit244258e35acc92b3293e91ddecee6a8c8613ec20
tree60da632ee010745487d5d2bbb1c26f2374a1c356
parent5034e1730f7a4dbd8004900096c4b176d24f13cb
Modify DataEncoder to be able to encode data in an object owned buffer.

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.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D115073
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 [new file with mode: 0644]