DWARFDebugRangeList.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DWARFDebugRangeList.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_DWARFDEBUGRANGELIST_H
  14. #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
  15. #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
  16. #include <cstdint>
  17. #include <vector>
  18. namespace llvm {
  19. class raw_ostream;
  20. class DWARFDataExtractor;
  21. namespace object {
  22. struct SectionedAddress;
  23. }
  24. class DWARFDebugRangeList {
  25. public:
  26. struct RangeListEntry {
  27. /// A beginning address offset. This address offset has the size of an
  28. /// address and is relative to the applicable base address of the
  29. /// compilation unit referencing this range list. It marks the beginning
  30. /// of an address range.
  31. uint64_t StartAddress;
  32. /// An ending address offset. This address offset again has the size of
  33. /// an address and is relative to the applicable base address of the
  34. /// compilation unit referencing this range list. It marks the first
  35. /// address past the end of the address range. The ending address must
  36. /// be greater than or equal to the beginning address.
  37. uint64_t EndAddress;
  38. /// A section index this range belongs to.
  39. uint64_t SectionIndex;
  40. /// The end of any given range list is marked by an end of list entry,
  41. /// which consists of a 0 for the beginning address offset
  42. /// and a 0 for the ending address offset.
  43. bool isEndOfListEntry() const {
  44. return (StartAddress == 0) && (EndAddress == 0);
  45. }
  46. /// A base address selection entry consists of:
  47. /// 1. The value of the largest representable address offset
  48. /// (for example, 0xffffffff when the size of an address is 32 bits).
  49. /// 2. An address, which defines the appropriate base address for
  50. /// use in interpreting the beginning and ending address offsets of
  51. /// subsequent entries of the location list.
  52. bool isBaseAddressSelectionEntry(uint8_t AddressSize) const;
  53. };
  54. private:
  55. /// Offset in .debug_ranges section.
  56. uint64_t Offset;
  57. uint8_t AddressSize;
  58. std::vector<RangeListEntry> Entries;
  59. public:
  60. DWARFDebugRangeList() { clear(); }
  61. void clear();
  62. void dump(raw_ostream &OS) const;
  63. Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr);
  64. const std::vector<RangeListEntry> &getEntries() { return Entries; }
  65. /// getAbsoluteRanges - Returns absolute address ranges defined by this range
  66. /// list. Has to be passed base address of the compile unit referencing this
  67. /// range list.
  68. DWARFAddressRangesVector
  69. getAbsoluteRanges(std::optional<object::SectionedAddress> BaseAddr) const;
  70. };
  71. } // end namespace llvm
  72. #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
  73. #ifdef __GNUC__
  74. #pragma GCC diagnostic pop
  75. #endif