SymbolFileDWARFDwo.cpp revision 292932
169408Sache//===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===//
259243Sobrien//
359243Sobrien//                     The LLVM Compiler Infrastructure
459243Sobrien//
559243Sobrien// This file is distributed under the University of Illinois Open Source
659243Sobrien// License. See LICENSE.TXT for details.
759243Sobrien//
859243Sobrien//===----------------------------------------------------------------------===//
959243Sobrien
1059243Sobrien#include "SymbolFileDWARFDwo.h"
1159243Sobrien
1259243Sobrien#include "lldb/Core/Section.h"
1359243Sobrien#include "lldb/Expression/DWARFExpression.h"
1459243Sobrien#include "lldb/Symbol/ObjectFile.h"
1559243Sobrien
1659243Sobrien#include "DWARFCompileUnit.h"
1759243Sobrien#include "DWARFDebugInfo.h"
1859243Sobrien
1959243Sobrienusing namespace lldb;
2059243Sobrienusing namespace lldb_private;
2159243Sobrien
2259243SobrienSymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile, DWARFCompileUnit* dwarf_cu) :
2359243Sobrien    SymbolFileDWARF(objfile.get()),
2459243Sobrien    m_obj_file_sp(objfile),
2559243Sobrien    m_base_dwarf_cu(dwarf_cu)
2659243Sobrien{
2759243Sobrien    SetID(((lldb::user_id_t)dwarf_cu->GetOffset())<<32);
2859243Sobrien}
2959243Sobrien
3059243Sobrienvoid
3159243SobrienSymbolFileDWARFDwo::LoadSectionData (lldb::SectionType sect_type, DWARFDataExtractor& data)
3259243Sobrien{
3359243Sobrien    const SectionList* section_list = m_obj_file->GetSectionList(false /* update_module_section_list */);
3459243Sobrien    if (section_list)
3559243Sobrien    {
3659243Sobrien        SectionSP section_sp (section_list->FindSectionByType(sect_type, true));
3759243Sobrien        if (section_sp)
3859243Sobrien        {
3969408Sache            // See if we memory mapped the DWARF segment?
4059243Sobrien            if (m_dwarf_data.GetByteSize())
4159243Sobrien            {
4259243Sobrien                data.SetData(m_dwarf_data, section_sp->GetOffset(), section_sp->GetFileSize());
4359243Sobrien                return;
4459243Sobrien            }
4559243Sobrien
4659243Sobrien            if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0)
4759243Sobrien                return;
4859243Sobrien
4959243Sobrien            data.Clear();
5059243Sobrien        }
5159243Sobrien    }
5259243Sobrien
5359243Sobrien    SymbolFileDWARF::LoadSectionData(sect_type, data);
5459243Sobrien}
5559243Sobrien
5659243Sobrienlldb::CompUnitSP
5759243SobrienSymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx)
5859243Sobrien{
5959243Sobrien    assert(GetCompileUnit() == dwarf_cu && "SymbolFileDWARFDwo::ParseCompileUnit called with incompatible compile unit");
6059243Sobrien    return GetBaseSymbolFile()->ParseCompileUnit(m_base_dwarf_cu, UINT32_MAX);
6159243Sobrien}
6259243Sobrien
6359243SobrienDWARFCompileUnit*
6459243SobrienSymbolFileDWARFDwo::GetCompileUnit()
6559243Sobrien{
6659243Sobrien    // Only dwo files with 1 compile unit is supported
6759243Sobrien    if (GetNumCompileUnits() == 1)
6859243Sobrien        return DebugInfo()->GetCompileUnitAtIndex(0);
6959243Sobrien    else
7059243Sobrien        return nullptr;
7159243Sobrien}
7259243Sobrien
7359243SobrienDWARFCompileUnit*
7459243SobrienSymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit)
7559243Sobrien{
7659243Sobrien    return GetCompileUnit();
7759243Sobrien}
7859243Sobrien
7959243SobrienSymbolFileDWARF::DIEToTypePtr&
8059243SobrienSymbolFileDWARFDwo::GetDIEToType()
8159243Sobrien{
8259243Sobrien    return GetBaseSymbolFile()->GetDIEToType();
8359243Sobrien}
8459243Sobrien
8559243SobrienSymbolFileDWARF::DIEToVariableSP&
8659243SobrienSymbolFileDWARFDwo::GetDIEToVariable()
8759243Sobrien{
8859243Sobrien    return GetBaseSymbolFile()->GetDIEToVariable();
8959243Sobrien}
9059243Sobrien
9159243SobrienSymbolFileDWARF::DIEToClangType&
9259243SobrienSymbolFileDWARFDwo::GetForwardDeclDieToClangType()
9359243Sobrien{
9459243Sobrien    return GetBaseSymbolFile()->GetForwardDeclDieToClangType();
9559243Sobrien}
9659243Sobrien
9759243SobrienSymbolFileDWARF::ClangTypeToDIE&
9859243SobrienSymbolFileDWARFDwo::GetForwardDeclClangTypeToDie()
9959243Sobrien{
10069408Sache    return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie();
10159243Sobrien}
10259243Sobrien
10359243SobrienUniqueDWARFASTTypeMap&
10459243SobrienSymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap()
10559243Sobrien{
10659243Sobrien    return GetBaseSymbolFile()->GetUniqueDWARFASTTypeMap();
10759243Sobrien}
10859243Sobrien
10959243Sobrienlldb::TypeSP
11059243SobrienSymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx)
11159243Sobrien{
11259243Sobrien    return GetBaseSymbolFile()->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
11359243Sobrien}
11459243Sobrien
11559243SobrienSymbolFileDWARF*
11659243SobrienSymbolFileDWARFDwo::GetBaseSymbolFile()
11759243Sobrien{
11859243Sobrien    return m_base_dwarf_cu->GetSymbolFileDWARF();
11959243Sobrien}
12059243Sobrien
12159243SobrienDWARFExpression::LocationListFormat
12259243SobrienSymbolFileDWARFDwo::GetLocationListFormat() const
12359243Sobrien{
12459243Sobrien    return DWARFExpression::SplitDwarfLocationList;
12559243Sobrien}
12659243Sobrien
12759243SobrienTypeSystem*
12859243SobrienSymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language)
12959243Sobrien{
13059243Sobrien    return GetBaseSymbolFile()->GetTypeSystemForLanguage(language);
13159243Sobrien}
13259243Sobrien