DWARFCompileUnit.cpp 1.8 KB

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