LLVM 23.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
13#include "llvm/Support/Format.h"
17
18using namespace llvm;
19
21 if (DumpOpts.SummarizeTypes)
22 return;
23 int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
24 OS << formatv("{0:x+8}", getOffset()) << ": Compile Unit:"
25 << " length = "
26 << formatv("0x{0:x-}",
27 fmt_align(getLength(), AlignStyle::Right, OffsetDumpWidth, '0'))
28 << ", format = " << dwarf::FormatString(getFormat())
29 << ", version = " << formatv("{0:x+4}", getVersion());
30
31 if (getVersion() >= 5)
32 OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
33 OS << ", abbr_offset = " << formatv("{0:x+4}", getAbbrOffset());
34 if (!getAbbreviations())
35 OS << " (invalid)";
36 OS << ", addr_size = " << formatv("{0:x+2}", getAddressByteSize());
37 if (getVersion() >= 5 && (getUnitType() == dwarf::DW_UT_skeleton ||
38 getUnitType() == dwarf::DW_UT_split_compile))
39 OS << ", DWO_id = " << formatv("{0:x+16}", *getDWOId());
40 OS << " (next unit at " << formatv("{0:x+8}", getNextUnitOffset()) << ")\n";
41
42 if (DWARFDie CUDie = getUnitDIE(false)) {
43 CUDie.dump(OS, 0, DumpOpts);
44 if (DumpOpts.DumpNonSkeleton) {
45 DWARFDie NonSkeletonCUDie = getNonSkeletonUnitDIE(false);
46 if (NonSkeletonCUDie && CUDie != NonSkeletonCUDie)
47 NonSkeletonCUDie.dump(OS, 0, DumpOpts);
48 }
49 } else {
50 OS << "<compile unit can't be parsed!>\n\n";
51 }
52}
53
54// 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:663
std::optional< uint64_t > getDWOId()
Definition DWARFUnit.h:465
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:1023
LLVM_ABI StringRef UnitTypeString(unsigned)
Definition Dwarf.cpp:804
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition Dwarf.h:1097
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