LLDB  mainline
DIERef.cpp
Go to the documentation of this file.
1 //===-- DIERef.cpp ----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "DIERef.h"
10 #include "DWARFUnit.h"
11 #include "DWARFDebugInfo.h"
12 #include "DWARFFormValue.h"
13 #include "SymbolFileDWARF.h"
15 
17  : cu_offset(DW_INVALID_OFFSET), die_offset(uid & 0xffffffff) {
18  SymbolFileDWARFDebugMap *debug_map = dwarf->GetDebugMapSymfile();
19  if (debug_map) {
20  const uint32_t oso_idx = debug_map->GetOSOIndexFromUserID(uid);
21  SymbolFileDWARF *actual_dwarf = debug_map->GetSymbolFileByOSOIndex(oso_idx);
22  if (actual_dwarf) {
23  DWARFDebugInfo *debug_info = actual_dwarf->DebugInfo();
24  if (debug_info) {
25  DWARFUnit *dwarf_cu =
27  if (dwarf_cu) {
28  cu_offset = dwarf_cu->GetOffset();
29  return;
30  }
31  }
32  }
34  } else {
35  cu_offset = uid >> 32;
36  }
37 }
38 
39 DIERef::DIERef(const DWARFFormValue &form_value)
41  if (form_value.IsValid()) {
42  const DWARFUnit *dwarf_cu = form_value.GetCompileUnit();
43  if (dwarf_cu) {
44  if (dwarf_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
45  cu_offset = dwarf_cu->GetBaseObjOffset();
46  else
47  cu_offset = dwarf_cu->GetOffset();
48  }
49  die_offset = form_value.Reference();
50  }
51 }
52 
54  // Each SymbolFileDWARF will set its ID to what is expected.
55  //
56  // SymbolFileDWARF, when used for DWARF with .o files on MacOSX, has the
57  // ID set to the compile unit index.
58  //
59  // SymbolFileDWARFDwo sets the ID to the compile unit offset.
60  if (dwarf && die_offset != DW_INVALID_OFFSET)
61  return dwarf->GetID() | die_offset;
62  else
63  return LLDB_INVALID_UID;
64 }
static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid)
DWARFUnit * GetCompileUnitContainingDIEOffset(dw_offset_t die_offset)
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:49
#define LLDB_INVALID_UID
Definition: lldb-defines.h:91
dw_offset_t die_offset
Definition: DIERef.h:48
SymbolFileDWARFDebugMap * GetDebugMapSymfile()
uint64_t user_id_t
Definition: lldb-types.h:84
uint64_t Reference() const
bool IsValid() const
SymbolFileDWARF * GetSymbolFileByOSOIndex(uint32_t oso_idx)
DWARFDebugInfo * DebugInfo()
dw_offset_t GetOffset() const
Definition: DWARFUnit.h:76
lldb::user_id_t GetUID(SymbolFileDWARF *dwarf) const
Definition: DIERef.cpp:53
dw_offset_t cu_offset
Definition: DIERef.h:47
DIERef()=default
#define DW_INVALID_OFFSET
Definition: dwarf.h:34
dw_offset_t GetBaseObjOffset() const
Definition: DWARFUnit.cpp:771
const DWARFUnit * GetCompileUnit() const