| Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 1 | //===-- DWARFCompileUnit.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 | |
| Zachary Turner | 82af943 | 2015-01-30 18:07:45 +0000 | [diff] [blame] | 10 | #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" |
| Eugene Zelenko | 570e39a | 2016-11-23 23:16:32 +0000 | [diff] [blame] | 11 | #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" |
| Greg Clayton | c8c1032 | 2016-12-13 18:25:19 +0000 | [diff] [blame] | 12 | #include "llvm/DebugInfo/DWARF/DWARFDie.h" |
| Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 13 | #include "llvm/Support/Format.h" |
| 14 | #include "llvm/Support/raw_ostream.h" |
| David Blaikie | 07e2244 | 2013-09-23 22:44:40 +0000 | [diff] [blame] | 15 | |
| Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 16 | using namespace llvm; |
| Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 17 | |
| Adrian Prantl | 318d119 | 2017-06-06 23:28:45 +0000 | [diff] [blame] | 18 | void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { |
| David Blaikie | 07e2244 | 2013-09-23 22:44:40 +0000 | [diff] [blame] | 19 | OS << format("0x%08x", getOffset()) << ": Compile Unit:" |
| 20 | << " length = " << format("0x%08x", getLength()) |
| Paul Robinson | cddd604 | 2017-02-28 20:24:55 +0000 | [diff] [blame] | 21 | << " version = " << format("0x%04x", getVersion()); |
| 22 | if (getVersion() >= 5) |
| 23 | OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); |
| 24 | OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset()) |
| Paul Robinson | 543c0e1 | 2018-05-22 17:27:31 +0000 | [diff] [blame^] | 25 | << " addr_size = " << format("0x%02x", getAddressByteSize()); |
| 26 | if (getVersion() >= 5 && getUnitType() != dwarf::DW_UT_compile) |
| 27 | OS << " DWO_id = " << format("0x%016" PRIx64, *getDWOId()); |
| 28 | OS << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n"; |
| Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 29 | |
| Greg Clayton | c8c1032 | 2016-12-13 18:25:19 +0000 | [diff] [blame] | 30 | if (DWARFDie CUDie = getUnitDIE(false)) |
| Adrian Prantl | d3f9f21 | 2017-09-20 17:44:00 +0000 | [diff] [blame] | 31 | CUDie.dump(OS, 0, DumpOpts); |
| Alexey Samsonov | 7a18c06 | 2015-05-19 21:54:32 +0000 | [diff] [blame] | 32 | else |
| 33 | OS << "<compile unit can't be parsed!>\n\n"; |
| Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| David Blaikie | 07e2244 | 2013-09-23 22:44:40 +0000 | [diff] [blame] | 36 | // VTable anchor. |
| Eugene Zelenko | 570e39a | 2016-11-23 23:16:32 +0000 | [diff] [blame] | 37 | DWARFCompileUnit::~DWARFCompileUnit() = default; |