blob: 513e415fa54216fb7f27ab0f95eb592cb21dfe3e [file] [log] [blame]
Benjamin Kramer72c0d7f2011-09-13 19:42:23 +00001//===-- DWARFContext.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 "DWARFContext.h"
11using namespace llvm;
12
13void DWARFContext::dump(raw_ostream &OS) {
14 getDebugAbbrev()->dump(OS);
15 for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i)
16 getCompileUnitAtIndex(i)->dump(OS);
17}
18
19const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
20 if (Abbrev)
21 return Abbrev.get();
22
23 DataExtractor abbrData(getAbbrevSection(), isLittleEndian(), 0);
24
25 Abbrev.reset(new DWARFDebugAbbrev());
26 Abbrev->parse(abbrData);
27 return Abbrev.get();
28}
29
30void DWARFContext::parseCompileUnits() {
31 uint32_t offset = 0;
32 const DataExtractor &debug_info_data = DataExtractor(getInfoSection(),
33 isLittleEndian(), 0);
34 while (debug_info_data.isValidOffset(offset)) {
35 CUs.push_back(DWARFCompileUnit(*this));
36 if (!CUs.back().extract(debug_info_data, &offset)) {
37 CUs.pop_back();
38 break;
39 }
40
41 offset = CUs.back().getNextCompileUnitOffset();
42 }
43}