Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- DWARFDebugArangeSet.h ------------------------------------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H |
| 10 | #define LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H |
| 11 | |
| 12 | #include "llvm/ADT/iterator_range.h" |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 13 | #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" |
| 14 | #include "llvm/Support/Error.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 15 | #include <cstdint> |
| 16 | #include <vector> |
| 17 | |
| 18 | namespace llvm { |
| 19 | |
| 20 | class raw_ostream; |
| 21 | |
| 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. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 27 | uint64_t Length; |
| 28 | /// The DWARF format of the set. |
| 29 | dwarf::DwarfFormat Format; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 30 | /// The offset from the beginning of the .debug_info section of the |
| 31 | /// compilation unit entry referenced by the table. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 32 | uint64_t CuOffset; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 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 | |
| 43 | struct Descriptor { |
| 44 | uint64_t Address; |
| 45 | uint64_t Length; |
| 46 | |
| 47 | uint64_t getEndAddress() const { return Address + Length; } |
| 48 | void dump(raw_ostream &OS, uint32_t AddressSize) const; |
| 49 | }; |
| 50 | |
| 51 | private: |
| 52 | using DescriptorColl = std::vector<Descriptor>; |
| 53 | using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>; |
| 54 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 55 | uint64_t Offset; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 56 | Header HeaderData; |
| 57 | DescriptorColl ArangeDescriptors; |
| 58 | |
| 59 | public: |
| 60 | DWARFDebugArangeSet() { clear(); } |
| 61 | |
| 62 | void clear(); |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 63 | Error extract(DWARFDataExtractor data, uint64_t *offset_ptr, |
| 64 | function_ref<void(Error)> WarningHandler); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 65 | void dump(raw_ostream &OS) const; |
| 66 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 67 | uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 68 | |
| 69 | const Header &getHeader() const { return HeaderData; } |
| 70 | |
| 71 | desc_iterator_range descriptors() const { |
| 72 | return desc_iterator_range(ArangeDescriptors.begin(), |
| 73 | ArangeDescriptors.end()); |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | } // end namespace llvm |
| 78 | |
| 79 | #endif // LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H |