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

Unified Diff: tools/llvm-nm/llvm-nm.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/llvm-dis/llvm-dis.cpp ('k') | tools/pnacl-abicheck/pnacl-abicheck.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/llvm-nm/llvm-nm.cpp
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index 2c346e51a1fef59b3f69ae2ef8c35027f1628db4..b2af842df27763431571dcdfb880076c38214b89 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -166,6 +166,12 @@ cl::opt<NaClFileFormat> InputFileFormat(
clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
clEnumValEnd),
cl::init(LLVMFormat));
+
+static cl::opt<bool>
+VerboseErrors(
+ "verbose-parse-errors",
+ cl::desc("Print out more descriptive PNaCl bitcode parse errors"),
+ cl::init(false));
// @LOCALMOD-END
}
@@ -1011,14 +1017,17 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
// Support parsing PNaCl bitcode files
/* TODO(jfb) This is currently broken: the code base now requires an Object.
if (InputFileFormat == PNaClFormat) {
- std::string ErrorMessage;
- Module *Result = NaClParseBitcodeFile(BufferOrErr.get().release(), Context,
- &ErrorMessage);
+ std::string VerboseBuffer;
+ raw_string_ostream VerboseStrm(VerboseBuffer);
+ raw_ostream *Verbose = VerboseErrors ? &VerboseStrm : nullptr;
+ ErrorOr<Module *> Result =
+ NaClParseBitcodeFile(BufferOrErr.get().release(), Verbose,
+ Context);
if (Result) {
- DumpSymbolNamesFromModule(Result);
+ DumpSymbolNamesFromModule(Result.get());
delete Result;
} else {
- error(ErrorMessage, Filename);
+ error(VerboseStrm.str() + Result.message()), Filename);
return;
}
}
« no previous file with comments | « tools/llvm-dis/llvm-dis.cpp ('k') | tools/pnacl-abicheck/pnacl-abicheck.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698