Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
35269 views
//===-- DWARFCompileUnit.cpp ----------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"9#include "llvm/DebugInfo/DIContext.h"10#include "llvm/DebugInfo/DWARF/DWARFDie.h"1112#include "llvm/Support/Format.h"13#include "llvm/Support/raw_ostream.h"1415using namespace llvm;1617void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {18if (DumpOpts.SummarizeTypes)19return;20int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());21OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:"22<< " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())23<< ", format = " << dwarf::FormatString(getFormat())24<< ", version = " << format("0x%04x", getVersion());25if (getVersion() >= 5)26OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());27OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset());28if (!getAbbreviations())29OS << " (invalid)";30OS << ", addr_size = " << format("0x%02x", getAddressByteSize());31if (getVersion() >= 5 && (getUnitType() == dwarf::DW_UT_skeleton ||32getUnitType() == dwarf::DW_UT_split_compile))33OS << ", DWO_id = " << format("0x%016" PRIx64, *getDWOId());34OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())35<< ")\n";3637if (DWARFDie CUDie = getUnitDIE(false)) {38CUDie.dump(OS, 0, DumpOpts);39if (DumpOpts.DumpNonSkeleton) {40DWARFDie NonSkeletonCUDie = getNonSkeletonUnitDIE(false);41if (NonSkeletonCUDie && CUDie != NonSkeletonCUDie)42NonSkeletonCUDie.dump(OS, 0, DumpOpts);43}44} else {45OS << "<compile unit can't be parsed!>\n\n";46}47}4849// VTable anchor.50DWARFCompileUnit::~DWARFCompileUnit() = default;515253