llvm-project/lldb/source/Symbol
Greg Clayton 268089b6ac Fix the encoding and decoding of UniqueCStringMap<T> objects when saved to cache files.
UniqueCStringMap<T> objects are a std::vector<UniqueCStringMap::Entry> objects where the Entry object contains a ConstString + T. The values in the vector are sorted first by ConstString and then by the T value. ConstString objects are simply uniqued "const char *" values and when we compare we use the actual string pointer as the value we sort by. This caused a problem when we saved the symbol table name indexes and debug info indexes to disk in one process when they were sorted, and then loaded them into another process when decoding them from the cache files. Why? Because the order in which the ConstString objects were created are now completely different and the string pointers will no longer be sorted in the new process the cache was loaded into.

The unit tests created for the initial patch didn't catch the encoding and decoding issues of UniqueCStringMap<T> because they were happening in the same process and encoding and decoding would end up createing sorted UniqueCStringMap<T> objects due to the constant string pool being exactly the same.

This patch does the sort and also reserves the right amount of entries in the UniqueCStringMap::m_map prior to adding them all to avoid doing multiple allocations.

Added a unit test that loads an object file from yaml, and then I created a cache file for the original file and removed the cache file's signature mod time check since we will generate an object file from the YAML, and use that as the object file for the Symtab object. Then we load the cache data from the array of symtab cache bytes so that the ConstString "const char *" values will not match the current process, and verify we can lookup the 4 names from the object file in the symbol table.

Differential Revision: https://reviews.llvm.org/D124572
2022-04-29 11:31:47 -07:00
..
ArmUnwindInfo.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
Block.cpp [lldb] Rename Logging.h to LLDBLog.h and clean up includes 2022-02-03 14:47:01 +01:00
CMakeLists.txt Introduce new symbol on-demand for debug info 2022-04-26 10:42:06 -07:00
CompactUnwindInfo.cpp [lldb] Rename Logging.h to LLDBLog.h and clean up includes 2022-02-03 14:47:01 +01:00
CompileUnit.cpp Introduce new symbol on-demand for debug info 2022-04-26 10:42:06 -07:00
CompilerDecl.cpp
CompilerDeclContext.cpp
CompilerType.cpp [lldb][NFC] Give CompilerType's IsArrayType/IsVectorType/IsBlockPointerType out-parameters default values 2021-02-23 11:15:31 +01:00
DWARFCallFrameInfo.cpp [LLDB] Remove cases of using namespace llvm:: from header file 2022-03-03 10:39:06 -08:00
DebugMacros.cpp
DeclVendor.cpp [lldb][NFC] Remove outdated FIXME 2021-09-20 11:44:20 -07:00
FuncUnwinders.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
Function.cpp [lldb] Rename Logging.h to LLDBLog.h and clean up includes 2022-02-03 14:47:01 +01:00
LineEntry.cpp Change PathMappingList::FindFile to return an optional result (NFC) 2021-06-29 15:10:46 -07:00
LineTable.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
LocateSymbolFile.cpp [lldb] Show the DBGError if dsymForUUID can't find a dSYM 2022-04-14 16:54:00 -07:00
LocateSymbolFileMacOSX.cpp [lldb] Show the DBGError if dsymForUUID can't find a dSYM 2022-04-14 16:54:00 -07:00
ObjectFile.cpp [lldb] Change CreateMemoryInstance to take a WritableDataBuffer 2022-04-05 13:46:41 -07:00
PostfixExpression.cpp [LLDB] Remove cases of using namespace llvm:: from header file 2022-03-03 10:39:06 -08:00
Symbol.cpp [LLDB] Applying clang-tidy modernize-use-default-member-init over LLDB 2022-03-14 13:32:03 -07:00
SymbolContext.cpp [lldb] Prevent crash when adding a stop hook with --shlib 2022-04-14 11:00:21 -07:00
SymbolFile.cpp Introduce new symbol on-demand for debug info 2022-04-26 10:42:06 -07:00
SymbolFileOnDemand.cpp Introduce new symbol on-demand for debug info 2022-04-26 10:42:06 -07:00
SymbolVendor.cpp [lldb] Return StringRef from PluginInterface::GetPluginName 2021-10-18 10:14:42 +02:00
Symtab.cpp Fix the encoding and decoding of UniqueCStringMap<T> objects when saved to cache files. 2022-04-29 11:31:47 -07:00
Type.cpp [LLDB] Applying clang-tidy modernize-use-default-member-init over LLDB 2022-03-14 13:32:03 -07:00
TypeList.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
TypeMap.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
TypeSystem.cpp Use true/false instead of 1/0 (NFC) 2022-01-09 12:21:06 -08:00
UnwindPlan.cpp Cleanup LLVMDWARFDebugInfo 2022-02-15 09:16:03 +01:00
UnwindTable.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
Variable.cpp [LLDB][NativePDB] Add support for S_DEFRANGE_REGISTER and S_DEFRANGE_SUBFIELD_REGISTER 2022-03-10 12:40:31 -08:00
VariableList.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00