Summary: With the last round of refactors, supporting type units in dwo files becomes almost trivial. This patch contains a couple of small fixes, which taken as a whole make type units work in the split dwarf scenario (both DWARF4 and DWARF5): - DWARFContext: make sure we actually read the debug_types.dwo section - DWARFUnit: set string offsets base on all units in the dwo file, not just the main CU - ManualDWARFIndex: index all units in the file - SymbolFileDWARFDwo: Search for the single compile unit in the file, as we can no longer assume it will be the first one The last part makes it obvious that there is still some work to be done here, namely that we do not support dwo files with multiple compile units. That is something that should be easier after the DIERef refactors, but it still requires more work. Tests are added for the type units+split dwarf + dwarf4/5 scenarios, as well as a test that checks we behave reasonably in the presence of dwo files with multiple CUs. Reviewers: clayborg, JDevlieghere, aprantl Subscribers: arphaman, lldb-commits Differential Revision: https://reviews.llvm.org/D63643 llvm-svn: 364274
103 lines
3.6 KiB
C++
103 lines
3.6 KiB
C++
//===-- DWARFContext.cpp ----------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "DWARFContext.h"
|
|
|
|
#include "lldb/Core/Section.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
static DWARFDataExtractor LoadSection(SectionList *section_list,
|
|
SectionType section_type) {
|
|
if (!section_list)
|
|
return DWARFDataExtractor();
|
|
|
|
auto section_sp = section_list->FindSectionByType(section_type, true);
|
|
if (!section_sp)
|
|
return DWARFDataExtractor();
|
|
|
|
DWARFDataExtractor data;
|
|
section_sp->GetSectionData(data);
|
|
return data;
|
|
}
|
|
|
|
const DWARFDataExtractor &
|
|
DWARFContext::LoadOrGetSection(SectionType main_section_type,
|
|
llvm::Optional<SectionType> dwo_section_type,
|
|
SectionData &data) {
|
|
llvm::call_once(data.flag, [&] {
|
|
if (dwo_section_type && isDwo())
|
|
data.data = LoadSection(m_dwo_section_list, *dwo_section_type);
|
|
else
|
|
data.data = LoadSection(m_main_section_list, main_section_type);
|
|
});
|
|
return data.data;
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadAbbrevData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugAbbrev,
|
|
eSectionTypeDWARFDebugAbbrevDwo, m_data_debug_abbrev);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugAranges, llvm::None,
|
|
m_data_debug_aranges);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadAddrData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugAddr, llvm::None,
|
|
m_data_debug_addr);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugInfo,
|
|
eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadLineData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugLine, llvm::None,
|
|
m_data_debug_line);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadLineStrData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugLineStr, llvm::None,
|
|
m_data_debug_line_str);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadMacroData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugMacro, llvm::None,
|
|
m_data_debug_macro);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadRangesData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugRanges, llvm::None,
|
|
m_data_debug_ranges);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadRngListsData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugRngLists, llvm::None,
|
|
m_data_debug_rnglists);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadStrData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugStr,
|
|
eSectionTypeDWARFDebugStrDwo, m_data_debug_str);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadStrOffsetsData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugStrOffsets,
|
|
eSectionTypeDWARFDebugStrOffsetsDwo,
|
|
m_data_debug_str_offsets);
|
|
}
|
|
|
|
const DWARFDataExtractor &DWARFContext::getOrLoadDebugTypesData() {
|
|
return LoadOrGetSection(eSectionTypeDWARFDebugTypes,
|
|
eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
|
|
}
|