xref: /freebsd/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
10b57cec5SDimitry Andric //===- DWARFDebugPubTable.h -------------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
100b57cec5SDimitry Andric #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "llvm/ADT/ArrayRef.h"
13*81ad6265SDimitry Andric #include "llvm/ADT/STLFunctionalExtras.h"
140b57cec5SDimitry Andric #include "llvm/ADT/StringRef.h"
150b57cec5SDimitry Andric #include "llvm/BinaryFormat/Dwarf.h"
160b57cec5SDimitry Andric #include <cstdint>
170b57cec5SDimitry Andric #include <vector>
180b57cec5SDimitry Andric 
190b57cec5SDimitry Andric namespace llvm {
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric class raw_ostream;
22*81ad6265SDimitry Andric class DWARFDataExtractor;
23*81ad6265SDimitry Andric class Error;
240b57cec5SDimitry Andric 
250b57cec5SDimitry Andric /// Represents structure for holding and parsing .debug_pub* tables.
260b57cec5SDimitry Andric class DWARFDebugPubTable {
270b57cec5SDimitry Andric public:
280b57cec5SDimitry Andric   struct Entry {
290b57cec5SDimitry Andric     /// Section offset from the beginning of the compilation unit.
308bcb0991SDimitry Andric     uint64_t SecOffset;
310b57cec5SDimitry Andric 
320b57cec5SDimitry Andric     /// An entry of the various gnu_pub* debug sections.
330b57cec5SDimitry Andric     dwarf::PubIndexEntryDescriptor Descriptor;
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric     /// The name of the object as given by the DW_AT_name attribute of the
360b57cec5SDimitry Andric     /// referenced DIE.
370b57cec5SDimitry Andric     StringRef Name;
380b57cec5SDimitry Andric   };
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric   /// Each table consists of sets of variable length entries. Each set describes
410b57cec5SDimitry Andric   /// the names of global objects and functions, or global types, respectively,
420b57cec5SDimitry Andric   /// whose definitions are represented by debugging information entries owned
430b57cec5SDimitry Andric   /// by a single compilation unit.
440b57cec5SDimitry Andric   struct Set {
450b57cec5SDimitry Andric     /// The total length of the entries for that set, not including the length
460b57cec5SDimitry Andric     /// field itself.
475ffd83dbSDimitry Andric     uint64_t Length;
485ffd83dbSDimitry Andric 
495ffd83dbSDimitry Andric     /// The DWARF format of the set.
505ffd83dbSDimitry Andric     dwarf::DwarfFormat Format;
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric     /// This number is specific to the name lookup table and is independent of
530b57cec5SDimitry Andric     /// the DWARF version number.
540b57cec5SDimitry Andric     uint16_t Version;
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric     /// The offset from the beginning of the .debug_info section of the
570b57cec5SDimitry Andric     /// compilation unit header referenced by the set.
588bcb0991SDimitry Andric     uint64_t Offset;
590b57cec5SDimitry Andric 
600b57cec5SDimitry Andric     /// The size in bytes of the contents of the .debug_info section generated
610b57cec5SDimitry Andric     /// to represent that compilation unit.
625ffd83dbSDimitry Andric     uint64_t Size;
630b57cec5SDimitry Andric 
640b57cec5SDimitry Andric     std::vector<Entry> Entries;
650b57cec5SDimitry Andric   };
660b57cec5SDimitry Andric 
670b57cec5SDimitry Andric private:
680b57cec5SDimitry Andric   std::vector<Set> Sets;
690b57cec5SDimitry Andric 
700b57cec5SDimitry Andric   /// gnu styled tables contains additional information.
710b57cec5SDimitry Andric   /// This flag determines whether or not section we parse is debug_gnu* table.
725ffd83dbSDimitry Andric   bool GnuStyle = false;
730b57cec5SDimitry Andric 
740b57cec5SDimitry Andric public:
755ffd83dbSDimitry Andric   DWARFDebugPubTable() = default;
765ffd83dbSDimitry Andric 
775ffd83dbSDimitry Andric   void extract(DWARFDataExtractor Data, bool GnuStyle,
785ffd83dbSDimitry Andric                function_ref<void(Error)> RecoverableErrorHandler);
790b57cec5SDimitry Andric 
800b57cec5SDimitry Andric   void dump(raw_ostream &OS) const;
810b57cec5SDimitry Andric 
getData()820b57cec5SDimitry Andric   ArrayRef<Set> getData() { return Sets; }
830b57cec5SDimitry Andric };
840b57cec5SDimitry Andric 
850b57cec5SDimitry Andric } // end namespace llvm
860b57cec5SDimitry Andric 
870b57cec5SDimitry Andric #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
88