LLVM 24.0.0git
DWARFCompileUnit.cpp
Go to the documentation of this file.
1//===-- DWARFCompileUnit.cpp ----------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
12
16
17using namespace llvm;
18
20 if (DumpOpts.SummarizeTypes)
21 return;
22 int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
23 OS << formatv("{0:x+8}", getOffset()) << ": Compile Unit:"
24 << " length = "
25 << formatv("0x{0:x-}",
26 fmt_align(getLength(), AlignStyle::Right, OffsetDumpWidth, '0'))
27 << ", format = " << dwarf::FormatString(getFormat())
28 << ", version = " << formatv("{0:x+4}", getVersion());
29
30 if (getVersion() >= 5)
31 OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
32 OS << ", abbr_offset = " << formatv("{0:x+4}", getAbbrOffset());
33 if (!getAbbreviations())
34 OS << " (invalid)";
35 OS << ", addr_size = " << formatv("{0:x+2}", getAddressByteSize());
36 if (getVersion() >= 5 && (getUnitType() == dwarf::DW_UT_skeleton ||
37 getUnitType() == dwarf::DW_UT_split_compile))
38 OS << ", DWO_id = " << formatv("{0:x+16}", *getDWOId());
39 OS << " (next unit at " << formatv("{0:x+8}", getNextUnitOffset()) << ")\n";
40
41 if (DWARFDie CUDie = getUnitDIE(false)) {
42 CUDie.dump(OS, 0, DumpOpts);
43 if (DumpOpts.DumpNonSkeleton) {
44 DWARFDie NonSkeletonCUDie = getNonSkeletonUnitDIE(false);
45 if (NonSkeletonCUDie && CUDie != NonSkeletonCUDie)
46 NonSkeletonCUDie.dump(OS, 0, DumpOpts);
47 }
48 } else {
49 OS << "<compile unit can't be parsed!>\n\n";
50 }
51}
52
53// VTable anchor.
~DWARFCompileUnit() override
VTable anchor.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override
Dump this compile unit to OS.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition DWARFDie.h:43
LLVM_ABI void dump(raw_ostream &OS, unsigned indent=0, DIDumpOptions DumpOpts=DIDumpOptions()) const
Dump the DIE and all of its attributes to the supplied stream.
Definition DWARFDie.cpp:677
std::optional< uint64_t > getDWOId()
Definition DWARFUnit.h:475
DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly=true, StringRef DWOAlternativeLocation={})
Definition DWARFUnit.h:457
uint8_t getUnitType() const
Definition DWARFUnit.h:342
uint64_t getLength() const
Definition DWARFUnit.h:340
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Definition DWARFUnit.h:450
uint8_t getAddressByteSize() const
Definition DWARFUnit.h:333
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
dwarf::DwarfFormat getFormat() const
Definition DWARFUnit.h:341
uint16_t getVersion() const
Definition DWARFUnit.h:332
uint64_t getAbbrOffset() const
Definition DWARFUnit.h:344
uint64_t getNextUnitOffset() const
Definition DWARFUnit.h:345
uint64_t getOffset() const
Definition DWARFUnit.h:328
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
LLVM_ABI StringRef FormatString(DwarfFormat Format)
Definition Dwarf.cpp:1062
LLVM_ABI StringRef UnitTypeString(unsigned)
Definition Dwarf.cpp:841
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition Dwarf.h:1186
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')
Container for dump options that control which debug information will be dumped.
Definition DIContext.h:196