LLVM 23.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
12#include "llvm/Support/Format.h"
16#include <cinttypes>
17
18using namespace llvm;
19
22 const char *Name = TD.getName(DINameKind::ShortName);
23 int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
24
25 if (DumpOpts.SummarizeTypes) {
26 OS << "name = '" << Name << "'"
27 << ", type_signature = " << formatv("{0:x16}", getTypeHash())
28 << ", length = "
30 OffsetDumpWidth, '0'))
31 << '\n';
32 return;
33 }
34
35 OS << formatv("{0:x8}", getOffset()) << ": Type Unit:"
36 << " length = "
37 << formatv("0x{0:x-}",
38 fmt_align(getLength(), AlignStyle::Right, OffsetDumpWidth, '0'))
39 << ", format = " << dwarf::FormatString(getFormat())
40 << ", version = " << formatv("{0:x4}", getVersion());
41 if (getVersion() >= 5)
42 OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
43 OS << ", abbr_offset = " << formatv("{0:x4}", getAbbrOffset());
44 if (!getAbbreviations())
45 OS << " (invalid)";
46 OS << ", addr_size = " << formatv("{0:x2}", getAddressByteSize())
47 << ", name = '" << Name << "'"
48 << ", type_signature = " << formatv("{0:x16}", getTypeHash())
49 << ", type_offset = " << formatv("{0:x4}", getTypeOffset())
50 << " (next unit at " << formatv("{0:x8}", getNextUnitOffset()) << ")\n";
51
52 if (DWARFDie TU = getUnitDIE(false))
53 TU.dump(OS, 0, DumpOpts);
54 else
55 OS << "<type unit can't be parsed!>\n\n";
56}
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:530
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:540
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