Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- DWARFDebugPubTable.h -------------------------------------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H |
| 10 | #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H |
| 11 | |
| 12 | #include "llvm/ADT/ArrayRef.h" |
| 13 | #include "llvm/ADT/StringRef.h" |
| 14 | #include "llvm/BinaryFormat/Dwarf.h" |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 15 | #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 16 | #include "llvm/DebugInfo/DWARF/DWARFObject.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 17 | #include <cstdint> |
| 18 | #include <vector> |
| 19 | |
| 20 | namespace llvm { |
| 21 | |
| 22 | class raw_ostream; |
| 23 | |
| 24 | /// Represents structure for holding and parsing .debug_pub* tables. |
| 25 | class DWARFDebugPubTable { |
| 26 | public: |
| 27 | struct Entry { |
| 28 | /// Section offset from the beginning of the compilation unit. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 29 | uint64_t SecOffset; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 30 | |
| 31 | /// An entry of the various gnu_pub* debug sections. |
| 32 | dwarf::PubIndexEntryDescriptor Descriptor; |
| 33 | |
| 34 | /// The name of the object as given by the DW_AT_name attribute of the |
| 35 | /// referenced DIE. |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 36 | StringRef Name; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | /// Each table consists of sets of variable length entries. Each set describes |
| 40 | /// the names of global objects and functions, or global types, respectively, |
| 41 | /// whose definitions are represented by debugging information entries owned |
| 42 | /// by a single compilation unit. |
| 43 | struct Set { |
| 44 | /// The total length of the entries for that set, not including the length |
| 45 | /// field itself. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 46 | uint64_t Length; |
| 47 | |
| 48 | /// The DWARF format of the set. |
| 49 | dwarf::DwarfFormat Format; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 50 | |
| 51 | /// This number is specific to the name lookup table and is independent of |
| 52 | /// the DWARF version number. |
| 53 | uint16_t Version; |
| 54 | |
| 55 | /// The offset from the beginning of the .debug_info section of the |
| 56 | /// compilation unit header referenced by the set. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 57 | uint64_t Offset; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 58 | |
| 59 | /// The size in bytes of the contents of the .debug_info section generated |
| 60 | /// to represent that compilation unit. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 61 | uint64_t Size; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 62 | |
| 63 | std::vector<Entry> Entries; |
| 64 | }; |
| 65 | |
| 66 | private: |
| 67 | std::vector<Set> Sets; |
| 68 | |
| 69 | /// gnu styled tables contains additional information. |
| 70 | /// This flag determines whether or not section we parse is debug_gnu* table. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 71 | bool GnuStyle = false; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 72 | |
| 73 | public: |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 74 | DWARFDebugPubTable() = default; |
| 75 | |
| 76 | void extract(DWARFDataExtractor Data, bool GnuStyle, |
| 77 | function_ref<void(Error)> RecoverableErrorHandler); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 78 | |
| 79 | void dump(raw_ostream &OS) const; |
| 80 | |
| 81 | ArrayRef<Set> getData() { return Sets; } |
| 82 | }; |
| 83 | |
| 84 | } // end namespace llvm |
| 85 | |
| 86 | #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H |