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