LLVM 19.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"
14#include <cinttypes>
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 = " << format("0x%016" PRIx64, getTypeHash())
26 << ", length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
27 << '\n';
28 return;
29 }
30
31 OS << format("0x%08" PRIx64, getOffset()) << ": Type Unit:"
32 << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
33 << ", format = " << dwarf::FormatString(getFormat())
34 << ", version = " << format("0x%04x", getVersion());
35 if (getVersion() >= 5)
36 OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
37 OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset());
38 if (!getAbbreviations())
39 OS << " (invalid)";
40 OS << ", addr_size = " << format("0x%02x", getAddressByteSize())
41 << ", name = '" << Name << "'"
42 << ", type_signature = " << format("0x%016" PRIx64, getTypeHash())
43 << ", type_offset = " << format("0x%04" PRIx64, getTypeOffset())
44 << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())
45 << ")\n";
46
47 if (DWARFDie TU = getUnitDIE(false))
48 TU.dump(OS, 0, DumpOpts);
49 else
50 OS << "<type unit can't be parsed!>\n\n";
51}
std::string Name
raw_pwrite_stream & OS
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition: DWARFDie.h:42
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:445
uint64_t getTypeOffset() const
Definition: DWARFTypeUnit.h:36
void dump(raw_ostream &OS, DIDumpOptions DumpOpts={}) override
uint64_t getTypeHash() const
Definition: DWARFTypeUnit.h:35
uint8_t getUnitType() const
Definition: DWARFUnit.h:335
uint64_t getLength() const
Definition: DWARFUnit.h:333
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Definition: DWARFUnit.h:443
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:326
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
Definition: DWARFUnit.cpp:1031
DWARFDie getDIEForOffset(uint64_t Offset)
Return the DIE object for a given offset Offset inside the unit's DIE vector.
Definition: DWARFUnit.h:533
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:334
uint16_t getVersion() const
Definition: DWARFUnit.h:325
uint64_t getAbbrOffset() const
Definition: DWARFUnit.h:337
uint64_t getNextUnitOffset() const
Definition: DWARFUnit.h:338
uint64_t getOffset() const
Definition: DWARFUnit.h:321
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
StringRef FormatString(DwarfFormat Format)
Definition: Dwarf.cpp:826
StringRef UnitTypeString(unsigned)
Definition: Dwarf.cpp:611
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:749
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:125
Container for dump options that control which debug information will be dumped.
Definition: DIContext.h:193