From e2947531280503a4e73e8d94a6161f68bea857a7 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 7 Jul 2004 21:01:38 +0000 Subject: [PATCH] Fix for bug 391. Improve exeception handling around bcreader invocations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14674 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/ExecutionEngine.cpp | 2 ++ lib/ExecutionEngine/JIT/JIT.cpp | 3 +++ lib/VMCore/Pass.cpp | 10 +++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index c9fd5776546..4ece8b9c84b 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -137,6 +137,8 @@ ExecutionEngine *ExecutionEngine::create(ModuleProvider *MP, } catch (...) { std::cerr << "Error creating the interpreter!\n"; } + } catch (std::string& errmsg) { + std::cerr << "Error reading the bytecode file: " << errmsg << "\n"; } catch (...) { std::cerr << "Error reading the bytecode file!\n"; } diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 5340a19e3ed..02577df3c42 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -117,6 +117,9 @@ void *JIT::getPointerToFunction(Function *F) { // Make sure we read in the function if it exists in this Module try { MP->materializeFunction(F); + } catch ( std::string& errmsg ) { + std::cerr << "Error parsing bytecode file: " << errmsg << "\n"; + abort(); } catch (...) { std::cerr << "Error parsing bytecode file!\n"; abort(); diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 88813297ec6..b37b4601da9 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -92,7 +92,15 @@ FunctionPassManager::~FunctionPassManager() { delete PM; } void FunctionPassManager::add(FunctionPass *P) { PM->add(P); } void FunctionPassManager::add(ImmutablePass *IP) { PM->add(IP); } bool FunctionPassManager::run(Function &F) { - MP->materializeFunction(&F); + try { + MP->materializeFunction(&F); + } catch (std::string& errstr) { + std::cerr << "Error reading bytecode file: " << errstr << "\n"; + abort(); + } catch (...) { + std::cerr << "Error reading bytecode file:\n"; + abort(); + } return PM->run(F); }