LLVM  13.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 #include "llvm/Support/Format.h"
14 
15 using namespace llvm;
16 
18  int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
19  OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:"
20  << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
21  << ", format = " << dwarf::FormatString(getFormat())
22  << ", version = " << format("0x%04x", getVersion());
23  if (getVersion() >= 5)
24  OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
25  OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset());
26  if (!getAbbreviations())
27  OS << " (invalid)";
28  OS << ", addr_size = " << format("0x%02x", getAddressByteSize());
29  if (getVersion() >= 5 && (getUnitType() == dwarf::DW_UT_skeleton ||
30  getUnitType() == dwarf::DW_UT_split_compile))
31  OS << ", DWO_id = " << format("0x%016" PRIx64, *getDWOId());
32  OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())
33  << ")\n";
34 
35  if (DWARFDie CUDie = getUnitDIE(false))
36  CUDie.dump(OS, 0, DumpOpts);
37  else
38  OS << "<compile unit can't be parsed!>\n\n";
39 }
40 
41 // VTable anchor.
llvm::DWARFUnit::getAbbreviations
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
Definition: DWARFUnit.cpp:834
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
DWARFCompileUnit.h
llvm::DWARFCompileUnit::~DWARFCompileUnit
~DWARFCompileUnit() override
VTable anchor.
llvm::DWARFUnit::getLength
uint64_t getLength() const
Definition: DWARFUnit.h:293
Format.h
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
llvm::DWARFUnit::getDWOId
Optional< uint64_t > getDWOId()
Definition: DWARFUnit.h:405
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::DWARFUnit::getFormat
dwarf::DwarfFormat getFormat() const
Definition: DWARFUnit.h:294
llvm::DWARFUnit::getNextUnitOffset
uint64_t getNextUnitOffset() const
Definition: DWARFUnit.h:298
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
llvm::DWARFCompileUnit::dump
void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override
Dump this compile unit to OS.
Definition: DWARFCompileUnit.cpp:17
llvm::DWARFUnit::getAddressByteSize
uint8_t getAddressByteSize() const
Definition: DWARFUnit.h:286
DWARFDebugAbbrev.h
llvm::DWARFUnit::getOffset
uint64_t getOffset() const
Definition: DWARFUnit.h:281
llvm::DWARFDie
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition: DWARFDie.h:43
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