DWARFDebugRnglists.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DWARFDebugRnglists.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_DWARFDEBUGRNGLISTS_H
  14. #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRNGLISTS_H
  15. #include "llvm/ADT/STLFunctionalExtras.h"
  16. #include "llvm/BinaryFormat/Dwarf.h"
  17. #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
  18. #include "llvm/DebugInfo/DWARF/DWARFListTable.h"
  19. #include <cstdint>
  20. namespace llvm {
  21. class Error;
  22. class raw_ostream;
  23. class DWARFUnit;
  24. class DWARFDataExtractor;
  25. struct DIDumpOptions;
  26. namespace object {
  27. struct SectionedAddress;
  28. }
  29. /// A class representing a single range list entry.
  30. struct RangeListEntry : public DWARFListEntryBase {
  31. /// The values making up the range list entry. Most represent a range with
  32. /// a start and end address or a start address and a length. Others are
  33. /// single value base addresses or end-of-list with no values. The unneeded
  34. /// values are semantically undefined, but initialized to 0.
  35. uint64_t Value0;
  36. uint64_t Value1;
  37. Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr);
  38. void
  39. dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,
  40. uint64_t &CurrentBase, DIDumpOptions DumpOpts,
  41. llvm::function_ref<std::optional<object::SectionedAddress>(uint32_t)>
  42. LookupPooledAddress) const;
  43. bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; }
  44. };
  45. /// A class representing a single rangelist.
  46. class DWARFDebugRnglist : public DWARFListType<RangeListEntry> {
  47. public:
  48. /// Build a DWARFAddressRangesVector from a rangelist.
  49. DWARFAddressRangesVector getAbsoluteRanges(
  50. std::optional<object::SectionedAddress> BaseAddr, uint8_t AddressByteSize,
  51. function_ref<std::optional<object::SectionedAddress>(uint32_t)>
  52. LookupPooledAddress) const;
  53. /// Build a DWARFAddressRangesVector from a rangelist.
  54. DWARFAddressRangesVector
  55. getAbsoluteRanges(std::optional<object::SectionedAddress> BaseAddr,
  56. DWARFUnit &U) const;
  57. };
  58. class DWARFDebugRnglistTable : public DWARFListTableBase<DWARFDebugRnglist> {
  59. public:
  60. DWARFDebugRnglistTable()
  61. : DWARFListTableBase(/* SectionName = */ ".debug_rnglists",
  62. /* HeaderString = */ "ranges:",
  63. /* ListTypeString = */ "range") {}
  64. };
  65. } // end namespace llvm
  66. #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRNGLISTS_H
  67. #ifdef __GNUC__
  68. #pragma GCC diagnostic pop
  69. #endif