blob: 3d5852ee151831ce02912f69d924909fb28c2e13 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- DWARFDebugArangeSet.h ------------------------------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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 Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
10#define LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
11
12#include "llvm/ADT/iterator_range.h"
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020013#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
14#include "llvm/Support/Error.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010015#include <cstdint>
16#include <vector>
17
18namespace llvm {
19
20class raw_ostream;
21
22class DWARFDebugArangeSet {
23public:
24 struct Header {
25 /// The total length of the entries for that set, not including the length
26 /// field itself.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020027 uint64_t Length;
28 /// The DWARF format of the set.
29 dwarf::DwarfFormat Format;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010030 /// The offset from the beginning of the .debug_info section of the
31 /// compilation unit entry referenced by the table.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020032 uint64_t CuOffset;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010033 /// 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
51private:
52 using DescriptorColl = std::vector<Descriptor>;
53 using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>;
54
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020055 uint64_t Offset;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010056 Header HeaderData;
57 DescriptorColl ArangeDescriptors;
58
59public:
60 DWARFDebugArangeSet() { clear(); }
61
62 void clear();
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020063 Error extract(DWARFDataExtractor data, uint64_t *offset_ptr,
64 function_ref<void(Error)> WarningHandler);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010065 void dump(raw_ostream &OS) const;
66
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020067 uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010068
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