From: Cedric Delamarre Date: Fri, 26 Mar 2021 12:57:41 +0000 (+0100) Subject: debugger: error in try/catch and errcatch fixed X-Git-Tag: 6.1.1~106 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=73dcb7c691efe1e417c7dd486d00c3a96f5d410a debugger: error in try/catch and errcatch fixed * the debugger must not stop when there is an error with exec/execstr(..., errcatch) and in a try catch exp. execstr("cos(""e"")", "errcatch") try, 1+list(); catch, disp("error catched !"); end Change-Id: I8c447a26bc0bd89e51562cf24e3c2c9e93eabff5 --- diff --git a/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp b/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp index ff1d6ec..762d9b6 100644 --- a/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp +++ b/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp @@ -381,6 +381,13 @@ void DebuggerVisitor::visit(const SeqExp &e) } catch (const InternalError& ie) { + // dont manage an error with the debugger + // in cases of try catch and errcatch + if(ConfigVariable::isSilentError()) + { + throw ie; + } + ConfigVariable::fillWhereError(ie.GetErrorLocation().first_line); const std::vector& lWhereAmI = ConfigVariable::getWhere(); diff --git a/scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp b/scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp index 7d16abf..3eda4de 100644 --- a/scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp +++ b/scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp @@ -76,6 +76,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ ast::Exp* pExp = NULL; int iID = 0; types::Macro* pMacro = NULL; + bool bSilentError = ConfigVariable::isSilentError(); Parser parser; wchar_t* pwstFile = NULL; @@ -293,6 +294,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ pSeqExp->setExecFrom(ast::SeqExp::EXEC); pSeqExp->setReturnable(); std::unique_ptr exec(ConfigVariable::getDefaultVisitor()); + ConfigVariable::setSilentError(bErrCatch); try { @@ -305,6 +307,8 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ } catch (const ast::RecursionException& /* re */) { + ConfigVariable::setSilentError(bSilentError); + //close opened scope during try while (pCtx->getScopeLevel() > scope) { @@ -328,6 +332,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ { closeFile(file, iID, wstFile, pExp); ConfigVariable::setPromptMode(oldVal); + ConfigVariable::setSilentError(bSilentError); throw ia; } catch (const ast::InternalError& ie) @@ -342,6 +347,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ closeFile(file, iID, wstFile, pExp); ConfigVariable::setPromptMode(oldVal); ConfigVariable::setExecutedFile(L""); + ConfigVariable::setSilentError(bSilentError); throw ie; } @@ -351,6 +357,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ //restore previous prompt mode ConfigVariable::setPromptMode(oldVal); + ConfigVariable::setSilentError(bSilentError); if (bErrCatch) { out.push_back(new types::Double(iErr)); diff --git a/scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp b/scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp index f7d94c8..6d422ca 100644 --- a/scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp +++ b/scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp @@ -48,6 +48,7 @@ types::Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, wchar_t* pstMsg = NULL; ast::Exp* pExp = NULL; wchar_t *pstCommand = NULL; + bool bSilentError = ConfigVariable::isSilentError(); Parser parser; if (in.size() < 1 || in.size() > 3) @@ -206,6 +207,7 @@ types::Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, ast::SeqExp* pSeqExp = pExp->getAs(); std::unique_ptr run(ConfigVariable::getDefaultVisitor()); + ConfigVariable::setSilentError(bErrCatch); try { symbol::Context* pCtx = symbol::Context::getInstance(); @@ -217,6 +219,8 @@ types::Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, } catch (const ast::RecursionException& /* re */) { + ConfigVariable::setSilentError(bSilentError); + //close opened scope during try while (pCtx->getScopeLevel() > scope) { @@ -243,6 +247,7 @@ types::Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, delete pExp; ConfigVariable::macroFirstLine_end(); ConfigVariable::setPromptMode(iPromptMode); + ConfigVariable::setSilentError(bSilentError); throw ie; } @@ -266,6 +271,7 @@ types::Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, ConfigVariable::macroFirstLine_end(); ConfigVariable::setPromptMode(iPromptMode); + ConfigVariable::setSilentError(bSilentError); delete pExp; return types::Function::OK;