xref: /netbsd-src/external/apache2/llvm/dist/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp (revision 82d56013d7b633d116a93943de88e08335357a7c)
17330f729Sjoerg //===-- DWARFCompileUnit.cpp ----------------------------------------------===//
27330f729Sjoerg //
37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67330f729Sjoerg //
77330f729Sjoerg //===----------------------------------------------------------------------===//
87330f729Sjoerg 
97330f729Sjoerg #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
107330f729Sjoerg #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
117330f729Sjoerg #include "llvm/DebugInfo/DWARF/DWARFDie.h"
127330f729Sjoerg #include "llvm/Support/Format.h"
137330f729Sjoerg #include "llvm/Support/raw_ostream.h"
147330f729Sjoerg 
157330f729Sjoerg using namespace llvm;
167330f729Sjoerg 
dump(raw_ostream & OS,DIDumpOptions DumpOpts)177330f729Sjoerg void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
18*82d56013Sjoerg   int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
197330f729Sjoerg   OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:"
20*82d56013Sjoerg      << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
21*82d56013Sjoerg      << ", format = " << dwarf::FormatString(getFormat())
22*82d56013Sjoerg      << ", version = " << format("0x%04x", getVersion());
237330f729Sjoerg   if (getVersion() >= 5)
24*82d56013Sjoerg     OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
25*82d56013Sjoerg   OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset());
26*82d56013Sjoerg   if (!getAbbreviations())
27*82d56013Sjoerg     OS << " (invalid)";
28*82d56013Sjoerg   OS << ", addr_size = " << format("0x%02x", getAddressByteSize());
29*82d56013Sjoerg   if (getVersion() >= 5 && (getUnitType() == dwarf::DW_UT_skeleton ||
30*82d56013Sjoerg                             getUnitType() == dwarf::DW_UT_split_compile))
31*82d56013Sjoerg     OS << ", DWO_id = " << format("0x%016" PRIx64, *getDWOId());
327330f729Sjoerg   OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())
337330f729Sjoerg      << ")\n";
347330f729Sjoerg 
357330f729Sjoerg   if (DWARFDie CUDie = getUnitDIE(false))
367330f729Sjoerg     CUDie.dump(OS, 0, DumpOpts);
377330f729Sjoerg   else
387330f729Sjoerg     OS << "<compile unit can't be parsed!>\n\n";
397330f729Sjoerg }
407330f729Sjoerg 
417330f729Sjoerg // VTable anchor.
427330f729Sjoerg DWARFCompileUnit::~DWARFCompileUnit() = default;
43