DWARFTypeUnit.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
  10. #include "llvm/Support/Format.h"
  11. #include "llvm/Support/raw_ostream.h"
  12. using namespace llvm;
  13. bool DWARFTypeUnit::extractImpl(DataExtractor debug_info,
  14. uint32_t *offset_ptr) {
  15. if (!DWARFUnit::extractImpl(debug_info, offset_ptr))
  16. return false;
  17. TypeHash = debug_info.getU64(offset_ptr);
  18. TypeOffset = debug_info.getU32(offset_ptr);
  19. return TypeOffset < getLength();
  20. }
  21. void DWARFTypeUnit::dump(raw_ostream &OS) {
  22. OS << format("0x%08x", getOffset()) << ": Type Unit:"
  23. << " length = " << format("0x%08x", getLength())
  24. << " version = " << format("0x%04x", getVersion())
  25. << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset())
  26. << " addr_size = " << format("0x%02x", getAddressByteSize())
  27. << " type_signature = " << format("0x%16" PRIx64, TypeHash)
  28. << " type_offset = " << format("0x%04x", TypeOffset)
  29. << " (next unit at " << format("0x%08x", getNextUnitOffset())
  30. << ")\n";
  31. if (const DWARFDebugInfoEntryMinimal *TU = getUnitDIE(false))
  32. TU->dump(OS, this, -1U);
  33. else
  34. OS << "<type unit can't be parsed!>\n\n";
  35. }