1f8aa073dim//===- DWARFDebugPubTable.h -------------------------------------*- C++ -*-===//
234e948adim//
326df4b1dim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
426df4b1dim// See https://llvm.org/LICENSE.txt for license information.
526df4b1dim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
634e948adim//
734e948adim//===----------------------------------------------------------------------===//
834e948adim
9f8aa073dim#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
10f8aa073dim#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
1134e948adim
1234e948adim#include "llvm/ADT/ArrayRef.h"
13f8aa073dim#include "llvm/ADT/StringRef.h"
146bdc653dim#include "llvm/BinaryFormat/Dwarf.h"
1569db237dim#include "llvm/DebugInfo/DWARF/DWARFObject.h"
16f8aa073dim#include <cstdint>
1734e948adim#include <vector>
1834e948adim
1934e948adimnamespace llvm {
2034e948adim
2134e948adimclass raw_ostream;
2234e948adim
2334e948adim/// Represents structure for holding and parsing .debug_pub* tables.
2434e948adimclass DWARFDebugPubTable {
2534e948adimpublic:
2634e948adim  struct Entry {
2734e948adim    /// Section offset from the beginning of the compilation unit.
289f839ebdim    uint64_t SecOffset;
2934e948adim
3034e948adim    /// An entry of the various gnu_pub* debug sections.
31f8aa073dim    dwarf::PubIndexEntryDescriptor Descriptor;
3234e948adim
3334e948adim    /// The name of the object as given by the DW_AT_name attribute of the
3434e948adim    /// referenced DIE.
35d0f7865dim    StringRef Name;
3634e948adim  };
3734e948adim
3834e948adim  /// Each table consists of sets of variable length entries. Each set describes
3934e948adim  /// the names of global objects and functions, or global types, respectively,
4034e948adim  /// whose definitions are represented by debugging information entries owned
4134e948adim  /// by a single compilation unit.
4234e948adim  struct Set {
4334e948adim    /// The total length of the entries for that set, not including the length
4434e948adim    /// field itself.
4534e948adim    uint32_t Length;
4634e948adim
4734e948adim    /// This number is specific to the name lookup table and is independent of
4834e948adim    /// the DWARF version number.
4934e948adim    uint16_t Version;
5034e948adim
5134e948adim    /// The offset from the beginning of the .debug_info section of the
5234e948adim    /// compilation unit header referenced by the set.
539f839ebdim    uint64_t Offset;
5434e948adim
5534e948adim    /// The size in bytes of the contents of the .debug_info section generated
5634e948adim    /// to represent that compilation unit.
5734e948adim    uint32_t Size;
5834e948adim
5934e948adim    std::vector<Entry> Entries;
6034e948adim  };
6134e948adim
6234e948adimprivate:
6334e948adim  std::vector<Set> Sets;
6434e948adim
6534e948adim  /// gnu styled tables contains additional information.
6634e948adim  /// This flag determines whether or not section we parse is debug_gnu* table.
6734e948adim  bool GnuStyle;
6834e948adim
6934e948adimpublic:
7069db237dim  DWARFDebugPubTable(const DWARFObject &Obj, const DWARFSection &Sec,
7169db237dim                     bool LittleEndian, bool GnuStyle);
72f8aa073dim
7308d5894dim  void dump(raw_ostream &OS) const;
7434e948adim
7534e948adim  ArrayRef<Set> getData() { return Sets; }
7634e948adim};
7734e948adim
78f8aa073dim} // end namespace llvm
79f8aa073dim
80f8aa073dim#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
81