/src/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
9 | | #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" |
10 | | #include "llvm/DebugInfo/DIContext.h" |
11 | | #include "llvm/DebugInfo/DWARF/DWARFDie.h" |
12 | | |
13 | | #include "llvm/Support/Format.h" |
14 | | #include "llvm/Support/raw_ostream.h" |
15 | | |
16 | | using namespace llvm; |
17 | | |
18 | 3 | void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { |
19 | 3 | if (DumpOpts.SummarizeTypes) |
20 | 0 | return; |
21 | 3 | int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat()); |
22 | 3 | OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:" |
23 | 3 | << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength()) |
24 | 3 | << ", format = " << dwarf::FormatString(getFormat()) |
25 | 3 | << ", version = " << format("0x%04x", getVersion()); |
26 | 3 | if (getVersion() >= 5) |
27 | 0 | OS << ", unit_type = " << dwarf::UnitTypeString(getUnitType()); |
28 | 3 | OS << ", abbr_offset = " << format("0x%04" PRIx64, getAbbrOffset()); |
29 | 3 | if (!getAbbreviations()) |
30 | 0 | OS << " (invalid)"; |
31 | 3 | OS << ", addr_size = " << format("0x%02x", getAddressByteSize()); |
32 | 3 | if (getVersion() >= 5 && (getUnitType() == dwarf::DW_UT_skeleton || |
33 | 0 | getUnitType() == dwarf::DW_UT_split_compile)) |
34 | 0 | OS << ", DWO_id = " << format("0x%016" PRIx64, *getDWOId()); |
35 | 3 | OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset()) |
36 | 3 | << ")\n"; |
37 | | |
38 | 3 | if (DWARFDie CUDie = getUnitDIE(false)) { |
39 | 3 | CUDie.dump(OS, 0, DumpOpts); |
40 | 3 | if (DumpOpts.DumpNonSkeleton) { |
41 | 0 | DWARFDie NonSkeletonCUDie = getNonSkeletonUnitDIE(false); |
42 | 0 | if (NonSkeletonCUDie && CUDie != NonSkeletonCUDie) |
43 | 0 | NonSkeletonCUDie.dump(OS, 0, DumpOpts); |
44 | 0 | } |
45 | 3 | } else { |
46 | 0 | OS << "<compile unit can't be parsed!>\n\n"; |
47 | 0 | } |
48 | 3 | } |
49 | | |
50 | | // VTable anchor. |
51 | 3 | DWARFCompileUnit::~DWARFCompileUnit() = default; |