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

Unified Diff: tools/pnacl-llc/pnacl-llc.cpp

Issue 23753003: Report fatal translator errors to the browser (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: split errors from streamable readBytes and Header ReadPrefix Created 7 years, 3 months 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/pnacl-llc/SRPCStreamer.cpp ('k') | tools/pnacl-llc/srpc_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/pnacl-llc/pnacl-llc.cpp
diff --git a/tools/pnacl-llc/pnacl-llc.cpp b/tools/pnacl-llc/pnacl-llc.cpp
index 31d546ab3e52cbecb600cba64c4fce09a4e7df81..cac4fa83a46d569df3a1996fd5551c32cb88992f 100644
--- a/tools/pnacl-llc/pnacl-llc.cpp
+++ b/tools/pnacl-llc/pnacl-llc.cpp
@@ -28,6 +28,7 @@
#include "llvm/PassManager.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/ManagedStatic.h"
@@ -52,6 +53,7 @@ using namespace llvm;
int srpc_main(int argc, char **argv);
int getObjectFileFD();
DataStreamer *getNaClBitcodeStreamer();
+fatal_error_handler_t getSRPCErrorHandler();
#endif
cl::opt<NaClFileFormat>
@@ -215,6 +217,10 @@ int llc_main(int argc, char **argv) {
LLVMContext &Context = getGlobalContext();
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+#if defined(__native_client__)
+ install_fatal_error_handler(getSRPCErrorHandler(), NULL);
+#endif
+
// Initialize targets first, so that --version shows registered targets.
InitializeAllTargets();
InitializeAllTargetMCs();
@@ -252,11 +258,15 @@ int llc_main(int argc, char **argv) {
static void CheckABIVerifyErrors(PNaClABIErrorReporter &Reporter,
const Twine &Name) {
if (PNaClABIVerify && Reporter.getErrorCount() > 0) {
- errs() << (PNaClABIVerifyFatalErrors ? "ERROR: " : "WARNING: ");
- errs() << Name << " is not valid PNaCl bitcode:\n";
- Reporter.printErrors(errs());
- if (PNaClABIVerifyFatalErrors)
- exit(1);
+ std::string errors;
+ raw_string_ostream os(errors);
+ os << (PNaClABIVerifyFatalErrors ? "ERROR: " : "WARNING: ");
+ os << Name << " is not valid PNaCl bitcode:\n";
+ Reporter.printErrors(os);
+ if (PNaClABIVerifyFatalErrors) {
+ report_fatal_error(os.str());
+ }
+ errs() << os.str();
}
Reporter.reset();
}
@@ -273,11 +283,12 @@ static int compileModule(StringRef ProgramName, LLVMContext &Context) {
#if defined(__native_client__)
if (LazyBitcode) {
std::string StrError;
+ std::string DisplayFilename("<PNaCl-translated pexe>");
M.reset(getNaClStreamedBitcodeModule(
- std::string("<SRPC stream>"),
+ DisplayFilename,
getNaClBitcodeStreamer(), Context, &StrError));
if (!StrError.empty())
- Err = SMDiagnostic(InputFilename, SourceMgr::DK_Error, StrError);
+ Err = SMDiagnostic(DisplayFilename, SourceMgr::DK_Error, StrError);
} else {
llvm_unreachable("native client SRPC only supports streaming");
}
@@ -287,8 +298,13 @@ static int compileModule(StringRef ProgramName, LLVMContext &Context) {
mod = M.get();
if (mod == 0) {
+#if defined(__native_client__)
+ report_fatal_error(Err.getMessage());
+#else
+ // Err.print is prettier, so use it for the non-sandboxed translator.
Err.print(ProgramName.data(), errs());
return 1;
+#endif
}
if (PNaClABIVerify) {
« no previous file with comments | « tools/pnacl-llc/SRPCStreamer.cpp ('k') | tools/pnacl-llc/srpc_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698