]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
Vendor import of llvm trunk r338150:
[FreeBSD/FreeBSD.git] / lib / DebugInfo / DWARF / DWARFTypeUnit.cpp
1 //===- DWARFTypeUnit.cpp --------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
11 #include "llvm/DebugInfo/DIContext.h"
12 #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
13 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
14 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
15 #include "llvm/Support/Format.h"
16 #include "llvm/Support/raw_ostream.h"
17 #include <cinttypes>
18
19 using namespace llvm;
20
21 void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
22   DWARFDie TD = getDIEForOffset(getTypeOffset() + getOffset());
23   const char *Name = TD.getName(DINameKind::ShortName);
24
25   if (DumpOpts.SummarizeTypes) {
26     OS << "name = '" << Name << "'"
27        << " type_signature = " << format("0x%016" PRIx64, getTypeHash())
28        << " length = " << format("0x%08x", getLength()) << '\n';
29     return;
30   }
31
32   OS << format("0x%08x", getOffset()) << ": Type Unit:"
33      << " length = " << format("0x%08x", getLength())
34      << " version = " << format("0x%04x", getVersion());
35   if (getVersion() >= 5)
36     OS << " unit_type = " << dwarf::UnitTypeString(getUnitType());
37   OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset())
38      << " addr_size = " << format("0x%02x", getAddressByteSize())
39      << " name = '" << Name << "'"
40      << " type_signature = " << format("0x%016" PRIx64, getTypeHash())
41      << " type_offset = " << format("0x%04x", getTypeOffset())
42      << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n";
43
44   if (DWARFDie TU = getUnitDIE(false))
45     TU.dump(OS, 0, DumpOpts);
46   else
47     OS << "<type unit can't be parsed!>\n\n";
48 }