LLVM 24.0.0git
DWARFTypeUnit.cpp
Go to the documentation of this file.
1//===- DWARFTypeUnit.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
15
16using namespace llvm;
17
20 const char *Name = TD.getName(DINameKind::ShortName);
21 int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
22
23 if (DumpOpts.SummarizeTypes) {
24 OS << "name = '" << Name << "'"
25 << ", type_signature = " << formatv("{0:x16}", getTypeHash())
26 << ", length = "
28 OffsetDumpWidth, '0'))
29 << '\n';
30 return;
31 }
32
33 OS << formatv("{0:x8}", getOffset()) << ": Type Unit:"
34 << " length = "
35 << formatv("0x{0:x-}",
36 fmt_align(getLength(), AlignStyle::Right, OffsetDumpWidth, '0'))
37 << ", format = " << dwarf::FormatString(getFormat())
38 << ", version = " << formatv("{0:x4}", getVersion());
39 if (getVersion() >= 5)
40 OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
41 OS << ", abbr_offset = " << formatv("{0:x4}", getAbbrOffset());
42 if (!getAbbreviations())
43 OS << " (invalid)";
44 OS << ", addr_size = " << formatv("{0:x2}", getAddressByteSize())
45 << ", name = '" << Name << "'"
46 << ", type_signature = " << formatv("{0:x16}", getTypeHash())
47 << ", type_offset = " << formatv("{0:x4}", getTypeOffset())
48 << " (next unit at " << formatv("{0:x8}", getNextUnitOffset()) << ")\n";
49
50 if (DWARFDie TU = getUnitDIE(false))
51 TU.dump(OS, 0, DumpOpts);
52 else
53 OS << "<type unit can't be parsed!>\n\n";
54}
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition DWARFDie.h:43
LLVM_ABI const char * getName(DINameKind Kind) const
Return the DIE name resolving DW_AT_specification or DW_AT_abstract_origin references if necessary.
Definition DWARFDie.cpp:545
uint64_t getTypeOffset() const
void dump(raw_ostream &OS, DIDumpOptions DumpOpts={}) override
uint64_t getTypeHash() const
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
DWARFDie getDIEForOffset(uint64_t Offset)
Return the DIE object for a given offset Offset inside the unit's DIE vector.
Definition DWARFUnit.h:550
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