summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Trent <mtrent@apple.com>2019-09-20 19:13:24 +0000
committerMichael Trent <mtrent@apple.com>2019-09-20 19:13:24 +0000
commit6a234677f4916fc647e463f058feeff73b131879 (patch)
treea79b9425291051fa55c13217dcfb9cee89f02c9e
parentc139d1e28109450085a11e3b2ec7d53c6a00c37b (diff)
downloadbcm5719-llvm-6a234677f4916fc647e463f058feeff73b131879.tar.gz
bcm5719-llvm-6a234677f4916fc647e463f058feeff73b131879.zip
Can't pass .dSYM directory to llvm-objdump -dsym= (and error message is wrong)
Summary: Allow users to pass the path to a .dSYM directory to llvm-objdump's -dsym flag rather than requiring users to find the DWARF DSYM Mach-O within the bundle structure by hand. rdar://46873333 Reviewers: pete, lhames, friss, aprantl Reviewed By: pete, aprantl Subscribers: MaskRay, aprantl, rupprecht, seiya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67780 llvm-svn: 372421
-rw-r--r--llvm/tools/llvm-objdump/MachODump.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 25b721ae558..284f9b2a7af 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -7340,10 +7340,24 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
// A separate DSym file path was specified, parse it as a macho file,
// get the sections and supply it to the section name parsing machinery.
if (!DSYMFile.empty()) {
+ std::string DSYMPath(DSYMFile);
+
+ // If DSYMPath is a .dSYM directory, append the Mach-O file.
+ if (llvm::sys::fs::is_directory(DSYMPath) &&
+ llvm::sys::path::extension(DSYMPath) == ".dSYM") {
+ SmallString<128> ShortName(llvm::sys::path::filename(DSYMPath));
+ llvm::sys::path::replace_extension(ShortName, "");
+ SmallString<1024> FullPath(DSYMPath);
+ llvm::sys::path::append(FullPath, "Contents", "Resources", "DWARF",
+ ShortName);
+ DSYMPath = FullPath.str();
+ }
+
+ // Load the file.
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
- MemoryBuffer::getFileOrSTDIN(DSYMFile);
+ MemoryBuffer::getFileOrSTDIN(DSYMPath);
if (std::error_code EC = BufOrErr.getError()) {
- reportError(errorCodeToError(EC), DSYMFile);
+ reportError(errorCodeToError(EC), DSYMPath);
return;
}
@@ -7353,13 +7367,12 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
Expected<std::unique_ptr<Binary>> BinaryOrErr =
createBinary(DSYMBuf.get()->getMemBufferRef());
if (!BinaryOrErr) {
- reportError(BinaryOrErr.takeError(), DSYMFile);
+ reportError(BinaryOrErr.takeError(), DSYMPath);
return;
}
- // We need to keep the Binary elive with the buffer
+ // We need to keep the Binary alive with the buffer
DSYMBinary = std::move(BinaryOrErr.get());
-
if (ObjectFile *O = dyn_cast<ObjectFile>(DSYMBinary.get())) {
// this is a Mach-O object file, use it
if (MachOObjectFile *MachDSYM = dyn_cast<MachOObjectFile>(&*O)) {
@@ -7367,7 +7380,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
}
else {
WithColor::error(errs(), "llvm-objdump")
- << DSYMFile << " is not a Mach-O file type.\n";
+ << DSYMPath << " is not a Mach-O file type.\n";
return;
}
}
@@ -7389,17 +7402,17 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
Expected<std::unique_ptr<MachOObjectFile>> MachDSYM =
UB->getMachOObjectForArch(ArchFlag);
if (!MachDSYM) {
- reportError(MachDSYM.takeError(), DSYMFile);
+ reportError(MachDSYM.takeError(), DSYMPath);
return;
}
- // We need to keep the Binary elive with the buffer
+ // We need to keep the Binary alive with the buffer
DbgObj = &*MachDSYM.get();
DSYMBinary = std::move(*MachDSYM);
}
else {
WithColor::error(errs(), "llvm-objdump")
- << DSYMFile << " is not a Mach-O or Universal file type.\n";
+ << DSYMPath << " is not a Mach-O or Universal file type.\n";
return;
}
}
OpenPOWER on IntegriCloud