Improved debugging printing. NFC

llvm-svn: 256805
This commit is contained in:
Pete Cooper 2016-01-05 01:56:59 +00:00
parent 54fc6575c5
commit 52db793d33
2 changed files with 54 additions and 9 deletions

View File

@ -507,6 +507,23 @@ void ArchHandler_arm64::generateAtomContent(
// Copy raw bytes.
memcpy(atomContentBuffer, atom.rawContent().data(), atom.size());
// Apply fix-ups.
#ifndef NDEBUG
if (atom.begin() != atom.end()) {
DEBUG_WITH_TYPE("atom-content", llvm::dbgs()
<< "Applying fixups to atom:\n"
<< " address="
<< llvm::format(" 0x%09lX", &atom)
<< ", file=#"
<< atom.file().ordinal()
<< ", atom=#"
<< atom.ordinal()
<< ", name="
<< atom.name()
<< ", type="
<< atom.contentType()
<< "\n");
}
#endif
for (const Reference *ref : atom) {
uint32_t offset = ref->offsetInAtom();
const Atom *target = ref->target();

View File

@ -625,19 +625,47 @@ void Util::buildAtomToAddressMap() {
_entryAtom = info.atom;
}
DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs()
<< " address="
<< llvm::format("0x%016X", _atomToAddress[info.atom])
<< " atom=" << info.atom
<< " name=" << info.atom->name() << "\n");
<< " address="
<< llvm::format("0x%016X", _atomToAddress[info.atom])
<< llvm::format(" 0x%09lX", info.atom)
<< ", file=#"
<< info.atom->file().ordinal()
<< ", atom=#"
<< info.atom->ordinal()
<< ", name="
<< info.atom->name()
<< ", type="
<< info.atom->contentType()
<< "\n");
}
}
DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs()
<< "assign header alias atom addresses:\n");
for (const Atom *atom : _machHeaderAliasAtoms) {
_atomToAddress[atom] = _ctx.baseAddress();
DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs()
<< " address="
<< llvm::format("0x%016X", _atomToAddress[atom])
<< " atom=" << atom
<< " name=" << atom->name() << "\n");
#ifndef NDEBUG
if (auto *definedAtom = dyn_cast<DefinedAtom>(atom)) {
DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs()
<< " address="
<< llvm::format("0x%016X", _atomToAddress[atom])
<< llvm::format(" 0x%09lX", atom)
<< ", file=#"
<< definedAtom->file().ordinal()
<< ", atom=#"
<< definedAtom->ordinal()
<< ", name="
<< definedAtom->name()
<< ", type="
<< definedAtom->contentType()
<< "\n");
} else {
DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs()
<< " address="
<< llvm::format("0x%016X", _atomToAddress[atom])
<< " atom=" << atom
<< " name=" << atom->name() << "\n");
}
#endif
}
}