DWARFDebugRnglists.h 2.8 KB

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