DWARFDebugArangeSet.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DWARFDebugArangeSet.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_DWARFDEBUGARANGESET_H
  14. #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGESET_H
  15. #include "llvm/ADT/iterator_range.h"
  16. #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
  17. #include "llvm/Support/Error.h"
  18. #include <cstdint>
  19. #include <vector>
  20. namespace llvm {
  21. class raw_ostream;
  22. class DWARFDebugArangeSet {
  23. public:
  24. struct Header {
  25. /// The total length of the entries for that set, not including the length
  26. /// field itself.
  27. uint64_t Length;
  28. /// The DWARF format of the set.
  29. dwarf::DwarfFormat Format;
  30. /// The offset from the beginning of the .debug_info section of the
  31. /// compilation unit entry referenced by the table.
  32. uint64_t CuOffset;
  33. /// The DWARF version number.
  34. uint16_t Version;
  35. /// The size in bytes of an address on the target architecture. For segmented
  36. /// addressing, this is the size of the offset portion of the address.
  37. uint8_t AddrSize;
  38. /// The size in bytes of a segment descriptor on the target architecture.
  39. /// If the target system uses a flat address space, this value is 0.
  40. uint8_t SegSize;
  41. };
  42. struct Descriptor {
  43. uint64_t Address;
  44. uint64_t Length;
  45. uint64_t getEndAddress() const { return Address + Length; }
  46. void dump(raw_ostream &OS, uint32_t AddressSize) const;
  47. };
  48. private:
  49. using DescriptorColl = std::vector<Descriptor>;
  50. using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>;
  51. uint64_t Offset;
  52. Header HeaderData;
  53. DescriptorColl ArangeDescriptors;
  54. public:
  55. DWARFDebugArangeSet() { clear(); }
  56. void clear();
  57. Error extract(DWARFDataExtractor data, uint64_t *offset_ptr,
  58. function_ref<void(Error)> WarningHandler);
  59. void dump(raw_ostream &OS) const;
  60. uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
  61. const Header &getHeader() const { return HeaderData; }
  62. desc_iterator_range descriptors() const {
  63. return desc_iterator_range(ArangeDescriptors.begin(),
  64. ArangeDescriptors.end());
  65. }
  66. };
  67. } // end namespace llvm
  68. #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGESET_H
  69. #ifdef __GNUC__
  70. #pragma GCC diagnostic pop
  71. #endif