1 //===-- DIERef.cpp ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "DWARFUnit.h"
12 #include "DWARFDebugInfo.h"
13 #include "DWARFFormValue.h"
14 #include "SymbolFileDWARF.h"
15 #include "SymbolFileDWARFDebugMap.h"
17 DIERef::DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf)
18 : cu_offset(DW_INVALID_OFFSET), die_offset(uid & 0xffffffff) {
19 SymbolFileDWARFDebugMap *debug_map = dwarf->GetDebugMapSymfile();
21 const uint32_t oso_idx = debug_map->GetOSOIndexFromUserID(uid);
22 SymbolFileDWARF *actual_dwarf = debug_map->GetSymbolFileByOSOIndex(oso_idx);
24 DWARFDebugInfo *debug_info = actual_dwarf->DebugInfo();
27 debug_info->GetCompileUnitContainingDIEOffset(die_offset);
29 cu_offset = dwarf_cu->GetOffset();
34 die_offset = DW_INVALID_OFFSET;
36 cu_offset = uid >> 32;
40 DIERef::DIERef(const DWARFFormValue &form_value)
41 : cu_offset(DW_INVALID_OFFSET), die_offset(DW_INVALID_OFFSET) {
42 if (form_value.IsValid()) {
43 const DWARFUnit *dwarf_cu = form_value.GetCompileUnit();
45 if (dwarf_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
46 cu_offset = dwarf_cu->GetBaseObjOffset();
48 cu_offset = dwarf_cu->GetOffset();
50 die_offset = form_value.Reference();
54 lldb::user_id_t DIERef::GetUID(SymbolFileDWARF *dwarf) const {
55 //----------------------------------------------------------------------
56 // Each SymbolFileDWARF will set its ID to what is expected.
58 // SymbolFileDWARF, when used for DWARF with .o files on MacOSX, has the
59 // ID set to the compile unit index.
61 // SymbolFileDWARFDwo sets the ID to the compile unit offset.
62 //----------------------------------------------------------------------
63 if (dwarf && die_offset != DW_INVALID_OFFSET)
64 return dwarf->GetID() | die_offset;
66 return LLDB_INVALID_UID;