Skip to content

Commit

Permalink
llvm-objdump: Make some error messages more consistent
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bogner committed Oct 26, 2016
1 parent ebeeab8 commit 31d8b7d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions llvm/test/Object/macho-invalid.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
12 changes: 6 additions & 6 deletions llvm/test/tools/llvm-objdump/malformed-archives.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 31d8b7d

Please sign in to comment.