1 //===- DWARFUnitIndex.h -----------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/DataExtractor.h"
22 enum DWARFSectionKind
{
33 class DWARFUnitIndex
{
38 uint32_t NumBuckets
= 0;
40 bool parse(DataExtractor IndexData
, uint64_t *OffsetPtr
);
41 void dump(raw_ostream
&OS
) const;
47 struct SectionContribution
{
53 const DWARFUnitIndex
*Index
;
55 std::unique_ptr
<SectionContribution
[]> Contributions
;
56 friend class DWARFUnitIndex
;
59 const SectionContribution
*getOffset(DWARFSectionKind Sec
) const;
60 const SectionContribution
*getOffset() const;
62 const SectionContribution
*getOffsets() const {
63 return Contributions
.get();
66 uint64_t getSignature() const { return Signature
; }
72 DWARFSectionKind InfoColumnKind
;
74 std::unique_ptr
<DWARFSectionKind
[]> ColumnKinds
;
75 std::unique_ptr
<Entry
[]> Rows
;
76 mutable std::vector
<Entry
*> OffsetLookup
;
78 static StringRef
getColumnHeader(DWARFSectionKind DS
);
80 bool parseImpl(DataExtractor IndexData
);
83 DWARFUnitIndex(DWARFSectionKind InfoColumnKind
)
84 : InfoColumnKind(InfoColumnKind
) {}
86 explicit operator bool() const { return Header
.NumBuckets
; }
88 bool parse(DataExtractor IndexData
);
89 void dump(raw_ostream
&OS
) const;
91 const Entry
*getFromOffset(uint32_t Offset
) const;
92 const Entry
*getFromHash(uint64_t Offset
) const;
94 ArrayRef
<DWARFSectionKind
> getColumnKinds() const {
95 return makeArrayRef(ColumnKinds
.get(), Header
.NumColumns
);
98 ArrayRef
<Entry
> getRows() const {
99 return makeArrayRef(Rows
.get(), Header
.NumBuckets
);
103 } // end namespace llvm
105 #endif // LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H