DWARFDebugRangeList.h 3.0 KB

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