Index: llvm/trunk/include/llvm/Object/WindowsResource.h =================================================================== --- llvm/trunk/include/llvm/Object/WindowsResource.h +++ llvm/trunk/include/llvm/Object/WindowsResource.h @@ -118,7 +118,7 @@ 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 { Index: llvm/trunk/lib/Object/WindowsResource.cpp =================================================================== --- llvm/trunk/lib/Object/WindowsResource.cpp +++ llvm/trunk/lib/Object/WindowsResource.cpp @@ -70,7 +70,7 @@ 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 @@ 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"); } Index: llvm/trunk/test/tools/llvm-cvtres/combined.test =================================================================== --- llvm/trunk/test/tools/llvm-cvtres/combined.test +++ llvm/trunk/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 [ Index: llvm/trunk/test/tools/llvm-cvtres/object.test =================================================================== --- llvm/trunk/test/tools/llvm-cvtres/object.test +++ llvm/trunk/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 [ Index: llvm/trunk/tools/llvm-cvtres/llvm-cvtres.cpp =================================================================== --- llvm/trunk/tools/llvm-cvtres/llvm-cvtres.cpp +++ llvm/trunk/tools/llvm-cvtres/llvm-cvtres.cpp @@ -191,11 +191,23 @@ 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; }