forked from OSchip/llvm-project
Add more debugging output to MachO lld. NFC.
In debug builds there's now a dump method on Section and improved printing of atoms. llvm-svn: 255826
This commit is contained in:
parent
48dd080c77
commit
e5fa5a3c29
|
@ -179,6 +179,8 @@ void Resolver::doDefinedAtom(const DefinedAtom &atom) {
|
|||
<< atom.ordinal()
|
||||
<< ", name="
|
||||
<< atom.name()
|
||||
<< ", type="
|
||||
<< atom.contentType()
|
||||
<< "\n");
|
||||
|
||||
// add to list of known atoms
|
||||
|
@ -525,12 +527,29 @@ bool Resolver::resolve() {
|
|||
void Resolver::MergedFile::addAtoms(std::vector<const Atom *> &all) {
|
||||
ScopedTask task(getDefaultDomain(), "addAtoms");
|
||||
DEBUG_WITH_TYPE("resolver", llvm::dbgs() << "Resolver final atom list:\n");
|
||||
|
||||
for (const Atom *atom : all) {
|
||||
DEBUG_WITH_TYPE("resolver", llvm::dbgs()
|
||||
<< llvm::format(" 0x%09lX", atom)
|
||||
<< ", name="
|
||||
<< atom->name()
|
||||
<< "\n");
|
||||
#ifndef NDEBUG
|
||||
if (auto *definedAtom = dyn_cast<DefinedAtom>(atom)) {
|
||||
DEBUG_WITH_TYPE("resolver", llvm::dbgs()
|
||||
<< llvm::format(" 0x%09lX", atom)
|
||||
<< ", file=#"
|
||||
<< definedAtom->file().ordinal()
|
||||
<< ", atom=#"
|
||||
<< definedAtom->ordinal()
|
||||
<< ", name="
|
||||
<< definedAtom->name()
|
||||
<< ", type="
|
||||
<< definedAtom->contentType()
|
||||
<< "\n");
|
||||
} else {
|
||||
DEBUG_WITH_TYPE("resolver", llvm::dbgs()
|
||||
<< llvm::format(" 0x%09lX", atom)
|
||||
<< ", name="
|
||||
<< atom->name()
|
||||
<< "\n");
|
||||
}
|
||||
#endif
|
||||
addAtom(*atom);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorOr.h"
|
||||
#include "llvm/Support/MachO.h"
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
|
@ -119,6 +120,15 @@ struct Section {
|
|||
ArrayRef<uint8_t> content;
|
||||
Relocations relocations;
|
||||
IndirectSymbols indirectSymbols;
|
||||
|
||||
#ifndef NDEBUG
|
||||
raw_ostream& operator<<(raw_ostream &OS) const {
|
||||
dump(OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
void dump(raw_ostream &OS = llvm::dbgs()) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -27,13 +27,17 @@
|
|||
#include "MachONormalizedFileBinaryUtils.h"
|
||||
#include "lld/Core/Error.h"
|
||||
#include "lld/Core/LLVM.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/Support/MachO.h"
|
||||
#include "llvm/Support/LEB128.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm::MachO;
|
||||
using namespace lld::mach_o::normalized;
|
||||
|
||||
#define DEBUG_TYPE "normalized-file-to-atoms"
|
||||
|
||||
namespace lld {
|
||||
namespace mach_o {
|
||||
|
||||
|
@ -892,10 +896,13 @@ std::error_code
|
|||
normalizedObjectToAtoms(MachOFile *file,
|
||||
const NormalizedFile &normalizedFile,
|
||||
bool copyRefs) {
|
||||
DEBUG(llvm::dbgs() << "******** Normalizing file to atoms: "
|
||||
<< file->path() << "\n");
|
||||
bool scatterable = ((normalizedFile.flags & MH_SUBSECTIONS_VIA_SYMBOLS) != 0);
|
||||
|
||||
// Create atoms from each section.
|
||||
for (auto § : normalizedFile.sections) {
|
||||
DEBUG(llvm::dbgs() << "Creating atoms: "; sect.dump());
|
||||
if (isDebugInfoSection(sect))
|
||||
continue;
|
||||
bool customSectionName;
|
||||
|
@ -1061,6 +1068,14 @@ normalizedToAtoms(const NormalizedFile &normalizedFile, StringRef path,
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void Section::dump(llvm::raw_ostream &OS) const {
|
||||
OS << "Section (\"" << segmentName << ", " << sectionName << "\"";
|
||||
OS << ", addr: " << llvm::format_hex(address, 16, true);
|
||||
OS << ", size: " << llvm::format_hex(content.size(), 8, true) << ")\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace normalized
|
||||
} // namespace mach_o
|
||||
} // namespace lld
|
||||
|
|
Loading…
Reference in New Issue