DWARFDebugPubTable.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DWARFDebugPubTable.h -------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
  14. #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
  15. #include "llvm/ADT/ArrayRef.h"
  16. #include "llvm/ADT/StringRef.h"
  17. #include "llvm/BinaryFormat/Dwarf.h"
  18. #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
  19. #include "llvm/DebugInfo/DWARF/DWARFObject.h"
  20. #include <cstdint>
  21. #include <vector>
  22. namespace llvm {
  23. class raw_ostream;
  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.
  29. uint64_t SecOffset;
  30. /// An entry of the various gnu_pub* debug sections.
  31. dwarf::PubIndexEntryDescriptor Descriptor;
  32. /// The name of the object as given by the DW_AT_name attribute of the
  33. /// referenced DIE.
  34. StringRef Name;
  35. };
  36. /// Each table consists of sets of variable length entries. Each set describes
  37. /// the names of global objects and functions, or global types, respectively,
  38. /// whose definitions are represented by debugging information entries owned
  39. /// by a single compilation unit.
  40. struct Set {
  41. /// The total length of the entries for that set, not including the length
  42. /// field itself.
  43. uint64_t Length;
  44. /// The DWARF format of the set.
  45. dwarf::DwarfFormat Format;
  46. /// This number is specific to the name lookup table and is independent of
  47. /// the DWARF version number.
  48. uint16_t Version;
  49. /// The offset from the beginning of the .debug_info section of the
  50. /// compilation unit header referenced by the set.
  51. uint64_t Offset;
  52. /// The size in bytes of the contents of the .debug_info section generated
  53. /// to represent that compilation unit.
  54. uint64_t Size;
  55. std::vector<Entry> Entries;
  56. };
  57. private:
  58. std::vector<Set> Sets;
  59. /// gnu styled tables contains additional information.
  60. /// This flag determines whether or not section we parse is debug_gnu* table.
  61. bool GnuStyle = false;
  62. public:
  63. DWARFDebugPubTable() = default;
  64. void extract(DWARFDataExtractor Data, bool GnuStyle,
  65. function_ref<void(Error)> RecoverableErrorHandler);
  66. void dump(raw_ostream &OS) const;
  67. ArrayRef<Set> getData() { return Sets; }
  68. };
  69. } // end namespace llvm
  70. #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
  71. #ifdef __GNUC__
  72. #pragma GCC diagnostic pop
  73. #endif