blob: f59e49268288c428c95a716b6e3675fb36a8e34a [file] [log] [blame]
Benjamin Krameraa2f78f2011-09-13 19:42:23 +00001//===-- DWARFCompileUnit.cpp ----------------------------------------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Benjamin Krameraa2f78f2011-09-13 19:42:23 +00006//
7//===----------------------------------------------------------------------===//
8
Zachary Turner82af9432015-01-30 18:07:45 +00009#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
Eugene Zelenko570e39a2016-11-23 23:16:32 +000010#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
Greg Claytonc8c10322016-12-13 18:25:19 +000011#include "llvm/DebugInfo/DWARF/DWARFDie.h"
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000012#include "llvm/Support/Format.h"
13#include "llvm/Support/raw_ostream.h"
David Blaikie07e22442013-09-23 22:44:40 +000014
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000015using namespace llvm;
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000016
Adrian Prantl318d1192017-06-06 23:28:45 +000017void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
Igor Kudrinf26a70a2019-08-06 10:49:40 +000018 OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:"
Igor Kudrined413072019-08-21 14:10:57 +000019 << " length = " << format("0x%08" PRIx64, getLength())
Paul Robinsoncddd6042017-02-28 20:24:55 +000020 << " version = " << format("0x%04x", getVersion());
21 if (getVersion() >= 5)
22 OS << " unit_type = " << dwarf::UnitTypeString(getUnitType());
Igor Kudrinf26a70a2019-08-06 10:49:40 +000023 OS << " abbr_offset = "
24 << format("0x%04" PRIx64, 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());
Igor Kudrinf26a70a2019-08-06 10:49:40 +000028 OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())
29 << ")\n";
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000030
Greg Claytonc8c10322016-12-13 18:25:19 +000031 if (DWARFDie CUDie = getUnitDIE(false))
Adrian Prantld3f9f212017-09-20 17:44:00 +000032 CUDie.dump(OS, 0, DumpOpts);
Alexey Samsonov7a18c062015-05-19 21:54:32 +000033 else
34 OS << "<compile unit can't be parsed!>\n\n";
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000035}
36
David Blaikie07e22442013-09-23 22:44:40 +000037// VTable anchor.
Eugene Zelenko570e39a2016-11-23 23:16:32 +000038DWARFCompileUnit::~DWARFCompileUnit() = default;