Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: tools/pnacl-thaw/pnacl-thaw.cpp

Issue 770853002: Fix error reporting in the PNaCl bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix typo. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/pnacl-llc/pnacl-llc.cpp ('k') | unittests/Bitcode/CMakeLists.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright 2013 The Native Client Authors. All rights reserved. 1 /* Copyright 2013 The Native Client Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can 2 * Use of this source code is governed by a BSD-style license that can
3 * be found in the LICENSE file. 3 * be found in the LICENSE file.
4 */ 4 */
5 5
6 //===-- pnacl-thaw.cpp - The low-level NaCl bitcode thawer ----------------===// 6 //===-- pnacl-thaw.cpp - The low-level NaCl bitcode thawer ----------------===//
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // Converts NaCl wire format back to LLVM bitcode. 10 // Converts NaCl wire format back to LLVM bitcode.
(...skipping 15 matching lines...) Expand all
26 26
27 using namespace llvm; 27 using namespace llvm;
28 28
29 static cl::opt<std::string> 29 static cl::opt<std::string>
30 OutputFilename("o", cl::desc("Specify thawed pexe filename"), 30 OutputFilename("o", cl::desc("Specify thawed pexe filename"),
31 cl::value_desc("filename"), cl::init("-")); 31 cl::value_desc("filename"), cl::init("-"));
32 32
33 static cl::opt<std::string> 33 static cl::opt<std::string>
34 InputFilename(cl::Positional, cl::desc("<frozen file>"), cl::init("-")); 34 InputFilename(cl::Positional, cl::desc("<frozen file>"), cl::init("-"));
35 35
36 static cl::opt<bool>
37 VerboseErrors(
38 "verbose-parse-errors",
39 cl::desc("Print out more descriptive PNaCl bitcode parse errors"),
40 cl::init(false));
41
36 static void WriteOutputFile(const Module *M) { 42 static void WriteOutputFile(const Module *M) {
37 43
38 std::string ErrorInfo; 44 std::string ErrorInfo;
39 std::unique_ptr<tool_output_file> Out( 45 std::unique_ptr<tool_output_file> Out(
40 new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None)); 46 new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None));
41 if (!ErrorInfo.empty()) { 47 if (!ErrorInfo.empty()) {
42 errs() << ErrorInfo << '\n'; 48 errs() << ErrorInfo << '\n';
43 exit(1); 49 exit(1);
44 } 50 }
45 51
(...skipping 20 matching lines...) Expand all
66 // Use the bitcode streaming interface 72 // Use the bitcode streaming interface
67 DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage); 73 DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage);
68 std::unique_ptr<StreamingMemoryObject> Buffer( 74 std::unique_ptr<StreamingMemoryObject> Buffer(
69 new StreamingMemoryObjectImpl(streamer)); 75 new StreamingMemoryObjectImpl(streamer));
70 if (streamer) { 76 if (streamer) {
71 std::string DisplayFilename; 77 std::string DisplayFilename;
72 if (InputFilename == "-") 78 if (InputFilename == "-")
73 DisplayFilename = "<stdin>"; 79 DisplayFilename = "<stdin>";
74 else 80 else
75 DisplayFilename = InputFilename; 81 DisplayFilename = InputFilename;
82 raw_ostream *Verbose = VerboseErrors ? &errs() : nullptr;
76 M.reset(getNaClStreamedBitcodeModule(DisplayFilename, Buffer.release(), 83 M.reset(getNaClStreamedBitcodeModule(DisplayFilename, Buffer.release(),
77 Context, &ErrorMessage, 84 Context, Verbose,
85 &ErrorMessage,
78 /*AcceptSupportedOnly=*/false)); 86 /*AcceptSupportedOnly=*/false));
79 if (M.get()) 87 if (M.get())
80 if (std::error_code EC = M->materializeAllPermanently()) { 88 if (std::error_code EC = M->materializeAllPermanently()) {
81 ErrorMessage = EC.message(); 89 ErrorMessage = EC.message();
82 M.reset(); 90 M.reset();
83 } 91 }
84 } 92 }
85 93
86 if (!M.get()) { 94 if (!M.get()) {
87 errs() << argv[0] << ": "; 95 errs() << argv[0] << ": ";
88 if (ErrorMessage.size()) 96 if (ErrorMessage.size())
89 errs() << ErrorMessage << "\n"; 97 errs() << ErrorMessage << "\n";
90 else 98 else
91 errs() << "bitcode didn't read correctly.\n"; 99 errs() << "bitcode didn't read correctly.\n";
92 return 1; 100 return 1;
93 } 101 }
94 102
95 WriteOutputFile(M.get()); 103 WriteOutputFile(M.get());
96 return 0; 104 return 0;
97 } 105 }
OLDNEW
« no previous file with comments | « tools/pnacl-llc/pnacl-llc.cpp ('k') | unittests/Bitcode/CMakeLists.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698