From: Eric Beckmann Date: Tue, 13 Jun 2017 18:17:36 +0000 (+0000) Subject: Improve error messages in order to help with fixing a big-endian bug. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9d223b2fc119d3d4bc912a710dbf9ff8bcba440;p=llvm Improve error messages in order to help with fixing a big-endian bug. Summary: Added output to stderr so that we can actually see what is happening when the test fails on big endian. Reviewers: zturner Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D34155 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305314 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Object/WindowsResource.h b/include/llvm/Object/WindowsResource.h index 33f396cc6f2..4839013c822 100644 --- a/include/llvm/Object/WindowsResource.h +++ b/include/llvm/Object/WindowsResource.h @@ -118,7 +118,7 @@ public: class TreeNode; WindowsResourceParser(); Error parse(WindowsResource *WR); - void printTree() const; + void printTree(raw_ostream &OS) const; const TreeNode &getTree() const { return Root; } const ArrayRef> getData() const { return Data; } const ArrayRef> getStringTable() const { diff --git a/lib/Object/WindowsResource.cpp b/lib/Object/WindowsResource.cpp index 3d689fe1e9a..b1452e8d5e9 100644 --- a/lib/Object/WindowsResource.cpp +++ b/lib/Object/WindowsResource.cpp @@ -70,7 +70,7 @@ ResourceEntryRef::ResourceEntryRef(BinaryStreamRef Ref, const WindowsResource *Owner, Error &Err) : Reader(Ref), OwningRes(Owner) { if (loadNext()) - Err = make_error("Could not read first entry.", + Err = make_error("Could not read first entry.\n", object_error::unexpected_eof); } @@ -156,8 +156,8 @@ Error WindowsResourceParser::parse(WindowsResource *WR) { return Error::success(); } -void WindowsResourceParser::printTree() const { - ScopedPrinter Writer(outs()); +void WindowsResourceParser::printTree(raw_ostream &OS) const { + ScopedPrinter Writer(OS); Root.print(Writer, "Resource Tree"); } diff --git a/test/tools/llvm-cvtres/combined.test b/test/tools/llvm-cvtres/combined.test index bb3b4dbc736..084a0ea0cde 100644 --- a/test/tools/llvm-cvtres/combined.test +++ b/test/tools/llvm-cvtres/combined.test @@ -8,7 +8,7 @@ // > cvtres /machine:X86 /readonly /nologo /out:combined.obj.coff \ // languages.res test_resource.res -RUN: llvm-cvtres /out:%t %p/Inputs/languages.res %p/Inputs/test_resource.res +RUN: llvm-cvtres /verbose /out:%t %p/Inputs/languages.res %p/Inputs/test_resource.res RUN: llvm-readobj -coff-resources -section-data %t | FileCheck %s CHECK: Resources [ diff --git a/test/tools/llvm-cvtres/object.test b/test/tools/llvm-cvtres/object.test index 12373e0ac7f..95522b17bd0 100644 --- a/test/tools/llvm-cvtres/object.test +++ b/test/tools/llvm-cvtres/object.test @@ -7,7 +7,7 @@ // > cvtres /machine:X86 /readonly /nologo /out:test_resource.obj.coff \ // test_resource.res -RUN: llvm-cvtres /out:%t %p/Inputs/test_resource.res +RUN: llvm-cvtres /verbose /out:%t %p/Inputs/test_resource.res RUN: llvm-readobj -coff-resources -section-data %t | FileCheck %s CHECK: Resources [ diff --git a/tools/llvm-cvtres/llvm-cvtres.cpp b/tools/llvm-cvtres/llvm-cvtres.cpp index eaba02c16f3..1e463399a59 100644 --- a/tools/llvm-cvtres/llvm-cvtres.cpp +++ b/tools/llvm-cvtres/llvm-cvtres.cpp @@ -191,11 +191,23 @@ int main(int argc_, const char *argv_[]) { error(Parser.parse(RF)); } - if (Verbose) - Parser.printTree(); + if (Verbose) { + Parser.printTree(outs()); + Parser.printTree(errs()); + } error( llvm::object::writeWindowsResourceCOFF(OutputFile, MachineType, Parser)); + if (Verbose) { + Expected> BinaryOrErr = + object::createBinary(OutputFile); + if (!BinaryOrErr) + reportError(OutputFile, errorToErrorCode(BinaryOrErr.takeError())); + Binary &Binary = *BinaryOrErr.get().getBinary(); + ScopedPrinter W(errs()); + W.printBinaryBlock("Output File Raw Data", Binary.getData()); + } + return 0; }