Index: lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -39,14 +39,14 @@ DIERef::DIERef(const DWARFFormValue &form_value) : cu_offset(DW_INVALID_OFFSET), die_offset(DW_INVALID_OFFSET) { if (form_value.IsValid()) { - const DWARFUnit *dwarf_cu = form_value.GetCompileUnit(); - if (dwarf_cu) { - if (dwarf_cu->GetBaseObjOffset() != DW_INVALID_OFFSET) - cu_offset = dwarf_cu->GetBaseObjOffset(); + DWARFFormValue::CUDIERef cudieref = form_value.Reference(); + die_offset = cudieref.DIEOffset(); + if (cudieref.CU()) { + if (cudieref.CU()->GetBaseObjOffset() != DW_INVALID_OFFSET) + cu_offset = cudieref.CU()->GetBaseObjOffset(); else - cu_offset = dwarf_cu->GetOffset(); + cu_offset = cudieref.CU()->GetOffset(); } - die_offset = form_value.Reference(); } } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -348,7 +348,7 @@ // will have a hard time tracking down an unnammed structure type in // the module DWO file, so we make sure we don't get into this // situation by always resolving typedefs from the DWO file. - const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid)); + const DWARFDIE encoding_die = encoding_uid.Reference().GetDIE(); // First make sure that the die that this is typedef'ed to _is_ just // a declaration (DW_AT_declaration == 1), not a full definition @@ -499,7 +499,7 @@ // Clang sometimes erroneously emits id as objc_object*. In that // case we fix up the type to "id". - const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid)); + const DWARFDIE encoding_die = encoding_uid.Reference().GetDIE(); if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type) { if (const char *struct_name = encoding_die.GetName()) { @@ -1150,7 +1150,7 @@ bool has_template_params = false; DWARFFormValue specification_die_form; DWARFFormValue abstract_origin_die_form; - dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET; + DWARFDIE object_pointer_die; unsigned type_quals = 0; clang::StorageClass storage = @@ -1221,7 +1221,7 @@ break; case DW_AT_object_pointer: - object_pointer_die_offset = form_value.Reference(); + object_pointer_die = form_value.Reference().GetDIE(); break; case DW_AT_allocated: @@ -1254,13 +1254,10 @@ } std::string object_pointer_name; - if (object_pointer_die_offset != DW_INVALID_OFFSET) { - DWARFDIE object_pointer_die = die.GetDIE(object_pointer_die_offset); - if (object_pointer_die) { - const char *object_pointer_name_cstr = object_pointer_die.GetName(); - if (object_pointer_name_cstr) - object_pointer_name = object_pointer_name_cstr; - } + if (object_pointer_die) { + const char *object_pointer_name_cstr = object_pointer_die.GetName(); + if (object_pointer_name_cstr) + object_pointer_name = object_pointer_name_cstr; } DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), @@ -1436,9 +1433,10 @@ LinkDeclContextToDIE(spec_clang_decl_ctx, die); } else { dwarf->GetObjectFile()->GetModule()->ReportWarning( - "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8" PRIx64 + "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x" ") has no decl\n", - die.GetID(), specification_die_form.Reference()); + die.GetID(), + specification_die_form.Reference().DIEOffset()); } type_handled = true; } else if (abstract_origin_die_form.IsValid()) { @@ -1456,9 +1454,10 @@ LinkDeclContextToDIE(abs_clang_decl_ctx, die); } else { dwarf->GetObjectFile()->GetModule()->ReportWarning( - "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8" PRIx64 + "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x" ") has no decl\n", - die.GetID(), abstract_origin_die_form.Reference()); + die.GetID(), + abstract_origin_die_form.Reference().DIEOffset()); } type_handled = true; } else { @@ -1601,8 +1600,7 @@ clang::FunctionDecl *template_function_decl = nullptr; if (abstract_origin_die_form.IsValid()) { - DWARFDIE abs_die = - dwarf->DebugInfo()->GetDIE(DIERef(abstract_origin_die_form)); + DWARFDIE abs_die = abstract_origin_die_form.Reference().GetDIE(); SymbolContext sc; @@ -3084,9 +3082,10 @@ member_byte_offset > parent_byte_size)) { module_sp->ReportError( "0x%8.8" PRIx64 - ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 + ": DW_TAG_member '%s' refers to type 0x%8.8x" " which extends beyond the bounds of 0x%8.8" PRIx64, - die.GetID(), name, encoding_form.Reference(), + die.GetID(), name, + encoding_form.Reference().DIEOffset(), parent_die.GetID()); } @@ -3149,15 +3148,15 @@ if (name) module_sp->ReportError( "0x%8.8" PRIx64 - ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 + ": DW_TAG_member '%s' refers to type 0x%8.8x" " which was unable to be parsed", - die.GetID(), name, encoding_form.Reference()); + die.GetID(), name, encoding_form.Reference().DIEOffset()); else module_sp->ReportError( "0x%8.8" PRIx64 - ": DW_TAG_member refers to type 0x%8.8" PRIx64 + ": DW_TAG_member refers to type 0x%8.8x" " which was unable to be parsed", - die.GetID(), encoding_form.Reference()); + die.GetID(), encoding_form.Reference().DIEOffset()); } } @@ -3267,11 +3266,12 @@ Type *base_class_type = die.ResolveTypeUID(DIERef(encoding_form)); if (base_class_type == NULL) { module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to " - "resolve the base class at 0x%8.8" PRIx64 + "resolve the base class at 0x%8.8x" " from enclosing type 0x%8.8x. \nPlease file " "a bug and attach the file at the start of " "this error message", - die.GetOffset(), encoding_form.Reference(), + die.GetOffset(), + encoding_form.Reference().DIEOffset(), parent_die.GetOffset()); break; } @@ -3564,7 +3564,7 @@ if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value)) - return dwarf->ResolveTypeUID(dwarf->GetDIE(DIERef(form_value)), true); + return dwarf->ResolveTypeUID(form_value.Reference().GetDIE(), true); } } } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h @@ -65,8 +65,8 @@ } dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); } bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const; - uint64_t FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const; - uint64_t FormValueAsUnsigned(dw_attr_t attr, uint64_t fail_value) const; + DWARFFormValue::CUDIERef FormValueAsCUDIERefAtIndex(uint32_t i) const; + DWARFFormValue::CUDIERef FormValueAsCUDIERef(dw_attr_t attr) const; uint32_t FindAttributeIndex(dw_attr_t attr) const; void Clear() { m_infos.clear(); } size_t Size() const { return m_infos.size(); } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp @@ -41,19 +41,18 @@ return form_value.ExtractValue(cu->GetData(), &offset); } -uint64_t DWARFAttributes::FormValueAsUnsigned(dw_attr_t attr, - uint64_t fail_value) const { +DWARFFormValue::CUDIERef +DWARFAttributes::FormValueAsCUDIERef(dw_attr_t attr) const { const uint32_t attr_idx = FindAttributeIndex(attr); if (attr_idx != UINT32_MAX) - return FormValueAsUnsignedAtIndex(attr_idx, fail_value); - return fail_value; + return FormValueAsCUDIERefAtIndex(attr_idx); + return {}; } -uint64_t -DWARFAttributes::FormValueAsUnsignedAtIndex(uint32_t i, - uint64_t fail_value) const { +DWARFFormValue::CUDIERef +DWARFAttributes::FormValueAsCUDIERefAtIndex(uint32_t i) const { DWARFFormValue form_value; if (ExtractFormValueAtIndex(i, form_value)) return form_value.Reference(); - return fail_value; + return {}; } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h @@ -11,6 +11,7 @@ #include "lldb/Core/dwarf.h" #include "lldb/lldb-types.h" +#include "DWARFFormValue.h" struct DIERef; class DWARFASTParser; @@ -113,8 +114,8 @@ uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const; - uint64_t GetAttributeValueAsReference(const dw_attr_t attr, - uint64_t fail_value) const; + DWARFFormValue::CUDIERef GetAttributeValueAsCUDIERef( + const dw_attr_t attr) const; uint64_t GetAttributeValueAsAddress(const dw_attr_t attr, uint64_t fail_value) const; Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp @@ -56,13 +56,12 @@ return fail_value; } -uint64_t DWARFBaseDIE::GetAttributeValueAsReference(const dw_attr_t attr, - uint64_t fail_value) const { +DWARFFormValue::CUDIERef DWARFBaseDIE::GetAttributeValueAsCUDIERef( + const dw_attr_t attr) const { if (IsValid()) - return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr, - fail_value); + return m_die->GetAttributeValueAsCUDIERef(GetDWARF(), GetCU(), attr); else - return fail_value; + return {}; } uint64_t DWARFBaseDIE::GetAttributeValueAsAddress(const dw_attr_t attr, Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -112,12 +112,7 @@ DWARFDIE DWARFDIE::GetReferencedDIE(const dw_attr_t attr) const { - const dw_offset_t die_offset = - GetAttributeValueAsReference(attr, DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) - return GetDIE(die_offset); - else - return DWARFDIE(); + return GetAttributeValueAsCUDIERef(attr).GetDIE(); } DWARFDIE @@ -137,7 +132,7 @@ DWARFFormValue form_value; if (m_die->GetAttributeValue(dwarf, cu, attr, form_value, nullptr, check_specification_or_abstract_origin)) - return dwarf->GetDIE(DIERef(form_value)); + return form_value.Reference().GetDIE(); } return DWARFDIE(); } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h @@ -103,9 +103,9 @@ const dw_attr_t attr, uint64_t fail_value, bool check_specification_or_abstract_origin = false) const; - uint64_t GetAttributeValueAsReference( + DWARFFormValue::CUDIERef GetAttributeValueAsCUDIERef( SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu, - const dw_attr_t attr, uint64_t fail_value, + const dw_attr_t attr, bool check_specification_or_abstract_origin = false) const; uint64_t GetAttributeValueAsAddress( Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -693,16 +693,16 @@ case DW_AT_abstract_origin: case DW_AT_specification: { - uint64_t abstract_die_offset = form_value.Reference(); + DWARFFormValue::CUDIERef abstract_die = form_value.Reference(); form_value.Dump(s); - // *ostrm_ptr << HEX32 << abstract_die_offset << " ( "; - GetName(dwarf2Data, cu, abstract_die_offset, s); + // *ostrm_ptr << HEX32 << abstract_die.DIEOffset() << " ( "; + GetName(dwarf2Data, abstract_die.CU() , abstract_die.DIEOffset(), s); } break; case DW_AT_type: { - uint64_t type_die_offset = form_value.Reference(); + DWARFFormValue::CUDIERef type_die = form_value.Reference(); s.PutCString(" ( "); - AppendTypeName(dwarf2Data, cu, type_die_offset, s); + AppendTypeName(dwarf2Data, type_die.CU(), type_die.DIEOffset(), s); s.PutCString(" )"); } break; @@ -734,13 +734,6 @@ const DWARFAbbreviationDeclaration *abbrevDecl = nullptr; lldb::offset_t offset = 0; if (cu) { - if (m_tag != DW_TAG_compile_unit && m_tag != DW_TAG_partial_unit) { - SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile(); - if (dwo_symbol_file) - return GetAttributes(dwo_symbol_file->GetCompileUnit(), - fixed_form_sizes, attributes, curr_depth); - } - dwarf2Data = cu->GetSymbolFileDWARF(); abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset); } @@ -779,9 +772,7 @@ if ((attr == DW_AT_specification) || (attr == DW_AT_abstract_origin)) { if (form_value.ExtractValue(debug_info_data, &offset)) { - dw_offset_t die_offset = form_value.Reference(); - DWARFDIE spec_die = - const_cast(cu)->GetDIE(die_offset); + DWARFDIE spec_die = form_value.Reference().GetDIE(); if (spec_die) spec_die.GetAttributes(attributes, curr_depth + 1); } @@ -845,8 +836,7 @@ if (check_specification_or_abstract_origin) { if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value)) { - DWARFDIE die = - const_cast(cu)->GetDIE(form_value.Reference()); + DWARFDIE die = form_value.Reference().GetDIE(); if (die) { dw_offset_t die_offset = die.GetDIE()->GetAttributeValue( die.GetDWARF(), die.GetCU(), attr, form_value, end_attr_offset_ptr, @@ -857,8 +847,7 @@ } if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value)) { - DWARFDIE die = - const_cast(cu)->GetDIE(form_value.Reference()); + DWARFDIE die = form_value.Reference().GetDIE(); if (die) { dw_offset_t die_offset = die.GetDIE()->GetAttributeValue( die.GetDWARF(), die.GetCU(), attr, form_value, end_attr_offset_ptr, @@ -916,19 +905,18 @@ return fail_value; } -// GetAttributeValueAsReference +// GetAttributeValueAsCUDIERef // // Get the value of an attribute as reference and fix up and compile unit // relative offsets as needed. -uint64_t DWARFDebugInfoEntry::GetAttributeValueAsReference( +DWARFFormValue::CUDIERef DWARFDebugInfoEntry::GetAttributeValueAsCUDIERef( SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu, - const dw_attr_t attr, uint64_t fail_value, - bool check_specification_or_abstract_origin) const { + const dw_attr_t attr, bool check_specification_or_abstract_origin) const { DWARFFormValue form_value; if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin)) return form_value.Reference(); - return fail_value; + return {}; } uint64_t DWARFDebugInfoEntry::GetAttributeValueAsAddress( @@ -1207,8 +1195,9 @@ // Follow the DW_AT_type if possible DWARFFormValue form_value; if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_type, form_value)) { - uint64_t next_die_offset = form_value.Reference(); - result = AppendTypeName(dwarf2Data, cu, next_die_offset, s); + DWARFFormValue::CUDIERef next_die_ref = form_value.Reference(); + result = AppendTypeName(dwarf2Data, + next_die_ref.CU(), next_die_ref.DIEOffset(), s); } switch (abbrevDecl->Tag()) { @@ -1353,28 +1342,20 @@ } } - dw_offset_t die_offset; - - die_offset = - attributes.FormValueAsUnsigned(DW_AT_specification, DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) { - DWARFDIE spec_die = cu->GetDIE(die_offset); - if (spec_die) { - DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE(); - if (decl_ctx_die) - return decl_ctx_die; - } + DWARFDIE spec_die = attributes.FormValueAsCUDIERef( + DW_AT_specification).GetDIE(); + if (spec_die) { + DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE(); + if (decl_ctx_die) + return decl_ctx_die; } - die_offset = attributes.FormValueAsUnsigned(DW_AT_abstract_origin, - DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) { - DWARFDIE abs_die = cu->GetDIE(die_offset); - if (abs_die) { - DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE(); - if (decl_ctx_die) - return decl_ctx_die; - } + DWARFDIE abs_die = attributes.FormValueAsCUDIERef( + DW_AT_abstract_origin).GetDIE(); + if (abs_die) { + DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE(); + if (decl_ctx_die) + return decl_ctx_die; } die = die.GetParent(); Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h @@ -14,6 +14,7 @@ class DWARFUnit; class SymbolFileDWARF; +class DWARFDIE; class DWARFFormValue { public: @@ -54,10 +55,25 @@ eValueTypeBlock }; + class CUDIERef { + public: + CUDIERef(const DWARFUnit *cu, dw_offset_t die_offset) + : m_cu(cu), m_die_offset(die_offset) { + assert(m_cu != nullptr); + } + CUDIERef() : m_cu(nullptr), m_die_offset(DW_INVALID_OFFSET) {} + const DWARFUnit *CU() const { return m_cu; } + dw_offset_t DIEOffset() const { return m_die_offset; } + DWARFDIE GetDIE() const; + explicit operator bool() const { return m_cu != nullptr; } + private: + const DWARFUnit *const m_cu; + dw_offset_t const m_die_offset; + }; + DWARFFormValue(); DWARFFormValue(const DWARFUnit *cu); DWARFFormValue(const DWARFUnit *cu, dw_form_t form); - const DWARFUnit *GetCompileUnit() const { return m_cu; } void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; } dw_form_t Form() const { return m_form; } dw_form_t& FormRef() { return m_form; } @@ -70,7 +86,7 @@ bool ExtractValue(const lldb_private::DWARFDataExtractor &data, lldb::offset_t *offset_ptr); const uint8_t *BlockData() const; - uint64_t Reference() const; + CUDIERef Reference() const; uint64_t Reference(dw_offset_t offset) const; bool Boolean() const { return m_value.value.uval != 0; } uint64_t Unsigned() const { return m_value.value.uval; } @@ -93,7 +109,9 @@ static bool FormIsSupported(dw_form_t form); protected: - const DWARFUnit *m_cu; // Compile unit for this form + // Compile unit where m_value was located. + // It may be different from compile unit where m_value refers to. + const DWARFUnit *m_cu; dw_form_t m_form; // Form for this value ValueType m_value; // Contains all data for the form }; Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -8,9 +8,12 @@ #include +#include "lldb/Core/Module.h" #include "lldb/Core/dwarf.h" +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/Stream.h" +#include "DWARFDebugInfo.h" #include "DWARFUnit.h" #include "DWARFFormValue.h" @@ -552,7 +555,7 @@ return symbol_file->get_debug_addr_data().GetMaxU64(&offset, index_size); } -uint64_t DWARFFormValue::Reference() const { +DWARFFormValue::CUDIERef DWARFFormValue::Reference() const { uint64_t value = m_value.value.uval; switch (m_form) { case DW_FORM_ref1: @@ -562,15 +565,29 @@ case DW_FORM_ref_udata: assert(m_cu); // CU must be valid for DW_FORM_ref forms that are compile // unit relative or we will get this wrong - return value + m_cu->GetOffset(); + value += m_cu->GetOffset(); + if (!m_cu->ContainsDIEOffset(value)) { + m_cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError( + "DW_FORM_ref* DIE reference 0x%" PRIx64 " is outside of its CU", + value); + return CUDIERef(); + } + return CUDIERef(m_cu, value); - case DW_FORM_ref_addr: - case DW_FORM_ref_sig8: - case DW_FORM_GNU_ref_alt: - return value; + case DW_FORM_ref_addr: { + DWARFUnit *ref_cu = m_cu->GetSymbolFileDWARF()->DebugInfo() + ->GetUnitContainingDIEOffset(value); + if (!ref_cu) { + m_cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError( + "DW_FORM_ref_addr DIE reference 0x%" PRIx64 " has no matching CU", + value); + return CUDIERef(); + } + return CUDIERef(ref_cu, value); + } default: - return DW_INVALID_OFFSET; + return CUDIERef(); } } @@ -697,8 +714,8 @@ case DW_FORM_ref4: case DW_FORM_ref8: case DW_FORM_ref_udata: { - uint64_t a = a_value.Reference(); - uint64_t b = b_value.Reference(); + uint64_t a = a_value.m_value.value.uval; + uint64_t b = b_value.m_value.value.uval; if (a < b) return -1; if (a > b) @@ -759,3 +776,9 @@ } return false; } + +DWARFDIE DWARFFormValue::CUDIERef::GetDIE() const { + if (!m_cu) + return DWARFDIE(); + return const_cast(m_cu)->GetDIE(m_die_offset); +} Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -550,12 +550,10 @@ if (die_offset == (*pos).GetOffset()) return DWARFDIE(this, &(*pos)); } - } else { - // Don't specify the compile unit offset as we don't know it because the - // DIE belongs to - // a different compile unit in the same symbol file. - return m_dwarf->DebugInfo()->GetDIEForDIEOffset(die_offset); - } + } else + GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError( + "GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32, + die_offset, GetOffset()); } return DWARFDIE(); // Not found } Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3309,7 +3309,7 @@ } } break; case DW_AT_specification: - spec_die = GetDIE(DIERef(form_value)); + spec_die = form_value.Reference().GetDIE(); break; case DW_AT_start_scope: { if (form_value.Form() == DW_FORM_sec_offset) { @@ -3584,13 +3584,12 @@ case DW_TAG_subprogram: case DW_TAG_inlined_subroutine: case DW_TAG_lexical_block: { - if (die.GetAttributeValueAsReference( - DW_AT_specification, DW_INVALID_OFFSET) == spec_block_die_offset) + if (die.GetAttributeValueAsCUDIERef( + DW_AT_specification).DIEOffset() == spec_block_die_offset) return die; - if (die.GetAttributeValueAsReference(DW_AT_abstract_origin, - DW_INVALID_OFFSET) == - spec_block_die_offset) + if (die.GetAttributeValueAsCUDIERef( + DW_AT_abstract_origin).DIEOffset() == spec_block_die_offset) return die; } break; }