DWARFDebugPubTable.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/STLFunctionalExtras.h"
  17. #include "llvm/ADT/StringRef.h"
  18. #include "llvm/BinaryFormat/Dwarf.h"
  19. #include <cstdint>
  20. #include <vector>
  21. namespace llvm {
  22. class raw_ostream;
  23. class DWARFDataExtractor;
  24. class Error;
  25. /// Represents structure for holding and parsing .debug_pub* tables.
  26. class DWARFDebugPubTable {
  27. public:
  28. struct Entry {
  29. /// Section offset from the beginning of the compilation unit.
  30. uint64_t SecOffset;
  31. /// An entry of the various gnu_pub* debug sections.
  32. dwarf::PubIndexEntryDescriptor Descriptor;
  33. /// The name of the object as given by the DW_AT_name attribute of the
  34. /// referenced DIE.
  35. StringRef Name;
  36. };
  37. /// Each table consists of sets of variable length entries. Each set describes
  38. /// the names of global objects and functions, or global types, respectively,
  39. /// whose definitions are represented by debugging information entries owned
  40. /// by a single compilation unit.
  41. struct Set {
  42. /// The total length of the entries for that set, not including the length
  43. /// field itself.
  44. uint64_t Length;
  45. /// The DWARF format of the set.
  46. dwarf::DwarfFormat Format;
  47. /// This number is specific to the name lookup table and is independent of
  48. /// the DWARF version number.
  49. uint16_t Version;
  50. /// The offset from the beginning of the .debug_info section of the
  51. /// compilation unit header referenced by the set.
  52. uint64_t Offset;
  53. /// The size in bytes of the contents of the .debug_info section generated
  54. /// to represent that compilation unit.
  55. uint64_t Size;
  56. std::vector<Entry> Entries;
  57. };
  58. private:
  59. std::vector<Set> Sets;
  60. /// gnu styled tables contains additional information.
  61. /// This flag determines whether or not section we parse is debug_gnu* table.
  62. bool GnuStyle = false;
  63. public:
  64. DWARFDebugPubTable() = default;
  65. void extract(DWARFDataExtractor Data, bool GnuStyle,
  66. function_ref<void(Error)> RecoverableErrorHandler);
  67. void dump(raw_ostream &OS) const;
  68. ArrayRef<Set> getData() { return Sets; }
  69. };
  70. } // end namespace llvm
  71. #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H
  72. #ifdef __GNUC__
  73. #pragma GCC diagnostic pop
  74. #endif