Skip to content

Commit ce00133

Browse files
authored
Allow lldb to load .dwp files with large .debug_info or .debug_types. (#73736)
A previous patch to llvm allowed the DWARFUnitIndex class to handle .debug_info.dwo and .debug_types.dwo sections to go over 4GB by checking for this case and fixing up the DWARFUnitIndex. LLDB's DWARF parser tries to use the llvm's DWARF parser when it can, and LLDB's DWARF parser uses the llvm::DWARFUnitIndex which should allow us to load large .dwp files, but there were a few things missing on the LLDB front: - support for parsing DWARFUnit objects when the offset exceeds 4GB due to a 32 bit truncation issue - not populating the required DWARF sections when we call DWARFContext::GetAsLLVM() which didn't allow the fixups to happen as the data was missing. This patch fixes these issues and now allows LLDB to parse large .dwp files without issues. The issue was discovered when running the "target modules dump separate-debug-info" command on one of these binaries that used a large .dwp file. This is unfortunately hard to test without creating a huge .dwp file, so there are currently no tests for this that I can think of adding that wouldn't cause disk space constraints or making testing times longer by producing a huge .dwp file.
1 parent 8f564a1 commit ce00133

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ llvm::DWARFContext &DWARFContext::GetAsLLVM() {
142142
AddSection("debug_line_str", getOrLoadLineStrData());
143143
AddSection("debug_cu_index", getOrLoadCuIndexData());
144144
AddSection("debug_tu_index", getOrLoadTuIndexData());
145-
145+
if (isDwo()) {
146+
AddSection("debug_info.dwo", getOrLoadDebugInfoData());
147+
AddSection("debug_types.dwo", getOrLoadDebugTypesData());
148+
}
146149
m_llvm_context = llvm::DWARFContext::create(section_map, addr_size);
147150
}
148151
return *m_llvm_context;

lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class DWARFUnitHeader {
7676
return m_unit_type == llvm::dwarf::DW_UT_type ||
7777
m_unit_type == llvm::dwarf::DW_UT_split_type;
7878
}
79-
uint32_t GetNextUnitOffset() const { return m_offset + m_length + 4; }
79+
dw_offset_t GetNextUnitOffset() const { return m_offset + m_length + 4; }
8080

8181
llvm::Error ApplyIndexEntry(const llvm::DWARFUnitIndex::Entry *index_entry);
8282

@@ -157,7 +157,7 @@ class DWARFUnit : public UserID {
157157
// Size of the CU data (without initial length and without header).
158158
size_t GetDebugInfoSize() const;
159159
// Size of the CU data incl. header but without initial length.
160-
uint32_t GetLength() const { return m_header.GetLength(); }
160+
dw_offset_t GetLength() const { return m_header.GetLength(); }
161161
uint16_t GetVersion() const { return m_header.GetVersion(); }
162162
const llvm::DWARFAbbreviationDeclarationSet *GetAbbreviations() const;
163163
dw_offset_t GetAbbrevOffset() const;

0 commit comments

Comments
 (0)