From 31d8b7d21d54beeab4eccc60887db798b025235f Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 26 Oct 2016 22:37:52 +0000 Subject: [PATCH] llvm-objdump: Make some error messages more consistent Most of the version of report_error were quoting the filename and printing a colon between the file name and the error message, but this one wasn't doing either of those. Fix the output to be more consistent. llvm-svn: 285252 --- llvm/test/Object/macho-invalid.test | 14 +++++++------- llvm/test/tools/llvm-objdump/malformed-archives.test | 12 ++++++------ llvm/tools/llvm-objdump/llvm-objdump.cpp | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/test/Object/macho-invalid.test b/llvm/test/Object/macho-invalid.test index 403b968..897b28e 100644 --- a/llvm/test/Object/macho-invalid.test +++ b/llvm/test/Object/macho-invalid.test @@ -61,14 +61,14 @@ NAME-PAST-EOF-nm-pax: 0000000000000000 64 00 0000 fe000002 bad string index RUN: not llvm-objdump -t %p/Inputs/macho-bad-archive1.a 2>&1 \ RUN: | FileCheck -check-prefix NAME-PAST-EOF-ARCHIVE %s -NAME-PAST-EOF-ARCHIVE: macho-bad-archive1.a(macho-invalid-symbol-name-past-eof) truncated or malformed object (bad string index: 4261412866 for symbol at index 0) +NAME-PAST-EOF-ARCHIVE: macho-bad-archive1.a(macho-invalid-symbol-name-past-eof): truncated or malformed object (bad string index: 4261412866 for symbol at index 0) RUN: not llvm-objdump -macho -arch all -t %p/Inputs/macho-universal-bad1.x86_64.i386 2>&1 \ RUN: | FileCheck -check-prefix NAME-PAST-EOF-FAT %s -NAME-PAST-EOF-FAT: macho-universal-bad1.x86_64.i386 (for architecture x86_64) truncated or malformed object (bad string index: 4261412866 for symbol at index 0) +NAME-PAST-EOF-FAT: macho-universal-bad1.x86_64.i386' (for architecture x86_64): truncated or malformed object (bad string index: 4261412866 for symbol at index 0) RUN: not llvm-objdump -macho -arch all -t %p/Inputs/macho-universal-archive-bad1.x86_64.i386 2>&1 \ RUN: | FileCheck -check-prefix NAME-PAST-EOF-FAT-ARCHIVE %s -NAME-PAST-EOF-FAT-ARCHIVE: macho-universal-archive-bad1.x86_64.i386(macho-invalid-symbol-name-past-eof) (for architecture x86_64) truncated or malformed object (bad string index: 4261412866 for symbol at index 0) +NAME-PAST-EOF-FAT-ARCHIVE: macho-universal-archive-bad1.x86_64.i386(macho-invalid-symbol-name-past-eof) (for architecture x86_64): truncated or malformed object (bad string index: 4261412866 for symbol at index 0) RUN: llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \ RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC %s @@ -90,13 +90,13 @@ RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomple INCOMPLETE-SEGMENT-LOADC: truncated or malformed object (load commands extend past the end of the file) RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-bad-archive2.a 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-ARCHIVE %s -INCOMPLETE-SEGMENT-LOADC-ARCHIVE: macho-bad-archive2.a(macho64-invalid-incomplete-segment-load-command) truncated or malformed object (load commands extend past the end of the file) +INCOMPLETE-SEGMENT-LOADC-ARCHIVE: macho-bad-archive2.a(macho64-invalid-incomplete-segment-load-command): truncated or malformed object (load commands extend past the end of the file) RUN: not llvm-objdump -macho -private-headers -arch all %p/Inputs/macho-universal-bad2.x86_64.i386 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-FAT %s -INCOMPLETE-SEGMENT-LOADC-FAT: macho-universal-bad2.x86_64.i386 (for architecture x86_64) truncated or malformed object (load commands extend past the end of the file) +INCOMPLETE-SEGMENT-LOADC-FAT: macho-universal-bad2.x86_64.i386' (for architecture x86_64): truncated or malformed object (load commands extend past the end of the file) RUN: not llvm-objdump -macho -private-headers -arch all %p/Inputs/macho-universal-archive-bad2.x86_64.i386 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-FAT-ARCHIVE %s -INCOMPLETE-SEGMENT-LOADC-FAT-ARCHIVE: macho-universal-archive-bad2.x86_64.i386(macho64-invalid-incomplete-segment-load-command) (for architecture x86_64) truncated or malformed object (load commands extend past the end of the file) +INCOMPLETE-SEGMENT-LOADC-FAT-ARCHIVE: macho-universal-archive-bad2.x86_64.i386(macho64-invalid-incomplete-segment-load-command) (for architecture x86_64): truncated or malformed object (load commands extend past the end of the file) RUN: not llvm-objdump -macho -universal-headers %p/Inputs/macho-invalid-fat 2>&1 | FileCheck -check-prefix INVALID-FAT %s INVALID-FAT: truncated or malformed fat file (fat_arch_64 structs would extend past the end of the file) @@ -408,4 +408,4 @@ RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-twolevelhi INVALID-TWOLEVELHINTS-OFFSET-HNINTS: macho-invalid-twolevelhints-offset-nhints': truncated or malformed object (offset field plus nhints times sizeof(struct twolevel_hint) field of LC_TWOLEVEL_HINTS command 0 extends past the end of the file) RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-fat_cputype 2>&1 | FileCheck -check-prefix INVALID-FAT-CPUTYPE %s -INVALID-FAT-CPUTYPE: macho-invalid-fat_cputype truncated or malformed object (universal header architecture: 0's cputype does not match object file's mach header) +INVALID-FAT-CPUTYPE: macho-invalid-fat_cputype': truncated or malformed object (universal header architecture: 0's cputype does not match object file's mach header) diff --git a/llvm/test/tools/llvm-objdump/malformed-archives.test b/llvm/test/tools/llvm-objdump/malformed-archives.test index b8ba48d..b241a6b 100644 --- a/llvm/test/tools/llvm-objdump/malformed-archives.test +++ b/llvm/test/tools/llvm-objdump/malformed-archives.test @@ -47,35 +47,35 @@ # RUN: %p/Inputs/libbogus8.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus8 %s -# bogus8: libbogus8.a(???) truncated or malformed archive (long name length: 1234 extends past the end of the member or archive for archive member header at offset 86) +# bogus8: libbogus8.a(???): truncated or malformed archive (long name length: 1234 extends past the end of the member or archive for archive member header at offset 86) # RUN: not llvm-objdump -s %p/Inputs/libbogus9.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus9 %s -# bogus9: libbogus9.a(???) truncated or malformed archive (long name offset characters after the '/' are not all decimal numbers: '&a25*' for archive member header at offset 94) +# bogus9: libbogus9.a(???): truncated or malformed archive (long name offset characters after the '/' are not all decimal numbers: '&a25*' for archive member header at offset 94) # RUN: not llvm-objdump -s %p/Inputs/libbogus10.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus10 %s -# bogus10: libbogus10.a(???) truncated or malformed archive (long name offset 507 past the end of the string table for archive member header at offset 94) +# bogus10: libbogus10.a(???): truncated or malformed archive (long name offset 507 past the end of the string table for archive member header at offset 94) # RUN: not llvm-objdump -macho -archive-headers \ # RUN: %p/Inputs/libbogus11.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus11 %s -# bogus11: libbogus11.a(hello.c) truncated or malformed archive (characters in UID field in archive header are not all decimal numbers: '~97&' for the archive member header at offset 8) +# bogus11: libbogus11.a(hello.c): truncated or malformed archive (characters in UID field in archive header are not all decimal numbers: '~97&' for the archive member header at offset 8) # RUN: not llvm-objdump -macho -archive-headers \ # RUN: %p/Inputs/libbogus12.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus12 %s -# bogus12: libbogus12.a(hello.c) truncated or malformed archive (characters in GID field in archive header are not all decimal numbers: '#55!' for the archive member header at offset 8) +# bogus12: libbogus12.a(hello.c): truncated or malformed archive (characters in GID field in archive header are not all decimal numbers: '#55!' for the archive member header at offset 8) # RUN: not llvm-objdump -macho -archive-headers \ # RUN: %p/Inputs/libbogus13.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus13 %s -# bogus13: libbogus13.a(hello.c) truncated or malformed archive (characters in AccessMode field in archive header are not all decimal numbers: 'Feed' for the archive member header at offset 8) +# bogus13: libbogus13.a(hello.c): truncated or malformed archive (characters in AccessMode field in archive header are not all decimal numbers: 'Feed' for the archive member header at offset 8) # RUN: llvm-objdump -macho -archive-headers %p/Inputs/libbogus14.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus14 %s diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 43a9a7a..f8bef75 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -319,14 +319,14 @@ LLVM_ATTRIBUTE_NORETURN void llvm::report_error(StringRef ArchiveName, if (ArchiveName != "") errs() << ArchiveName << "(" << FileName << ")"; else - errs() << FileName; + errs() << "'" << FileName << "'"; if (!ArchitectureName.empty()) errs() << " (for architecture " << ArchitectureName << ")"; std::string Buf; raw_string_ostream OS(Buf); logAllUnhandledErrors(std::move(E), OS, ""); OS.flush(); - errs() << " " << Buf; + errs() << ": " << Buf; exit(1); } -- 2.7.4