Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/26/10 17:14:16 (14 years ago)
Author:
epitzer
Message:

Simpler breakpoint handling, fix cloning, prevent stepping while running (#47)

Location:
branches/HeuristicLab.DebugEngine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DebugEngine/DebugEngine.cs

    r4946 r4947  
    4848      Log = cloner.Clone(original.Log);
    4949      ExecutionStack = cloner.Clone(original.ExecutionStack);
    50       OperatorTrace = cloner.Clone(OperatorTrace);
     50      OperatorTrace = cloner.Clone(original.OperatorTrace);
    5151      operatorParents = original.operatorParents.ToDictionary(kvp => cloner.Clone(kvp.Key), kvp => cloner.Clone(kvp.Value));
    5252      pausePending = original.pausePending;
     
    9494
    9595    [Storable]
    96     private bool ignoreNextBreakpoint;
    97 
    98     [Storable]
    9996    private IOperation currentOperation;
    10097    public virtual IOperation CurrentOperation {
     
    122119    private Dictionary<IAtomicOperation, IAtomicOperation> operatorParents;
    123120
     121    public virtual bool CanContinue {
     122      get { return CurrentOperation != null || ExecutionStack.Count > 0; }
     123    }
     124
     125    public virtual bool IsAtBreakpoint {
     126      get { return CurrentAtomicOperation != null && CurrentAtomicOperation.Operator != null && CurrentAtomicOperation.Operator.Breakpoint; }
     127    }
     128
    124129    #endregion
    125130
     
    140145      base.Prepare();
    141146      ExecutionStack.Clear();
    142       ignoreNextBreakpoint = false;
    143147      CurrentOperation = null;
    144148      OperatorTrace.Clear();
     
    151155      if (initialOperation != null)
    152156        ExecutionStack.Add(initialOperation);
    153       ignoreNextBreakpoint = false;
    154157      CurrentOperation = null;
    155158      OperatorTrace.Clear();
     
    165168      OnStarted();
    166169      lastUpdateTime = DateTime.Now;
    167       ignoreNextBreakpoint = true;
    168170      timer.Start();
    169171      ProcessNextOperation();
     
    172174      timer.Stop();
    173175      ExecutionTime += DateTime.Now - lastUpdateTime;
    174       ignoreNextBreakpoint = false;
    175176      OnPaused();
    176177    }
     
    202203      stopPending = true;
    203204      if (currentOperator != null) currentOperator.Abort();
    204       ignoreNextBreakpoint = false;
    205205      if (ExecutionState == ExecutionState.Paused) OnStopped();
    206206    }
     
    222222      lastUpdateTime = DateTime.Now;
    223223      timer.Start();
    224       while (!pausePending && !stopPending && CanContinue) {
     224      if (!pausePending && !stopPending && CanContinue)
    225225        ProcessNextOperation();
    226       }
     226      while (!pausePending && !stopPending && CanContinue && !IsAtBreakpoint)
     227        ProcessNextOperation();
    227228      timer.Stop();
    228229      ExecutionTime += DateTime.Now - lastUpdateTime;
    229230
    230       if (pausePending) OnPaused();
    231       else OnStopped();
     231      if (IsAtBreakpoint)
     232        Log.LogMessage(string.Format("Breaking before: {0}", CurrentAtomicOperation.Operator.Name));
     233      if (pausePending || IsAtBreakpoint)
     234        OnPaused();
     235      else
     236        OnStopped();
    232237    }
    233238
     
    241246    #region Methods
    242247
    243     public virtual bool CanContinue {
    244       get { return CurrentOperation != null || ExecutionStack.Count > 0; }
    245     }
     248
    246249
    247250    /// <summary>
     
    274277        }
    275278        GenerateOperationTrace();
    276       }
    277       catch (Exception x) {
     279      } catch (Exception x) {
    278280        OnExceptionOccurred(x);
    279281      }
     
    298300    protected virtual void PerformAtomicOperation(IAtomicOperation operation) {
    299301      if (operation != null) {
    300         if (operation.Operator.Breakpoint) {
    301           if (ignoreNextBreakpoint) {
    302             ignoreNextBreakpoint = false;
    303           } else {
    304             ignoreNextBreakpoint = true;
    305             Log.LogMessage(string.Format("Breaking before: {0}", Name(operation)));
    306             Pause();
    307             return;
    308           }
    309         }
    310302        try {
    311303          currentOperator = operation.Operator;
     
    317309          currentOperator = null;
    318310          CurrentOperation = null;
    319         }
    320         catch (Exception ex) {
     311        } catch (Exception ex) {
    321312          OnExceptionOccurred(new OperatorExecutionException(operation.Operator, ex));
    322313          Pause();
  • branches/HeuristicLab.DebugEngine/DebugEngineView.cs

    r4909 r4947  
    9595        refreshButton.Enabled = false;
    9696      } else {
    97         stepButton.Enabled = Content.CanContinue;
    98         refreshButton.Enabled = Content.CurrentAtomicOperation != null;
     97        stepButton.Enabled = Content.CanContinue && Content.ExecutionState != ExecutionState.Started;
     98        refreshButton.Enabled = Content.CurrentAtomicOperation != null && Content.ExecutionState != ExecutionState.Started;
    9999      }
    100100    }
Note: See TracChangeset for help on using the changeset viewer.