DWARFUnit *dwo_cu = dwo_symbol_file->GetCompileUnit();
if (!dwo_cu)
return; // Can't fetch the compile unit from the dwo file.
+ dwo_cu->SetUserData(this);
DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
if (!dwo_cu_die.IsValid())
void *DWARFUnit::GetUserData() const { return m_user_data; }
-void DWARFUnit::SetUserData(void *d) {
- m_user_data = d;
- if (m_dwo_symbol_file)
- m_dwo_symbol_file->GetCompileUnit()->SetUserData(d);
-}
+void DWARFUnit::SetUserData(void *d) { m_user_data = d; }
bool DWARFUnit::Supports_DW_AT_APPLE_objc_complete_type() {
return GetProducer() != eProducerLLVMGCC;
DIERef::Section section, lldb::offset_t *offset_ptr);
virtual ~DWARFUnit();
+ bool IsDWOUnit() { return m_is_dwo; }
+
void ExtractUnitDIEIfNeeded();
void ExtractDIEsIfNeeded();
void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
assert(
- !unit.GetSymbolFileDWARF().GetBaseCompileUnit() &&
+ !unit.IsDWOUnit() &&
"DWARFUnit associated with .dwo or .dwp should not be indexed directly");
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS);
// We already parsed this compile unit, had out a shared pointer to it
cu_sp = comp_unit->shared_from_this();
} else {
- if (&dwarf_cu.GetSymbolFileDWARF() != this) {
- return dwarf_cu.GetSymbolFileDWARF().ParseCompileUnit(dwarf_cu);
- } else if (dwarf_cu.GetOffset() == 0 && GetDebugMapSymfile()) {
+ if (dwarf_cu.GetOffset() == 0 && GetDebugMapSymfile()) {
// Let the debug map create the compile unit
cu_sp = m_debug_map_symfile->GetCompileUnit(this);
dwarf_cu.SetUserData(cu_sp.get());
CompileUnit *
SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu) {
+ DWARFCompileUnit *non_dwo_cu =
+ dwarf_cu.IsDWOUnit()
+ ? static_cast<DWARFCompileUnit *>(dwarf_cu.GetUserData())
+ : &dwarf_cu;
// Check if the symbol vendor already knows about this compile unit?
- if (dwarf_cu.GetUserData() == nullptr) {
+ if (non_dwo_cu->GetUserData() == nullptr) {
// The symbol vendor doesn't know about this compile unit, we need to parse
// and add it to the symbol vendor object.
- return ParseCompileUnit(dwarf_cu).get();
+ return ParseCompileUnit(*non_dwo_cu).get();
}
- return (CompileUnit *)dwarf_cu.GetUserData();
+ return static_cast<CompileUnit *>(non_dwo_cu->GetUserData());
}
size_t SymbolFileDWARF::GetObjCMethodDIEOffsets(ConstString class_name,
if (dwo_obj_file == nullptr)
return nullptr;
- return std::make_unique<SymbolFileDWARFDwo>(dwo_obj_file, *dwarf_cu);
+ return std::make_unique<SymbolFileDWARFDwo>(*this, dwo_obj_file,
+ dwarf_cu->GetID());
}
void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
static DWARFDIE GetParentSymbolContextDIE(const DWARFDIE &die);
- virtual lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu);
-
lldb::ModuleSP GetExternalModule(lldb_private::ConstString name);
typedef std::map<lldb_private::ConstString, lldb::ModuleSP>
GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
const DWARFDebugInfoEntry &cu_die);
- // For regular SymbolFileDWARF instances the method returns nullptr,
- // for the instances of the subclass SymbolFileDWARFDwo
- // the method returns a pointer to the base compile unit.
- virtual DWARFCompileUnit *GetBaseCompileUnit() { return nullptr; }
-
virtual llvm::Optional<uint32_t> GetDwoNum() { return llvm::None; }
/// If this is a DWARF object with a single CU, return its DW_AT_dwo_id.
lldb_private::TypeList &GetTypeList() override;
+ lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu);
+
virtual DWARFUnit *
GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit);
char SymbolFileDWARFDwo::ID;
-SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile,
- DWARFCompileUnit &dwarf_cu)
+SymbolFileDWARFDwo::SymbolFileDWARFDwo(SymbolFileDWARF &base_symbol_file,
+ ObjectFileSP objfile, uint32_t id)
: SymbolFileDWARF(objfile, objfile->GetSectionList(
/*update_module_section_list*/ false)),
- m_base_dwarf_cu(dwarf_cu) {
- SetID(((lldb::user_id_t)dwarf_cu.GetID()) << 32);
+ m_base_symbol_file(base_symbol_file) {
+ SetID(user_id_t(id) << 32);
}
void SymbolFileDWARFDwo::LoadSectionData(lldb::SectionType sect_type,
SymbolFileDWARF::LoadSectionData(sect_type, data);
}
-lldb::CompUnitSP
-SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
- assert(GetCompileUnit() == &dwarf_cu &&
- "SymbolFileDWARFDwo::ParseCompileUnit called with incompatible "
- "compile unit");
- return GetBaseSymbolFile().ParseCompileUnit(m_base_dwarf_cu);
-}
-
DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
if (!m_cu)
m_cu = ComputeCompileUnit();
die, type_name, must_be_implementation);
}
-SymbolFileDWARF &SymbolFileDWARFDwo::GetBaseSymbolFile() {
- return m_base_dwarf_cu.GetSymbolFileDWARF();
-}
-
llvm::Expected<TypeSystem &>
SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
return GetBaseSymbolFile().GetTypeSystemForLanguage(language);
static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
/// \}
- SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu);
+ SymbolFileDWARFDwo(SymbolFileDWARF &m_base_symbol_file,
+ lldb::ObjectFileSP objfile, uint32_t id);
~SymbolFileDWARFDwo() override = default;
- lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu) override;
-
DWARFCompileUnit *GetCompileUnit();
DWARFUnit *
DWARFDIE
GetDIE(const DIERef &die_ref) override;
- DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
-
llvm::Optional<uint32_t> GetDwoNum() override { return GetID() >> 32; }
protected:
const DWARFDIE &die, lldb_private::ConstString type_name,
bool must_be_implementation) override;
- SymbolFileDWARF &GetBaseSymbolFile();
+ SymbolFileDWARF &GetBaseSymbolFile() { return m_base_symbol_file; }
DWARFCompileUnit *ComputeCompileUnit();
- DWARFCompileUnit &m_base_dwarf_cu;
+ SymbolFileDWARF &m_base_symbol_file;
DWARFCompileUnit *m_cu = nullptr;
};
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/LLDBAssert.h"
-#include "DWARFUnit.h"
+#include "DWARFCompileUnit.h"
#include "DWARFDebugInfo.h"
using namespace lldb;
ObjectFileSP objfile,
DWARFCompileUnit &dwarf_cu,
uint64_t dwo_id)
- : SymbolFileDWARFDwo(objfile, dwarf_cu), m_dwp_symfile(dwp_symfile),
- m_dwo_id(dwo_id) {}
+ : SymbolFileDWARFDwo(dwarf_cu.GetSymbolFileDWARF(), objfile,
+ dwarf_cu.GetID()),
+ m_dwp_symfile(dwp_symfile), m_dwo_id(dwo_id) {}
void SymbolFileDWARFDwoDwp::LoadSectionData(lldb::SectionType sect_type,
DWARFDataExtractor &data) {