Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H |
| 11 | #define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 12 | |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 13 | #include "llvm/ADT/iterator_range.h" |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 14 | #include "llvm/Support/DataExtractor.h" |
| 15 | #include <vector> |
| 16 | |
| 17 | namespace llvm { |
| 18 | |
| 19 | class raw_ostream; |
| 20 | |
| 21 | class DWARFDebugArangeSet { |
| 22 | public: |
| 23 | struct Header { |
| 24 | // The total length of the entries for that set, not including the length |
| 25 | // field itself. |
| 26 | uint32_t Length; |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 27 | // The offset from the beginning of the .debug_info section of the |
| 28 | // compilation unit entry referenced by the table. |
| 29 | uint32_t CuOffset; |
Benjamin Kramer | a59d118 | 2011-09-14 18:34:47 +0000 | [diff] [blame] | 30 | // The DWARF version number. |
| 31 | uint16_t Version; |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 32 | // The size in bytes of an address on the target architecture. For segmented |
| 33 | // addressing, this is the size of the offset portion of the address. |
| 34 | uint8_t AddrSize; |
| 35 | // The size in bytes of a segment descriptor on the target architecture. |
| 36 | // If the target system uses a flat address space, this value is 0. |
| 37 | uint8_t SegSize; |
| 38 | }; |
| 39 | |
| 40 | struct Descriptor { |
| 41 | uint64_t Address; |
| 42 | uint64_t Length; |
| 43 | uint64_t getEndAddress() const { return Address + Length; } |
| 44 | }; |
| 45 | |
| 46 | private: |
| 47 | typedef std::vector<Descriptor> DescriptorColl; |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 48 | typedef iterator_range<DescriptorColl::const_iterator> desc_iterator_range; |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 49 | |
| 50 | uint32_t Offset; |
Rafael Espindola | 43e553d | 2013-03-20 21:03:41 +0000 | [diff] [blame] | 51 | Header HeaderData; |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 52 | DescriptorColl ArangeDescriptors; |
| 53 | |
| 54 | public: |
| 55 | DWARFDebugArangeSet() { clear(); } |
| 56 | void clear(); |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 57 | bool extract(DataExtractor data, uint32_t *offset_ptr); |
| 58 | void dump(raw_ostream &OS) const; |
| 59 | |
Rafael Espindola | 43e553d | 2013-03-20 21:03:41 +0000 | [diff] [blame] | 60 | uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 61 | |
| 62 | desc_iterator_range descriptors() const { |
| 63 | return desc_iterator_range(ArangeDescriptors.begin(), |
| 64 | ArangeDescriptors.end()); |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 65 | } |
Benjamin Kramer | a6002fd | 2011-09-14 01:09:52 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | } |
| 69 | |
| 70 | #endif |