DWARFDebugArangeSet.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //===-- DWARFDebugArangeSet.h -----------------------------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H
  10. #define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H
  11. #include "llvm/ADT/iterator_range.h"
  12. #include "llvm/Support/DataExtractor.h"
  13. #include <vector>
  14. namespace llvm {
  15. class raw_ostream;
  16. class DWARFDebugArangeSet {
  17. public:
  18. struct Header {
  19. // The total length of the entries for that set, not including the length
  20. // field itself.
  21. uint32_t Length;
  22. // The offset from the beginning of the .debug_info section of the
  23. // compilation unit entry referenced by the table.
  24. uint32_t CuOffset;
  25. // The DWARF version number.
  26. uint16_t Version;
  27. // The size in bytes of an address on the target architecture. For segmented
  28. // addressing, this is the size of the offset portion of the address.
  29. uint8_t AddrSize;
  30. // The size in bytes of a segment descriptor on the target architecture.
  31. // If the target system uses a flat address space, this value is 0.
  32. uint8_t SegSize;
  33. };
  34. struct Descriptor {
  35. uint64_t Address;
  36. uint64_t Length;
  37. uint64_t getEndAddress() const { return Address + Length; }
  38. };
  39. private:
  40. typedef std::vector<Descriptor> DescriptorColl;
  41. typedef iterator_range<DescriptorColl::const_iterator> desc_iterator_range;
  42. uint32_t Offset;
  43. Header HeaderData;
  44. DescriptorColl ArangeDescriptors;
  45. public:
  46. DWARFDebugArangeSet() { clear(); }
  47. void clear();
  48. bool extract(DataExtractor data, uint32_t *offset_ptr);
  49. void dump(raw_ostream &OS) const;
  50. uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
  51. desc_iterator_range descriptors() const {
  52. return desc_iterator_range(ArangeDescriptors.begin(),
  53. ArangeDescriptors.end());
  54. }
  55. };
  56. }
  57. #endif