summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authorCedric Delamarre <cedric.delamarre@esi-group.com>2021-02-22 13:33:53 +0100
committerAntoine ELIAS <antoine.elias@esi-group.com>2021-02-22 15:42:40 +0100
commita402c68895b9ef9e42494547a6f6047ab4c5ed9c (patch)
treece2683c85979a477335028c9465e38658817663c /scilab
parent9ef0a23acd9aeda1bb1e4a7e810022edfbbb2702 (diff)
downloadscilab-a402c68895b9ef9e42494547a6f6047ab4c5ed9c.zip
scilab-a402c68895b9ef9e42494547a6f6047ab4c5ed9c.tar.gz
breakpoint add, update, remove method added
Change-Id: Id93e04017304c380afa0ad4d3a6c910880340b97
Diffstat (limited to 'scilab')
-rw-r--r--scilab/modules/ast/includes/ast/debugmanager.hxx5
-rw-r--r--scilab/modules/ast/src/cpp/ast/debugmanager.cpp79
2 files changed, 62 insertions, 22 deletions
diff --git a/scilab/modules/ast/includes/ast/debugmanager.hxx b/scilab/modules/ast/includes/ast/debugmanager.hxx
index ebef8aa..d2b5300 100644
--- a/scilab/modules/ast/includes/ast/debugmanager.hxx
+++ b/scilab/modules/ast/includes/ast/debugmanager.hxx
@@ -159,7 +159,10 @@ public:
159 void errorInScript(const std::wstring funcname, const ast::Exp* pExp); 159 void errorInScript(const std::wstring funcname, const ast::Exp* pExp);
160 160
161 //breakpoints functions 161 //breakpoints functions
162 void addBreakPoint(Breakpoint* bp); 162 bool addBreakPoint(Breakpoint* bp);
163 bool updateBreakPoint(Breakpoint* bp);
164 bool removeBreakPoint(Breakpoint* bp);
165 Breakpoints::iterator findBreakPoint(Breakpoint* bp);
163 void removeBreakPoint(int _iBreakPoint); 166 void removeBreakPoint(int _iBreakPoint);
164 void setAllBreakPoints(Breakpoints& _bps); 167 void setAllBreakPoints(Breakpoints& _bps);
165 void removeAllBreakPoints(); 168 void removeAllBreakPoints();
diff --git a/scilab/modules/ast/src/cpp/ast/debugmanager.cpp b/scilab/modules/ast/src/cpp/ast/debugmanager.cpp
index 11d1f0d..ef5c55c 100644
--- a/scilab/modules/ast/src/cpp/ast/debugmanager.cpp
+++ b/scilab/modules/ast/src/cpp/ast/debugmanager.cpp
@@ -172,27 +172,6 @@ void DebuggerManager::sendUpdate() const
172 } 172 }
173} 173}
174 174
175void DebuggerManager::addBreakPoint(Breakpoint* bp)
176{
177 //check if breakpoint does not exist
178 for (const auto b : breakpoints)
179 {
180 bool isMacro = b->getFunctioName() == bp->getFunctioName() &&
181 b->getMacroLine() != bp->getMacroLine();
182 bool isFile = b->getFileName() == bp->getFileName() &&
183 b->getFileLine() != bp->getFileLine();
184 bool equalCondition = b->getCondition() != bp->getCondition();
185 if ((isMacro || isFile) && equalCondition)
186 {
187 //same breakpoint, cancel add
188 return;
189 }
190 }
191
192 breakpoints.push_back(bp);
193 sendUpdate();
194}
195
196void DebuggerManager::setAllBreakPoints(Breakpoints& _bps) 175void DebuggerManager::setAllBreakPoints(Breakpoints& _bps)
197{ 176{
198 // remove existing breakpoints 177 // remove existing breakpoints
@@ -207,6 +186,64 @@ void DebuggerManager::setAllBreakPoints(Breakpoints& _bps)
207 sendUpdate(); 186 sendUpdate();
208} 187}
209 188
189Breakpoints::iterator DebuggerManager::findBreakPoint(Breakpoint* bp)
190{
191 Breakpoints::iterator found = std::find_if(breakpoints.begin(), breakpoints.end(),
192 [&](Breakpoint* b) {
193 bool isMacro = b->getFunctioName() != "" &&
194 b->getFunctioName() == bp->getFunctioName() &&
195 b->getMacroLine() == bp->getMacroLine();
196
197 bool isFile = b->getFileName() != "" &&
198 b->getFileName() == bp->getFileName() &&
199 b->getFileLine() == bp->getFileLine();
200
201 return (isMacro || isFile);
202 });
203
204 return found;
205}
206
207bool DebuggerManager::addBreakPoint(Breakpoint* bp)
208{
209 //check if breakpoint does not exist
210 Breakpoints::iterator iter = findBreakPoint(bp);
211 if(iter == breakpoints.end())
212 {
213 breakpoints.push_back(bp);
214 sendUpdate();
215 return true;
216 }
217
218 return false;
219}
220
221bool DebuggerManager::updateBreakPoint(Breakpoint* bp)
222{
223 Breakpoints::iterator iter = findBreakPoint(bp);
224 if(iter != breakpoints.end())
225 {
226 std::swap(*iter, bp);
227 delete bp;
228 return true;
229 }
230
231 return false;
232}
233
234bool DebuggerManager::removeBreakPoint(Breakpoint* bp)
235{
236 Breakpoints::iterator iter = findBreakPoint(bp);
237 if(iter != breakpoints.end())
238 {
239 delete *iter;
240 breakpoints.erase(iter);
241 return true;
242 }
243
244 return false;
245}
246
210void DebuggerManager::removeBreakPoint(int _iBreakPoint) 247void DebuggerManager::removeBreakPoint(int _iBreakPoint)
211{ 248{
212 if (_iBreakPoint >= 0 && _iBreakPoint <= (int)breakpoints.size()) 249 if (_iBreakPoint >= 0 && _iBreakPoint <= (int)breakpoints.size())