DWARFObject.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DWARFObject.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_DWARFOBJECT_H
  14. #define LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H
  15. #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
  16. #include "llvm/DebugInfo/DWARF/DWARFSection.h"
  17. #include "llvm/Object/ObjectFile.h"
  18. #include <optional>
  19. namespace llvm {
  20. // This is responsible for low level access to the object file. It
  21. // knows how to find the required sections and compute relocated
  22. // values.
  23. // The default implementations of the get<Section> methods return dummy values.
  24. // This is to allow clients that only need some of those to implement just the
  25. // ones they need. We can't use unreachable for as many cases because the parser
  26. // implementation is eager and will call some of these methods even if the
  27. // result is not used.
  28. class DWARFObject {
  29. DWARFSection Dummy;
  30. public:
  31. virtual ~DWARFObject() = default;
  32. virtual StringRef getFileName() const { llvm_unreachable("unimplemented"); }
  33. virtual const object::ObjectFile *getFile() const { return nullptr; }
  34. virtual ArrayRef<SectionName> getSectionNames() const { return {}; }
  35. virtual bool isLittleEndian() const = 0;
  36. virtual uint8_t getAddressSize() const { llvm_unreachable("unimplemented"); }
  37. virtual void
  38. forEachInfoSections(function_ref<void(const DWARFSection &)> F) const {}
  39. virtual void
  40. forEachTypesSections(function_ref<void(const DWARFSection &)> F) const {}
  41. virtual StringRef getAbbrevSection() const { return ""; }
  42. virtual const DWARFSection &getLocSection() const { return Dummy; }
  43. virtual const DWARFSection &getLoclistsSection() const { return Dummy; }
  44. virtual StringRef getArangesSection() const { return ""; }
  45. virtual const DWARFSection &getFrameSection() const { return Dummy; }
  46. virtual const DWARFSection &getEHFrameSection() const { return Dummy; }
  47. virtual const DWARFSection &getLineSection() const { return Dummy; }
  48. virtual StringRef getLineStrSection() const { return ""; }
  49. virtual StringRef getStrSection() const { return ""; }
  50. virtual const DWARFSection &getRangesSection() const { return Dummy; }
  51. virtual const DWARFSection &getRnglistsSection() const { return Dummy; }
  52. virtual const DWARFSection &getMacroSection() const { return Dummy; }
  53. virtual StringRef getMacroDWOSection() const { return ""; }
  54. virtual StringRef getMacinfoSection() const { return ""; }
  55. virtual StringRef getMacinfoDWOSection() const { return ""; }
  56. virtual const DWARFSection &getPubnamesSection() const { return Dummy; }
  57. virtual const DWARFSection &getPubtypesSection() const { return Dummy; }
  58. virtual const DWARFSection &getGnuPubnamesSection() const { return Dummy; }
  59. virtual const DWARFSection &getGnuPubtypesSection() const { return Dummy; }
  60. virtual const DWARFSection &getStrOffsetsSection() const { return Dummy; }
  61. virtual void
  62. forEachInfoDWOSections(function_ref<void(const DWARFSection &)> F) const {}
  63. virtual void
  64. forEachTypesDWOSections(function_ref<void(const DWARFSection &)> F) const {}
  65. virtual StringRef getAbbrevDWOSection() const { return ""; }
  66. virtual const DWARFSection &getLineDWOSection() const { return Dummy; }
  67. virtual const DWARFSection &getLocDWOSection() const { return Dummy; }
  68. virtual const DWARFSection &getLoclistsDWOSection() const { return Dummy; }
  69. virtual StringRef getStrDWOSection() const { return ""; }
  70. virtual const DWARFSection &getStrOffsetsDWOSection() const {
  71. return Dummy;
  72. }
  73. virtual const DWARFSection &getRangesDWOSection() const { return Dummy; }
  74. virtual const DWARFSection &getRnglistsDWOSection() const { return Dummy; }
  75. virtual const DWARFSection &getAddrSection() const { return Dummy; }
  76. virtual const DWARFSection &getAppleNamesSection() const { return Dummy; }
  77. virtual const DWARFSection &getAppleTypesSection() const { return Dummy; }
  78. virtual const DWARFSection &getAppleNamespacesSection() const {
  79. return Dummy;
  80. }
  81. virtual const DWARFSection &getNamesSection() const { return Dummy; }
  82. virtual const DWARFSection &getAppleObjCSection() const { return Dummy; }
  83. virtual StringRef getCUIndexSection() const { return ""; }
  84. virtual StringRef getGdbIndexSection() const { return ""; }
  85. virtual StringRef getTUIndexSection() const { return ""; }
  86. virtual std::optional<RelocAddrEntry> find(const DWARFSection &Sec,
  87. uint64_t Pos) const = 0;
  88. };
  89. } // namespace llvm
  90. #endif
  91. #ifdef __GNUC__
  92. #pragma GCC diagnostic pop
  93. #endif