summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authorCedric Delamarre <cdl@esi-group.com>2020-11-10 12:05:11 +0100
committerCedric Delamarre <cdl@esi-group.com>2020-11-10 15:58:10 +0100
commit032909d24d16f00eab44148184aefdab8a987acb (patch)
tree9b99e5eb0016227b6bccc3b1b048c1cca47e6b67 /scilab
parentb0ddb28dcb5000ddfbb4d992a9e982caf5a7d197 (diff)
downloadscilab-032909d24d16f00eab44148184aefdab8a987acb.zip
scilab-032909d24d16f00eab44148184aefdab8a987acb.tar.gz
Breakpoints condition
* mute bp condition execution * add bo condition error * bp stop on condition changes: - Dont stop if the bp condition is valid and the result is false - stop if the bp condition is valid and the result true - stop if the bp condition exection return an error Change-Id: Ia61868ad7c7978f31d5aa91ab3ac66d1340e052d
Diffstat (limited to 'scilab')
-rw-r--r--scilab/modules/ast/includes/ast/breakpoint.hxx26
-rw-r--r--scilab/modules/ast/includes/exps/exp.hxx9
-rw-r--r--scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp34
3 files changed, 56 insertions, 13 deletions
diff --git a/scilab/modules/ast/includes/ast/breakpoint.hxx b/scilab/modules/ast/includes/ast/breakpoint.hxx
index 1628ee4..89247fa 100644
--- a/scilab/modules/ast/includes/ast/breakpoint.hxx
+++ b/scilab/modules/ast/includes/ast/breakpoint.hxx
@@ -35,6 +35,7 @@ struct Breakpoint
35 _iFileLine(0), 35 _iFileLine(0),
36 _iFirstColumn(0), 36 _iFirstColumn(0),
37 _condition(""), 37 _condition(""),
38 _conditionError(""),
38 _conditionExp(NULL), 39 _conditionExp(NULL),
39 _enable(true) {} 40 _enable(true) {}
40 ~Breakpoint() 41 ~Breakpoint()
@@ -100,6 +101,16 @@ struct Breakpoint
100 return _pFileName.empty() == false && _iFileLine >= 0; 101 return _pFileName.empty() == false && _iFileLine >= 0;
101 } 102 }
102 103
104 bool hasCondition() const
105 {
106 return _condition.empty() == false;
107 }
108
109 bool hasConditionError() const
110 {
111 return _conditionError.empty() == false;
112 }
113
103 void setEnable() 114 void setEnable()
104 { 115 {
105 _enable = true; 116 _enable = true;
@@ -113,14 +124,26 @@ struct Breakpoint
113 return _enable; 124 return _enable;
114 } 125 }
115 126
127 const std::string& getConditionError(void)
128 {
129 return _conditionError;
130 }
131
132 void setConditionError(const std::string& error)
133 {
134 _conditionError = error;
135 }
136
116 char* setCondition(const std::string& condition) 137 char* setCondition(const std::string& condition)
117 { 138 {
139 _condition = condition;
118 char* error = parseCommand(condition.data(), (void**)(&_conditionExp)); 140 char* error = parseCommand(condition.data(), (void**)(&_conditionExp));
119 if(error) 141 if(error)
120 { 142 {
143 _conditionError = error;
121 return error; 144 return error;
122 } 145 }
123 _condition = condition; 146 _conditionExp->mute();
124 return nullptr; 147 return nullptr;
125 } 148 }
126 149
@@ -141,6 +164,7 @@ private:
141 std::string _pFileName; 164 std::string _pFileName;
142 int _iFileLine; 165 int _iFileLine;
143 std::string _condition; 166 std::string _condition;
167 std::string _conditionError;
144 ast::Exp* _conditionExp; 168 ast::Exp* _conditionExp;
145 bool _enable; 169 bool _enable;
146}; 170};
diff --git a/scilab/modules/ast/includes/exps/exp.hxx b/scilab/modules/ast/includes/exps/exp.hxx
index d96e41c..0048098 100644
--- a/scilab/modules/ast/includes/exps/exp.hxx
+++ b/scilab/modules/ast/includes/exps/exp.hxx
@@ -102,9 +102,16 @@ public:
102 } 102 }
103 103
104public: 104public:
105 /** \brief Return if an expression should be displayed or not. */ 105 /** \brief Set recursively if an expression should be displayed or not. */
106 inline void mute(void) 106 inline void mute(void)
107 { 107 {
108 for (auto& e : _exps)
109 {
110 if(e)
111 {
112 e->mute();
113 }
114 }
108 _verbose = false; 115 _verbose = false;
109 } 116 }
110 117
diff --git a/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp b/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp
index 1f0ce45..38438b1 100644
--- a/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp
+++ b/scilab/modules/ast/src/cpp/ast/debuggervisitor.cpp
@@ -179,28 +179,40 @@ void DebuggerVisitor::visit(const SeqExp &e)
179 pCtx->scope_begin(); 179 pCtx->scope_begin();
180 bp->getConditionExp()->accept(execCond); 180 bp->getConditionExp()->accept(execCond);
181 types::InternalType* pIT = pCtx->getCurrentLevel(symbol::Symbol(L"ans")); 181 types::InternalType* pIT = pCtx->getCurrentLevel(symbol::Symbol(L"ans"));
182 if (pIT == NULL || 182 if (pIT == NULL)
183 pIT->isBool() == false ||
184 ((types::Bool*)pIT)->isScalar() == false ||
185 ((types::Bool*)pIT)->get(0) == 0)
186 { 183 {
184 // no result ie: assignation
185 char pcError[256];
186 sprintf(pcError, _("Wrong breakpoint condition: A result expected.\n"));
187 bp->setConditionError(pcError);
188 }
189 else if(pIT->isTrue() == false)
190 {
191 // bool scalar false
187 pCtx->scope_end(); 192 pCtx->scope_end();
188 //not a boolean, not scalar or false
189 stopExecution = false; 193 stopExecution = false;
190 continue; 194 continue;
191 } 195 }
192 196
193 pCtx->scope_end(); 197 // condition is invalid or true
194 //ok condition is valid and true
195 } 198 }
196 catch (ast::ScilabException &/*e*/) 199 catch (ast::ScilabException& e)
197 { 200 {
198 pCtx->scope_end();
199 stopExecution = false;
200 //not work ! 201 //not work !
201 //invalid breakpoint 202 //invalid breakpoint
202 continue; 203 if(ConfigVariable::isError())
204 {
205 bp->setConditionError(scilab::UTF8::toUTF8(ConfigVariable::getLastErrorMessage()));
206 ConfigVariable::clearLastError();
207 ConfigVariable::resetError();
208 }
209 else
210 {
211 bp->setConditionError(scilab::UTF8::toUTF8(e.GetErrorMessage()));
212 }
203 } 213 }
214
215 pCtx->scope_end();
204 } 216 }
205 217
206 //we have a breakpoint ! 218 //we have a breakpoint !