Fix ErrorHandler
Change-Id: Ia8d5871d07f774278bef756a5ee836dd9716f16f
diff --git a/bcc.cpp b/bcc.cpp
index c092f86..74659ba 100644
--- a/bcc.cpp
+++ b/bcc.cpp
@@ -371,11 +371,12 @@
}
static void LLVMErrorHandler(void *UserData, const std::string &Message) {
- // std::string* Error = static_cast<std::string*>(UserData);
- // Error->assign(Message);
- // return;
- fprintf(stderr, "%s\n", Message.c_str());
- exit(1);
+ std::string* Error = static_cast<std::string*>(UserData);
+ Error->assign(Message);
+ LOGE(Message.c_str());
+ return;
+ //fprintf(stderr, "%s\n", Message.c_str());
+ //exit(1);
}
static const llvm::StringRef PragmaMetadataName;
@@ -2604,6 +2605,7 @@
const llvm::NamedMDNode* ExportVarMetadata;
const llvm::NamedMDNode* ExportFuncMetadata;
+ //LOGE("COMPILE");
if(mModule == NULL) /* No module was loaded */
return 0;
@@ -2664,6 +2666,7 @@
goto on_bcc_compile_error;
}
+ //LOGE("Before CODEGEN");
/*
* Run the pass (the code emitter) on every non-declaration function
* in the module
@@ -2671,12 +2674,21 @@
CodeGenPasses->doInitialization();
for(llvm::Module::iterator I = mModule->begin();
I != mModule->end();
- I++)
- if(!I->isDeclaration())
+ I++) {
+ //LOGE("CODEGEN 1.");
+ if(!I->isDeclaration()) {
+ //LOGE("CODEGEN 2.");
CodeGenPasses->run(*I);
+ //LOGE("CODEGEN 3.");
+ }
+ }
+
+ //LOGE("Before Finalization");
CodeGenPasses->doFinalization();
+ //LOGE("After CODEGEN");
+
/* Copy the global address mapping from code emitter and remapping */
ExportVarMetadata = mModule->getNamedMetadata(ExportVarMetadataName);
if(ExportVarMetadata) {
@@ -2763,6 +2775,7 @@
}
on_bcc_compile_error:
+ //LOGE("on_bcc_compiler_error");
if (CodeGenPasses) {
delete CodeGenPasses;
} else if (TD) {
@@ -2771,7 +2784,12 @@
if (TM)
delete TM;
- return hasError();
+ if (mError.empty()) {
+ return false;
+ }
+
+ // LOGE(getErrorMessage());
+ return true;
}
/* interface for bccGetScriptInfoLog() */