1 //===-- DWARFContext.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 "DWARFContext.h"
11 #include "llvm/Support/raw_ostream.h"
14 void DWARFContext::dump(raw_ostream &OS) {
15 OS << ".debug_abbrev contents:\n";
16 getDebugAbbrev()->dump(OS);
18 OS << "\n.debug_info contents:\n";
19 for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i)
20 getCompileUnitAtIndex(i)->dump(OS);
22 OS << "\n.debug_aranges contents:\n";
23 DataExtractor arangesData(getARangeSection(), isLittleEndian(), 0);
25 DWARFDebugArangeSet set;
26 while (set.extract(arangesData, &offset))
30 const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
34 DataExtractor abbrData(getAbbrevSection(), isLittleEndian(), 0);
36 Abbrev.reset(new DWARFDebugAbbrev());
37 Abbrev->parse(abbrData);
41 const DWARFDebugAranges *DWARFContext::getDebugAranges() {
45 DataExtractor arangesData(getARangeSection(), isLittleEndian(), 0);
47 Aranges.reset(new DWARFDebugAranges());
48 Aranges->extract(arangesData);
52 void DWARFContext::parseCompileUnits() {
54 const DataExtractor &debug_info_data = DataExtractor(getInfoSection(),
56 while (debug_info_data.isValidOffset(offset)) {
57 CUs.push_back(DWARFCompileUnit(*this));
58 if (!CUs.back().extract(debug_info_data, &offset)) {
63 offset = CUs.back().getNextCompileUnitOffset();