1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
llvm-mirror/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
Greg Clayton 18fb71a6df Make a DWARFDIE class that can help avoid using the wrong DWARFUnit when extracting attributes
Many places pass around a DWARFDebugInfoEntryMinimal and a DWARFUnit. It is easy to get things wrong by using the wrong DWARFUnit with a DWARFDebugInfoEntryMinimal. This patch creates a DWARFDie class that contains the DWARFUnit and DWARFDebugInfoEntryMinimal objects so that they can't get out of sync. All attribute extraction has been moved out of DWARFDebugInfoEntryMinimal and into DWARFDie. DWARFDebugInfoEntryMinimal was also renamed to DWARFDebugInfoEntry.

DWARFDie objects are temporary objects that are used by clients and contain 2 pointers that you always need to have anyway. Keeping them grouped will avoid errors and simplify many of the attribute extracting APIs by not having to pass in a DWARFUnit.

Differential Revision: https://reviews.llvm.org/D27634

llvm-svn: 289565
2016-12-13 18:25:19 +00:00

35 lines
1.2 KiB
C++

//===-- DWARFCompileUnit.cpp ----------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
void DWARFCompileUnit::dump(raw_ostream &OS) {
OS << format("0x%08x", getOffset()) << ": Compile Unit:"
<< " length = " << format("0x%08x", getLength())
<< " version = " << format("0x%04x", getVersion())
<< " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset())
<< " addr_size = " << format("0x%02x", getAddressByteSize())
<< " (next unit at " << format("0x%08x", getNextUnitOffset())
<< ")\n";
if (DWARFDie CUDie = getUnitDIE(false))
CUDie.dump(OS, -1U);
else
OS << "<compile unit can't be parsed!>\n\n";
}
// VTable anchor.
DWARFCompileUnit::~DWARFCompileUnit() = default;