LLVM 20.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
13#include "llvm/Support/Format.h"
15
16using namespace llvm;
17
19 if (DumpOpts.SummarizeTypes)
20 return;
21 int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
22 OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:"
23 << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
24 << ", format = " << dwarf::FormatString(getFormat())
25 << ", version = " << format("0x%04x", getVersion());
26 if (getVersion() >= 5)
27 OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType());
28 OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset());
29 if (!getAbbreviations())
30 OS << " (invalid)";
31 OS << ", addr_size = " << format("0x%02x", getAddressByteSize());
32 if (getVersion() >= 5 && (getUnitType() == dwarf::DW_UT_skeleton ||
33 getUnitType() == dwarf::DW_UT_split_compile))
34 OS << ", DWO_id = " << format("0x%016" PRIx64, *getDWOId());
35 OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())
36 << ")\n";
37
38 if (DWARFDie CUDie = getUnitDIE(false)) {
39 CUDie.dump(OS, 0, DumpOpts);
40 if (DumpOpts.DumpNonSkeleton) {
41 DWARFDie NonSkeletonCUDie = getNonSkeletonUnitDIE(false);
42 if (NonSkeletonCUDie && CUDie != NonSkeletonCUDie)
43 NonSkeletonCUDie.dump(OS, 0, DumpOpts);
44 }
45 } else {
46 OS << "<compile unit can't be parsed!>\n\n";
47 }
48}
49
50// VTable anchor.
raw_pwrite_stream & OS
~DWARFCompileUnit() override
VTable anchor.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override
Dump this compile unit to OS.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition: DWARFDie.h:42
void dump(raw_ostream &OS, unsigned indent=0, DIDumpOptions DumpOpts=DIDumpOptions()) const
Dump the DIE and all of its attributes to the supplied stream.
Definition: DWARFDie.cpp:580
std::optional< uint64_t > getDWOId()
Definition: DWARFUnit.h:458
DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly=true, StringRef DWOAlternativeLocation={})
Definition: DWARFUnit.h:450
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:1054
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:868
StringRef UnitTypeString(unsigned)
Definition: Dwarf.cpp:653
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:1064
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:196