blob: 00a23b3898fa5a16fcc3030d8b93ad18ae8db3cb [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())
Paul Robinson543c0e12018-05-22 17:27:31 +000025 << " addr_size = " << format("0x%02x", getAddressByteSize());
26 if (getVersion() >= 5 && getUnitType() != dwarf::DW_UT_compile)
27 OS << " DWO_id = " << format("0x%016" PRIx64, *getDWOId());
28 OS << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n";
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000029
Greg Claytonc8c10322016-12-13 18:25:19 +000030 if (DWARFDie CUDie = getUnitDIE(false))
Adrian Prantld3f9f212017-09-20 17:44:00 +000031 CUDie.dump(OS, 0, DumpOpts);
Alexey Samsonov7a18c062015-05-19 21:54:32 +000032 else
33 OS << "<compile unit can't be parsed!>\n\n";
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000034}
35
David Blaikie07e22442013-09-23 22:44:40 +000036// VTable anchor.
Eugene Zelenko570e39a2016-11-23 23:16:32 +000037DWARFCompileUnit::~DWARFCompileUnit() = default;