LLVM  14.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 
14 #include "llvm/Support/Format.h"
16 #include <cinttypes>
17 
18 using 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 = " << format("0x%016" PRIx64, getTypeHash())
28  << ", length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
29  << '\n';
30  return;
31  }
32 
33  OS << format("0x%08" PRIx64, getOffset()) << ": Type Unit:"
34  << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
35  << ", format = " << dwarf::FormatString(getFormat())
36  << ", version = " << format("0x%04x", getVersion());
37  if (getVersion() >= 5)
38  OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
39  OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset());
40  if (!getAbbreviations())
41  OS << " (invalid)";
42  OS << ", addr_size = " << format("0x%02x", getAddressByteSize())
43  << ", name = '" << Name << "'"
44  << ", type_signature = " << format("0x%016" PRIx64, getTypeHash())
45  << ", type_offset = " << format("0x%04" PRIx64, getTypeOffset())
46  << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())
47  << ")\n";
48 
49  if (DWARFDie TU = getUnitDIE(false))
50  TU.dump(OS, 0, DumpOpts);
51  else
52  OS << "<type unit can't be parsed!>\n\n";
53 }
llvm::DWARFUnit::getAbbreviations
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
Definition: DWARFUnit.cpp:815
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::DWARFUnit::getLength
uint64_t getLength() const
Definition: DWARFUnit.h:293
llvm::DIDumpOptions::SummarizeTypes
bool SummarizeTypes
Definition: DIContext.h:190
Format.h
llvm::DWARFTypeUnit::getTypeHash
uint64_t getTypeHash() const
Definition: DWARFTypeUnit.h:36
llvm::DWARFUnit::getAbbrOffset
uint64_t getAbbrOffset() const
Definition: DWARFUnit.h:297
llvm::DWARFUnit::getUnitType
uint8_t getUnitType() const
Definition: DWARFUnit.h:295
llvm::DWARFUnit::getUnitDIE
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Definition: DWARFUnit.h:390
DWARFDie.h
llvm::dwarf::FormatString
StringRef FormatString(DwarfFormat Format)
Definition: Dwarf.cpp:790
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::DINameKind::ShortName
@ ShortName
DWARFUnit.h
llvm::DWARFUnit::getFormat
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:294
llvm::DWARFTypeUnit::getTypeOffset
uint64_t getTypeOffset() const
Definition: DWARFTypeUnit.h:37
llvm::DWARFUnit::getNextUnitOffset
uint64_t getNextUnitOffset() const
Definition: DWARFUnit.h:298
llvm::DWARFTypeUnit::dump
void dump(raw_ostream &OS, DIDumpOptions DumpOpts={}) override
Definition: DWARFTypeUnit.cpp:20
llvm::DWARFDie::getName
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:618
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
DIContext.h
llvm::DWARFUnit::getAddressByteSize
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:286
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
DWARFDebugAbbrev.h
llvm::DWARFUnit::getOffset
uint64_t getOffset() const
Definition: DWARFUnit.h:281
DWARFTypeUnit.h
llvm::DWARFDie
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition: DWARFDie.h:43
llvm::DWARFUnit::getDIEForOffset
DWARFDie getDIEForOffset(uint64_t Offset)
Return the DIE object for a given offset inside the unit's DIE vector.
Definition: DWARFUnit.h:479
raw_ostream.h
llvm::dwarf::getDwarfOffsetByteSize
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:635
llvm::dwarf::UnitTypeString
StringRef UnitTypeString(unsigned)
Definition: Dwarf.cpp:576
llvm::DWARFUnit::getVersion
uint16_t getVersion() const
Definition: DWARFUnit.h:285
llvm::DIDumpOptions
Container for dump options that control which debug information will be dumped.
Definition: DIContext.h:180