1 //===- DWARFTypeUnit.cpp --------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/DIContext.h"
11 #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
12 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
13 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
14 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
15 #include "llvm/Support/Format.h"
16 #include "llvm/Support/raw_ostream.h"
21 bool DWARFTypeUnit::extractImpl(DataExtractor debug_info,
22 uint32_t *offset_ptr) {
23 if (!DWARFUnit::extractImpl(debug_info, offset_ptr))
25 TypeHash = debug_info.getU64(offset_ptr);
26 TypeOffset = debug_info.getU32(offset_ptr);
27 return TypeOffset < getLength();
30 void DWARFTypeUnit::dump(raw_ostream &OS, bool SummarizeTypes) {
31 DWARFDie TD = getDIEForOffset(TypeOffset + getOffset());
32 const char *Name = TD.getName(DINameKind::ShortName);
35 OS << "name = '" << Name << "'"
36 << " type_signature = " << format("0x%016" PRIx64, TypeHash)
37 << " length = " << format("0x%08x", getLength()) << '\n';
41 OS << format("0x%08x", getOffset()) << ": Type Unit:"
42 << " length = " << format("0x%08x", getLength())
43 << " version = " << format("0x%04x", getVersion());
44 if (getVersion() >= 5)
45 OS << " unit_type = " << dwarf::UnitTypeString(getUnitType());
46 OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset())
47 << " addr_size = " << format("0x%02x", getAddressByteSize())
48 << " name = '" << Name << "'"
49 << " type_signature = " << format("0x%016" PRIx64, TypeHash)
50 << " type_offset = " << format("0x%04x", TypeOffset)
51 << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n";
53 if (DWARFDie TU = getUnitDIE(false))
56 OS << "<type unit can't be parsed!>\n\n";