1 //===-- DWARFCompileUnit.cpp ----------------------------------------------===//
3 // 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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
10 #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
11 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
12 #include "llvm/Support/Format.h"
13 #include "llvm/Support/raw_ostream.h"
17 void DWARFCompileUnit::dump(raw_ostream
&OS
, DIDumpOptions DumpOpts
) {
18 OS
<< format("0x%08" PRIx64
, getOffset()) << ": Compile Unit:"
19 << " length = " << format("0x%08" PRIx64
, getLength())
20 << " version = " << format("0x%04x", getVersion());
21 if (getVersion() >= 5)
22 OS
<< " unit_type = " << dwarf::UnitTypeString(getUnitType());
23 OS
<< " abbr_offset = "
24 << format("0x%04" PRIx64
, getAbbreviations()->getOffset())
25 << " 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%08" PRIx64
, getNextUnitOffset())
31 if (DWARFDie CUDie
= getUnitDIE(false))
32 CUDie
.dump(OS
, 0, DumpOpts
);
34 OS
<< "<compile unit can't be parsed!>\n\n";
38 DWARFCompileUnit::~DWARFCompileUnit() = default;