Skip to content

Commit 3cadb89

Browse files
committed
Лишняя остановка отладчиком на заголовке цикла Для Каждого
1 parent 18a53e9 commit 3cadb89

1 file changed

Lines changed: 41 additions & 18 deletions

File tree

src/ScriptEngine/Machine/MachineStopManager.cs

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ internal enum DebugState
2222

2323
internal class MachineStopManager
2424
{
25+
private struct StopPoint
26+
{
27+
public ExecutionFrame frame;
28+
public int line;
29+
}
30+
2531
private DebugState _currentState = DebugState.Running;
2632
private readonly IBreakpointManager _breakpoints;
2733
private readonly MachineInstance _machine;
2834
private readonly IThreadEventsListener _threadManager;
2935
private ExecutionFrame[] _stopFrames;
36+
37+
private StopPoint _lastStopPoint;
3038

3139
public MachineStopManager(MachineInstance runner, IThreadEventsListener threadManager, IBreakpointManager breakpoints)
3240
{
@@ -76,32 +84,47 @@ public bool ShouldStopAtThisLine(string module, ExecutionFrame currentFrame)
7684

7785
if (mustStop)
7886
{
79-
if (_currentState == DebugState.Running)
87+
// здесь мы уже останавливались?
88+
if (_lastStopPoint.frame != currentFrame || _lastStopPoint.line != currentFrame.LineNumber)
8089
{
81-
LastStopReason = MachineStopReason.Breakpoint;
90+
if (_currentState == DebugState.Running)
91+
{
92+
LastStopReason = MachineStopReason.Breakpoint;
8293

83-
// Проверим существование условия остановки
84-
var condition = Breakpoints.GetCondition(module, currentFrame.LineNumber);
94+
// Проверим существование условия остановки
95+
var condition = Breakpoints.GetCondition(module, currentFrame.LineNumber);
8596

86-
if (!string.IsNullOrEmpty(condition))
87-
{
88-
try
89-
{
90-
mustStop = _machine.EvaluateInFrame(condition, currentFrame).AsBoolean();
91-
}
92-
catch (Exception ex)
97+
if (!string.IsNullOrEmpty(condition))
9398
{
94-
// Остановим и сообщим, что остановка произошла не по условию, а в результате ошибки вычисления
95-
mustStop = true;
96-
LastStopReason = MachineStopReason.BreakpointConditionError;
97-
LastStopErrorMessage = $"Не удалось выполнить условие точки останова: {ex.Message}";
99+
try
100+
{
101+
mustStop = _machine.EvaluateInFrame(condition, currentFrame).AsBoolean();
102+
}
103+
catch (Exception ex)
104+
{
105+
// Остановим и сообщим, что остановка произошла не по условию, а в результате ошибки вычисления
106+
mustStop = true;
107+
LastStopReason = MachineStopReason.BreakpointConditionError;
108+
LastStopErrorMessage = $"Не удалось выполнить условие точки останова: {ex.Message}";
109+
}
98110
}
99111
}
112+
else
113+
{
114+
LastStopReason = MachineStopReason.Step;
115+
}
116+
117+
_lastStopPoint = new StopPoint()
118+
{
119+
frame = currentFrame,
120+
line = currentFrame.LineNumber
121+
};
122+
_currentState = DebugState.Running;
100123
}
101124
else
102-
LastStopReason = MachineStopReason.Step;
103-
104-
_currentState = DebugState.Running;
125+
{
126+
mustStop = false;
127+
}
105128
}
106129

107130
return mustStop;

0 commit comments

Comments
 (0)