dwarfdump: First piece of support for DWP dumping
[oota-llvm.git] / lib / DebugInfo / DWARF / DWARFUnitIndex.cpp
1 //===-- DWARFUnitIndex.cpp ------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
11
12 namespace llvm {
13
14 bool DWARFUnitIndex::Header::parse(DataExtractor IndexData, uint32_t *OffsetPtr) {
15   Version = IndexData.getU32(OffsetPtr);
16   NumColumns = IndexData.getU32(OffsetPtr);
17   NumUnits = IndexData.getU32(OffsetPtr);
18   NumBuckets = IndexData.getU32(OffsetPtr);
19   return Version <= 2;
20 }
21
22 void DWARFUnitIndex::Header::dump(raw_ostream &OS) const {
23   OS << "Index header:\n" << format("   version: %u\n", Version)
24      << format("   columns: %u\n", NumColumns)
25      << format("     units: %u\n", NumUnits)
26      << format("   buckets: %u\n", NumBuckets);
27 }
28
29 bool DWARFUnitIndex::parse(DataExtractor IndexData) {
30   uint32_t Offset = 0;
31   if (!Header.parse(IndexData, &Offset))
32     return false;
33
34   return true;
35 }
36
37 void DWARFUnitIndex::dump(raw_ostream &OS) const {
38   Header.dump(OS);
39 }
40
41 }