DWARFDebugRnglists.h 2.8 KB

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