182af9438SZachary Turner //===-- DWARFCompileUnit.cpp ----------------------------------------------===// 282af9438SZachary Turner // 3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 682af9438SZachary Turner // 782af9438SZachary Turner //===----------------------------------------------------------------------===// 882af9438SZachary Turner 982af9438SZachary Turner #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" 10570e39a2SEugene Zelenko #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" 11c8c1032cSGreg Clayton #include "llvm/DebugInfo/DWARF/DWARFDie.h" 1282af9438SZachary Turner #include "llvm/Support/Format.h" 1382af9438SZachary Turner #include "llvm/Support/raw_ostream.h" 1482af9438SZachary Turner 1582af9438SZachary Turner using namespace llvm; 1682af9438SZachary Turner 17318d1195SAdrian Prantl void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { 1882af9438SZachary Turner OS << format("0x%08x", getOffset()) << ": Compile Unit:" 1982af9438SZachary Turner << " length = " << format("0x%08x", getLength()) 20cddd6044SPaul Robinson << " version = " << format("0x%04x", getVersion()); 21cddd6044SPaul Robinson if (getVersion() >= 5) 22cddd6044SPaul Robinson OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); 23cddd6044SPaul Robinson OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset()) 24543c0e1dSPaul Robinson << " addr_size = " << format("0x%02x", getAddressByteSize()); 25543c0e1dSPaul Robinson if (getVersion() >= 5 && getUnitType() != dwarf::DW_UT_compile) 26543c0e1dSPaul Robinson OS << " DWO_id = " << format("0x%016" PRIx64, *getDWOId()); 27543c0e1dSPaul Robinson OS << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n"; 2882af9438SZachary Turner 29c8c1032cSGreg Clayton if (DWARFDie CUDie = getUnitDIE(false)) 30d3f9f213SAdrian Prantl CUDie.dump(OS, 0, DumpOpts); 317a18c061SAlexey Samsonov else 327a18c061SAlexey Samsonov OS << "<compile unit can't be parsed!>\n\n"; 3382af9438SZachary Turner } 3482af9438SZachary Turner 3582af9438SZachary Turner // VTable anchor. 36570e39a2SEugene Zelenko DWARFCompileUnit::~DWARFCompileUnit() = default; 37