DWARFDebugArangeSet.h 2.6 KB

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