1 //===-- DIERef.h ------------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef SymbolFileDWARF_DIERef_h_
10 #define SymbolFileDWARF_DIERef_h_
12 #include "lldb/Core/dwarf.h"
13 #include "llvm/ADT/Optional.h"
14 #include "llvm/Support/FormatProviders.h"
18 /// Identifies a DWARF debug info entry within a given Module. It contains three
20 /// - dwo_num: identifies the dwo file in the Module. If this field is not set,
21 /// the DIERef references the main file.
22 /// - section: identifies the section of the debug info entry in the given file:
23 /// debug_info or debug_types.
24 /// - die_offset: The offset of the debug info entry as an absolute offset from
25 /// the beginning of the section specified in the section field.
28 enum Section : uint8_t { DebugInfo, DebugTypes };
30 DIERef(llvm::Optional<uint32_t> dwo_num, Section section,
31 dw_offset_t die_offset)
32 : m_dwo_num(dwo_num.getValueOr(0)), m_dwo_num_valid(bool(dwo_num)),
33 m_section(section), m_die_offset(die_offset) {
34 assert(this->dwo_num() == dwo_num && "Dwo number out of range?");
37 llvm::Optional<uint32_t> dwo_num() const {
43 Section section() const { return static_cast<Section>(m_section); }
45 dw_offset_t die_offset() const { return m_die_offset; }
48 uint32_t m_dwo_num : 30;
49 uint32_t m_dwo_num_valid : 1;
50 uint32_t m_section : 1;
51 dw_offset_t m_die_offset;
53 static_assert(sizeof(DIERef) == 8, "");
55 typedef std::vector<DIERef> DIEArray;
58 template<> struct format_provider<DIERef> {
59 static void format(const DIERef &ref, raw_ostream &OS, StringRef Style);
63 #endif // SymbolFileDWARF_DIERef_h_