blob: 43b235621d18f063f0257db8d39b33983ab6b33a [file] [log] [blame]
Benjamin Krameraa2f78f2011-09-13 19:42:23 +00001//===-- DWARFCompileUnit.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
Zachary Turner82af9432015-01-30 18:07:45 +000010#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
Eugene Zelenko570e39a2016-11-23 23:16:32 +000011#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
Greg Claytonc8c10322016-12-13 18:25:19 +000012#include "llvm/DebugInfo/DWARF/DWARFDie.h"
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000013#include "llvm/Support/Format.h"
14#include "llvm/Support/raw_ostream.h"
David Blaikie07e22442013-09-23 22:44:40 +000015
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000016using namespace llvm;
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000017
Adrian Prantl318d1192017-06-06 23:28:45 +000018void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
David Blaikie07e22442013-09-23 22:44:40 +000019 OS << format("0x%08x", getOffset()) << ": Compile Unit:"
20 << " length = " << format("0x%08x", getLength())
Paul Robinsoncddd6042017-02-28 20:24:55 +000021 << " version = " << format("0x%04x", getVersion());
22 if (getVersion() >= 5)
23 OS << " unit_type = " << dwarf::UnitTypeString(getUnitType());
24 OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset())
David Blaikie07e22442013-09-23 22:44:40 +000025 << " addr_size = " << format("0x%02x", getAddressByteSize())
26 << " (next unit at " << format("0x%08x", getNextUnitOffset())
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000027 << ")\n";
28
Greg Claytonc8c10322016-12-13 18:25:19 +000029 if (DWARFDie CUDie = getUnitDIE(false))
Adrian Prantld3f9f212017-09-20 17:44:00 +000030 CUDie.dump(OS, 0, DumpOpts);
Alexey Samsonov7a18c062015-05-19 21:54:32 +000031 else
32 OS << "<compile unit can't be parsed!>\n\n";
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000033}
34
David Blaikie07e22442013-09-23 22:44:40 +000035// VTable anchor.
Eugene Zelenko570e39a2016-11-23 23:16:32 +000036DWARFCompileUnit::~DWARFCompileUnit() = default;