summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2016-10-31 16:46:02 +0000
committerGreg Clayton <gclayton@apple.com>2016-10-31 16:46:02 +0000
commitcddab279f6978fca9ae5a5676c7346f384579d2c (patch)
tree6624cdcb50838123e6cf69e73541ad40e33cacf4 /llvm/tools
parent218770b827cac5e36e9739d0c47f4c67d05434ea (diff)
downloadbcm5719-llvm-cddab279f6978fca9ae5a5676c7346f384579d2c.tar.gz
bcm5719-llvm-cddab279f6978fca9ae5a5676c7346f384579d2c.zip
Modify DWARFFormValue to remember the DWARFUnit that it was decoded with.
Modifying DWARFFormValue to remember the DWARFUnit that it was encoded with can simplify the usage of instances of this class. Previously users would have to try and pass in the same DWARFUnit that was used to decode the form value and there was a possibility that a different DWARFUnit might be supplied to the functions that extract values (strings, CU relative references, addresses) and cause problems. This fixes this potential issue by storing the DWARFUnit inside the DWARFFormValue so that this mistake can't be made. Instances of DWARFFormValue are not stored permanently and are used as temporary values, so the increase in size of an instance of DWARFFormValue isn't a big deal. This makes decoding form values more bullet proof and is a change that will be used by future modifications. https://reviews.llvm.org/D26052 llvm-svn: 285594
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index cb8bb7eeca8..778c76043ae 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -1487,7 +1487,7 @@ static const DWARFDebugInfoEntryMinimal *resolveDIEReference(
const DWARFFormValue &RefValue, const DWARFUnit &Unit,
const DWARFDebugInfoEntryMinimal &DIE, CompileUnit *&RefCU) {
assert(RefValue.isFormClass(DWARFFormValue::FC_Reference));
- uint64_t RefOffset = *RefValue.getAsReference(&Unit);
+ uint64_t RefOffset = *RefValue.getAsReference();
if ((RefCU = getUnitForOffset(Units, RefOffset)))
if (const auto *RefDie = RefCU->getOrigUnit().getDIEForOffset(RefOffset))
@@ -1838,12 +1838,6 @@ static bool dieNeedsChildrenToBeMeaningful(uint32_t Tag) {
llvm_unreachable("Invalid Tag");
}
-static unsigned getRefAddrSize(const DWARFUnit &U) {
- if (U.getVersion() == 2)
- return U.getAddressByteSize();
- return 4;
-}
-
void DwarfLinker::startDebugObject(DWARFContext &Dwarf, DebugMapObject &Obj) {
Units.reserve(Dwarf.getNumCompileUnits());
// Iterate over the debug map entries and put all the ones that are
@@ -2159,7 +2153,7 @@ unsigned DwarfLinker::shouldKeepSubprogramDIE(
uint64_t HighPc;
if (HighPcValue.isFormClass(DWARFFormValue::FC_Address)) {
- HighPc = *HighPcValue.getAsAddress(&OrigUnit);
+ HighPc = *HighPcValue.getAsAddress();
} else {
assert(HighPcValue.isFormClass(DWARFFormValue::FC_Constant));
HighPc = LowPc + *HighPcValue.getAsUnsignedConstant();
@@ -2357,7 +2351,7 @@ unsigned DwarfLinker::DIECloner::cloneStringAttribute(DIE &Die,
const DWARFFormValue &Val,
const DWARFUnit &U) {
// Switch everything to out of line strings.
- const char *String = *Val.getAsCString(&U);
+ const char *String = *Val.getAsCString();
unsigned Offset = Linker.StringPool.getStringOffset(String);
Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_strp,
DIEInteger(Offset));
@@ -2369,7 +2363,7 @@ unsigned DwarfLinker::DIECloner::cloneDieReferenceAttribute(
AttributeSpec AttrSpec, unsigned AttrSize, const DWARFFormValue &Val,
CompileUnit &Unit) {
const DWARFUnit &U = Unit.getOrigUnit();
- uint32_t Ref = *Val.getAsReference(&U);
+ uint32_t Ref = *Val.getAsReference();
DIE *NewRefDie = nullptr;
CompileUnit *RefUnit = nullptr;
DeclContext *Ctxt = nullptr;
@@ -2392,7 +2386,7 @@ unsigned DwarfLinker::DIECloner::cloneDieReferenceAttribute(
DIEInteger Attr(Ctxt->getCanonicalDIEOffset());
Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
dwarf::DW_FORM_ref_addr, Attr);
- return getRefAddrSize(U);
+ return U.getRefAddrByteSize();
}
}
@@ -2427,7 +2421,7 @@ unsigned DwarfLinker::DIECloner::cloneDieReferenceAttribute(
Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
dwarf::DW_FORM_ref_addr, DIEInteger(Attr)));
}
- return getRefAddrSize(U);
+ return U.getRefAddrByteSize();
}
Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
@@ -2481,7 +2475,7 @@ unsigned DwarfLinker::DIECloner::cloneBlockAttribute(DIE &Die,
unsigned DwarfLinker::DIECloner::cloneAddressAttribute(
DIE &Die, AttributeSpec AttrSpec, const DWARFFormValue &Val,
const CompileUnit &Unit, AttributesInfo &Info) {
- uint64_t Addr = *Val.getAsAddress(&Unit.getOrigUnit());
+ uint64_t Addr = *Val.getAsAddress();
if (AttrSpec.Attr == dwarf::DW_AT_low_pc) {
if (Die.getTag() == dwarf::DW_TAG_inlined_subroutine ||
Die.getTag() == dwarf::DW_TAG_lexical_block)
OpenPOWER on IntegriCloud