17 bool DWARFUnitIndex::Header::parse(DataExtractor IndexData,
19 if (!IndexData.isValidOffsetForDataOfSize(*OffsetPtr, 16))
21 Version = IndexData.getU32(OffsetPtr);
22 NumColumns = IndexData.getU32(OffsetPtr);
23 NumUnits = IndexData.getU32(OffsetPtr);
24 NumBuckets = IndexData.getU32(OffsetPtr);
29 OS <<
format(
"version = %u slots = %u\n\n",
Version, NumBuckets);
33 bool b = parseImpl(IndexData);
36 Header.NumBuckets = 0;
46 if (!Header.parse(IndexData, &Offset))
50 Offset, Header.NumBuckets * (8 + 4) +
51 (2 * Header.NumUnits + 1) * 4 * Header.NumColumns))
54 Rows = llvm::make_unique<Entry[]>(Header.NumBuckets);
56 llvm::make_unique<Entry::SectionContribution *[]>(Header.NumUnits);
57 ColumnKinds = llvm::make_unique<DWARFSectionKind[]>(Header.NumColumns);
60 for (
unsigned i = 0;
i != Header.NumBuckets; ++
i)
61 Rows[
i].Signature = IndexData.
getU64(&Offset);
64 for (
unsigned i = 0;
i != Header.NumBuckets; ++
i) {
65 auto Index = IndexData.
getU32(&Offset);
69 Rows[
i].Contributions =
70 llvm::make_unique<Entry::SectionContribution[]>(Header.NumColumns);
71 Contribs[Index - 1] = Rows[
i].Contributions.get();
75 for (
unsigned i = 0;
i != Header.NumColumns; ++
i) {
77 if (ColumnKinds[
i] == InfoColumnKind) {
88 for (
unsigned i = 0;
i != Header.NumUnits; ++
i) {
89 auto *Contrib = Contribs[
i];
90 for (
unsigned i = 0;
i != Header.NumColumns; ++
i)
91 Contrib[
i].Offset = IndexData.
getU32(&Offset);
95 for (
unsigned i = 0;
i != Header.NumUnits; ++
i) {
96 auto *Contrib = Contribs[
i];
97 for (
unsigned i = 0;
i != Header.NumColumns; ++
i)
98 Contrib[
i].Length = IndexData.
getU32(&Offset);
122 if (!Header.NumBuckets)
126 OS <<
"Index Signature ";
127 for (
unsigned i = 0;
i != Header.NumColumns; ++
i)
128 OS <<
' ' <<
left_justify(getColumnHeader(ColumnKinds[
i]), 24);
129 OS <<
"\n----- ------------------";
130 for (
unsigned i = 0; i != Header.NumColumns; ++
i)
131 OS <<
" ------------------------";
133 for (
unsigned i = 0; i != Header.NumBuckets; ++
i) {
135 if (
auto *Contribs = Row.Contributions.get()) {
136 OS <<
format(
"%5u 0x%016" PRIx64
" ", i + 1, Row.Signature);
137 for (
unsigned i = 0; i != Header.NumColumns; ++
i) {
138 auto &Contrib = Contribs[
i];
139 OS <<
format(
"[0x%08x, 0x%08x) ", Contrib.Offset,
140 Contrib.Offset + Contrib.Length);
150 for (; i != Index->Header.NumColumns; ++
i)
151 if (Index->ColumnKinds[i] == Sec)
152 return &Contributions[
i];
157 return &Contributions[Index->InfoColumn];
163 if (
const auto &Contribs = Rows[
i].Contributions)
164 if (Contribs[InfoColumn].Offset == Offset)
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
static void dump(StringRef Title, SpillInfo const &Spills)
const Entry * getFromOffset(uint32_t Offset) const
bool parse(DataExtractor IndexData)
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const SectionContribution * getOffset() const
void dump(raw_ostream &OS) const
This class implements an extremely fast bulk output stream that can only output to a stream...