[llvm-objdump][MachO] Use the -dsym file name when reporting errors
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>
Thu, 10 Jan 2019 17:16:42 +0000 (17:16 +0000)
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>
Thu, 10 Jan 2019 17:16:42 +0000 (17:16 +0000)
Instead of using the binary filename.

llvm-svn: 350849

llvm/test/tools/llvm-objdump/invalid-input.test
llvm/tools/llvm-objdump/MachODump.cpp

index d9bf739..7e6c806 100644 (file)
@@ -7,3 +7,10 @@ UNKNOWN_FILE_TYPE: '{{.*}}invalid-input.test': The file was not recognized as a
 
 RUN: not llvm-objdump -macho -disassemble -g -dsym=%s %p/Inputs/bind.macho-x86_64 2>&1 | FileCheck %s -check-prefix=UNKNOWN_FILE_TYPE_DSYM
 UNKNOWN_FILE_TYPE_DSYM: {{.*}}llvm-objdump: error:
+
+RUN: not llvm-objdump -macho -disassemble -g -dsym=%p/missing-dsym %p/Inputs/bind.macho-x86_64 2>&1 | FileCheck %s -check-prefix=NO_SUCH_FILE_DSYM
+NO_SUCH_FILE_DSYM: error: {{.*}}missing-dsym:
+
+RUN: not llvm-objdump -macho -disassemble -g -dsym=%s %p/Inputs/bind.macho-x86_64 2>&1 | FileCheck %s -check-prefix=UNKNOWN_FILE_TYPE_DSYM_MSG
+UNKNOWN_FILE_TYPE_DSYM_MSG: {{.*}}llvm-objdump: error:
+UNKNOWN_FILE_TYPE_DSYM_MSG-NOT: bind.macho-x86_64
index 4198ff0..a8e90df 100644 (file)
@@ -6971,14 +6971,14 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
           MemoryBuffer::getFileOrSTDIN(DSYMFile);
       if (std::error_code EC = BufOrErr.getError()) {
         WithColor::error(errs(), "llvm-objdump")
-            << Filename << ": " << EC.message() << '\n';
+            << DSYMFile << ": " << EC.message() << '\n';
         return;
       }
       Expected<std::unique_ptr<MachOObjectFile>> DbgObjCheck =
           ObjectFile::createMachOObjectFile(BufOrErr.get()->getMemBufferRef());
 
       if (Error E = DbgObjCheck.takeError())
-        report_error(MachOOF->getFileName(), std::move(E));
+        report_error(DSYMFile, std::move(E));
 
       DbgObj = DbgObjCheck.get().release();
       // We need to keep the file alive, because we're replacing DbgObj with it.