1 //===-- DWARFUnitIndex.cpp ------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/ErrorHandling.h"
17 bool DWARFUnitIndex::Header::parse(DataExtractor IndexData,
18 uint32_t *OffsetPtr) {
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);
28 void DWARFUnitIndex::Header::dump(raw_ostream &OS) const {
29 OS << "Index header:\n" << format(" version: %u\n", Version)
30 << format(" columns: %u\n", NumColumns)
31 << format(" units: %u\n", NumUnits)
32 << format(" buckets: %u\n", NumBuckets);
35 bool DWARFUnitIndex::parse(DataExtractor IndexData) {
37 if (!Header.parse(IndexData, &Offset))
40 if (!IndexData.isValidOffsetForDataOfSize(
41 Offset, Header.NumBuckets * (8 + 4) +
42 (2 * Header.NumUnits + 1) * 4 * Header.NumColumns))
48 StringRef DWARFUnitIndex::getColumnHeader(DwarfSection DS) {
62 llvm_unreachable("unknown DwarfSection");
65 void DWARFUnitIndex::dump(raw_ostream &OS) const {