summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-09-13 18:22:59 +0000
committerAdrian Prantl <aprantl@apple.com>2017-09-13 18:22:59 +0000
commit3dcd122151ee58afc5f7f262c890bbfdbf47b08c (patch)
treee9bed3a2f0d8cf0b688c8f6a553cab03601181b5 /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
parentfb1baef1c0f28a2ad9071843e2b620e2ee30aaf6 (diff)
downloadbcm5719-llvm-3dcd122151ee58afc5f7f262c890bbfdbf47b08c.tar.gz
bcm5719-llvm-3dcd122151ee58afc5f7f262c890bbfdbf47b08c.zip
llvm-dwarfdump: support dumping UUIDs of Mach-O binaries.
This is a feature supported by Darwin dwarfdump. UUIDs are used to associate executables with their .dSYM bundles. llvm-svn: 313165
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index e9b3c0c132e..02c91d2464c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -80,6 +80,27 @@ static void dumpAccelSection(raw_ostream &OS, StringRef Name,
Accel.dump(OS);
}
+/// Dump the UUID load command.
+static void dumpUUID(raw_ostream &OS, const ObjectFile &Obj) {
+ auto *MachO = dyn_cast<MachOObjectFile>(&Obj);
+ if (!MachO)
+ return;
+ for (auto LC : MachO->load_commands()) {
+ raw_ostream::uuid_t UUID;
+ if (LC.C.cmd == MachO::LC_UUID) {
+ if (LC.C.cmdsize < sizeof(UUID) + sizeof(LC.C)) {
+ OS << "error: UUID load command is too short.\n";
+ return;
+ }
+ OS << "UUID: ";
+ memcpy(&UUID, LC.Ptr+sizeof(LC.C), sizeof(UUID));
+ OS.write_uuid(UUID);
+ OS << ' ' << MachO->getFileFormatName();
+ OS << ' ' << MachO->getFileName() << '\n';
+ }
+ }
+}
+
static void
dumpDWARFv5StringOffsetsSection(raw_ostream &OS, StringRef SectionName,
const DWARFObject &Obj,
@@ -203,6 +224,13 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
uint64_t DumpType = DumpOpts.DumpType;
bool DumpEH = DumpOpts.DumpEH;
+ const auto *ObjFile = DObj->getFile();
+ if (!(DumpType & DIDT_UUID) || DumpType == DIDT_All)
+ outs() << ObjFile->getFileName() << ":\tfile format "
+ << ObjFile->getFileFormatName() << "\n\n";
+ if (DumpType & DIDT_UUID)
+ dumpUUID(OS, *ObjFile);
+
if (DumpType & DIDT_DebugAbbrev) {
OS << ".debug_abbrev contents:\n";
getDebugAbbrev()->dump(OS);
OpenPOWER on IntegriCloud