Author: Zequan Wu Date: 2023-03-06T10:25:38-05:00 New Revision: 960126e04a6faad1b71e110a4262c5733e50fab7
URL: https://github.com/llvm/llvm-project/commit/960126e04a6faad1b71e110a4262c5733e50fab7 DIFF: https://github.com/llvm/llvm-project/commit/960126e04a6faad1b71e110a4262c5733e50fab7.diff LOG: [LLDB][NativePDB] Check string table in PDB files. Usually PDB files have a string table (aka: Named Stream "/names" ). PDB for some windows system libraries might not have that. This adds the check for it to avoid crash in the absence of string table. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D145115 Added: Modified: lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp index e2e06491e8c17..06cb720b1e9f7 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp @@ -162,9 +162,13 @@ CompilandIndexItem &CompileUnitIndex::GetOrCreateCompiland(uint16_t modi) { ParseExtendedInfo(m_index, *cci); ParseInlineeLineTableForCompileUnit(*cci); - cci->m_strings.initialize(cci->m_debug_stream.getSubsectionsArray()); - PDBStringTable &strings = cantFail(m_index.pdb().getStringTable()); - cci->m_strings.setStrings(strings.getStringTable()); + auto strings = m_index.pdb().getStringTable(); + if (strings) { + cci->m_strings.initialize(cci->m_debug_stream.getSubsectionsArray()); + cci->m_strings.setStrings(strings->getStringTable()); + } else { + consumeError(strings.takeError()); + } // We want the main source file to always comes first. Note that we can't // just push_back the main file onto the front because `GetMainSourceFile` diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp index 164bfa8b3726a..888bd89a72625 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp @@ -703,8 +703,12 @@ static bool GetFrameDataProgram(PdbIndex &index, if (frame_data_it == new_fpo_data.end()) return false; - PDBStringTable &strings = cantFail(index.pdb().getStringTable()); - out_program = cantFail(strings.getStringForID(frame_data_it->FrameFunc)); + auto strings = index.pdb().getStringTable(); + if (!strings) { + consumeError(strings.takeError()); + return false; + } + out_program = cantFail(strings->getStringForID(frame_data_it->FrameFunc)); return true; } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 82d3707acfa4b..b99e9ec82f126 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1341,6 +1341,9 @@ bool SymbolFileNativePDB::ParseDebugMacros(CompileUnit &comp_unit) { llvm::Expected<uint32_t> SymbolFileNativePDB::GetFileIndex(const CompilandIndexItem &cii, uint32_t file_id) { + if (!cii.m_strings.hasChecksums() || !cii.m_strings.hasStrings()) + return llvm::make_error<RawError>(raw_error_code::no_entry); + const auto &checksums = cii.m_strings.checksums().getArray(); const auto &strings = cii.m_strings.strings(); // Indices in this structure are actually offsets of records in the _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits