Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4904


Ignore:
Timestamp:
11/22/10 17:06:12 (14 years ago)
Author:
epitzer
Message:

Add operator trace view (#47)

Location:
branches/HeuristicLab.DebugEngine
Files:
3 added
7 edited

Legend:

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

    r4903 r4904  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Threading;
     
    4849      Log = cloner.Clone(original.Log);
    4950      ExecutionStack = cloner.Clone(original.ExecutionStack);
     51      OperatorTrace = new ItemList<IOperator>(original.OperatorTrace.Select(op => cloner.Clone(op)));
     52      operatorParents = original.operatorParents.ToDictionary(kvp => cloner.Clone(kvp.Key), kvp => cloner.Clone(kvp.Value));
    5053      pausePending = original.pausePending;
    5154      stopPending = original.stopPending;
     
    6063      Log = new Log();
    6164      ExecutionStack = new ExecutionStack();
     65      OperatorTrace = new ItemList<IOperator>();
     66      operatorParents = new Dictionary<IAtomicOperation, IAtomicOperation>();
    6267      pausePending = stopPending = false;
    6368      timer = new System.Timers.Timer(100);
     
    110115    }
    111116
     117    [Storable]
     118    public ItemList<IOperator> OperatorTrace { get; private set; }
     119
     120    [Storable]
     121    private Dictionary<IAtomicOperation, IAtomicOperation> operatorParents;
     122
    112123    #endregion
    113124
     
    131142      ignoreNextBreakpoint = false;
    132143      CurrentOperation = null;
     144      OperatorTrace.Clear();
     145      operatorParents.Clear();
    133146      OnPrepared();
    134147    }
     
    140153      ignoreNextBreakpoint = false;
    141154      CurrentOperation = null;
     155      OperatorTrace.Clear();
     156      operatorParents.Clear();
    142157      OnPrepared();
    143158    }
     
    161176    public override void Start() {
    162177      base.Start();
    163       CurrentOperation = null;
    164178      ThreadPool.QueueUserWorkItem(new WaitCallback(Run), null);
    165179    }
     
    250264          ExpandOperationCollection(operations);
    251265        } else if (ExecutionStack.Count > 0) {
    252           Log.LogMessage("Poping execution stack");
     266          Log.LogMessage("Popping execution stack");
    253267          CurrentOperation = ExecutionStack.Last();
    254268          ExecutionStack.RemoveAt(ExecutionStack.Count - 1);
     
    256270          Log.LogMessage("Nothing to do");
    257271        }
     272        GenerateOperationTrace();
    258273      } catch (Exception x) {
    259274        OnExceptionOccurred(x);
     275      }
     276    }
     277
     278    private void GenerateOperationTrace() {
     279      var operation = CurrentOperation as IAtomicOperation;
     280      if (operation != null) {
     281        List<IOperator> trace = new List<IOperator>();
     282        while (operation != null) {
     283          trace.Add(operation.Operator);
     284          IAtomicOperation parent = null;
     285          operatorParents.TryGetValue(operation, out parent);
     286          operation = parent;
     287        }
     288        trace.Reverse();
     289        OperatorTrace.Clear();
     290        OperatorTrace.AddRange(trace);
    260291      }
    261292    }
     
    276307          currentOperator = operation.Operator;
    277308          IOperation successor = operation.Operator.Execute((IExecutionContext)operation);
    278           CurrentOperation = null;
    279           currentOperator = null;
    280309          if (successor != null) {
     310            AssignParents(operation, successor);
    281311            ExecutionStack.Add(successor);
    282312          }
     313          currentOperator = null;
     314          CurrentOperation = null;
    283315        } catch (Exception ex) {
    284316          OnExceptionOccurred(new OperatorExecutionException(operation.Operator, ex));
     
    288320    }
    289321
     322    private void AssignParents(IAtomicOperation parent, IOperation successor) {
     323      OperationCollection operations = successor as OperationCollection;
     324      if (operations != null)
     325        foreach (var op in operations)
     326          AssignParents(parent, op);
     327      IAtomicOperation atomicOperation = successor as IAtomicOperation;
     328      if (atomicOperation != null && atomicOperation.Operator != null && !operatorParents.ContainsKey(atomicOperation))
     329        operatorParents[atomicOperation] = parent;
     330    }
     331
    290332    protected virtual void ExpandOperationCollection(OperationCollection operations) {
    291333      ExecutionStack.AddRange(operations.Reverse());
  • branches/HeuristicLab.DebugEngine/DebugEngineView.Designer.cs

    r4903 r4904  
    4949      this.label1 = new System.Windows.Forms.Label();
    5050      this.executionTimeTextBox = new System.Windows.Forms.TextBox();
    51       this.executionStackView = new HeuristicLab.DebugEngine.ExecutionStackView();
    52       this.operationContentView = new HeuristicLab.DebugEngine.OperationContentView();
     51      this.operationContentView = new OperationContentView();
    5352      this.logView = new HeuristicLab.Core.Views.LogView();
    5453      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
     
    5857      this.refreshButton = new System.Windows.Forms.Button();
    5958      this.skipStackOpsCheckBox = new System.Windows.Forms.CheckBox();
     59      this.splitContainer3 = new System.Windows.Forms.SplitContainer();
     60      this.executionStackView = new HeuristicLab.DebugEngine.ExecutionStackView();
     61      this.operatorTraceView = new OperatorTraceView();
    6062      this.splitContainer1.Panel1.SuspendLayout();
    6163      this.splitContainer1.Panel2.SuspendLayout();
     
    6466      this.splitContainer2.Panel2.SuspendLayout();
    6567      this.splitContainer2.SuspendLayout();
     68      this.splitContainer3.Panel1.SuspendLayout();
     69      this.splitContainer3.SuspendLayout();
    6670      this.SuspendLayout();
    6771      //
     
    8589      this.executionTimeTextBox.TabIndex = 1;
    8690      //
    87       // executionStackView
    88       //
    89       this.executionStackView.Caption = "Execution Stack View";
    90       this.executionStackView.Content = null;
    91       this.executionStackView.Dock = System.Windows.Forms.DockStyle.Fill;
    92       this.executionStackView.Location = new System.Drawing.Point(0, 0);
    93       this.executionStackView.Name = "executionStackView";
    94       this.executionStackView.ReadOnly = false;
    95       this.executionStackView.Size = new System.Drawing.Size(252, 262);
    96       this.executionStackView.TabIndex = 0;
    97       //
    98       // operationContentView
    99       //
    100       this.operationContentView.Caption = "Operation Content View";
    101       this.operationContentView.Content = null;
    102       this.operationContentView.Dock = System.Windows.Forms.DockStyle.Fill;
    103       this.operationContentView.Location = new System.Drawing.Point(0, 0);
    104       this.operationContentView.Name = "operationContentView";
    105       this.operationContentView.ReadOnly = false;
    106       this.operationContentView.Size = new System.Drawing.Size(610, 503);
    107       this.operationContentView.TabIndex = 0;
    108       //
    10991      // logView
    11092      //
     
    11597      this.logView.Name = "logView";
    11698      this.logView.ReadOnly = false;
    117       this.logView.Size = new System.Drawing.Size(252, 237);
     99      this.logView.Size = new System.Drawing.Size(198, 237);
    118100      this.logView.TabIndex = 2;
    119101      //
     
    132114      //
    133115      this.splitContainer1.Panel2.Controls.Add(this.logView);
    134       this.splitContainer1.Size = new System.Drawing.Size(252, 503);
    135       this.splitContainer1.SplitterDistance = 262;
     116      this.splitContainer1.Size = new System.Drawing.Size(198, 502);
     117      this.splitContainer1.SplitterDistance = 261;
    136118      this.splitContainer1.TabIndex = 3;
    137119      //
    138120      // splitContainer2
    139121      //
    140       this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    141                   | System.Windows.Forms.AnchorStyles.Left)
    142                   | System.Windows.Forms.AnchorStyles.Right)));
    143       this.splitContainer2.Location = new System.Drawing.Point(3, 32);
     122      this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
     123      this.splitContainer2.Location = new System.Drawing.Point(0, 0);
    144124      this.splitContainer2.Name = "splitContainer2";
    145125      //
     
    151131      //
    152132      this.splitContainer2.Panel2.Controls.Add(this.operationContentView);
    153       this.splitContainer2.Size = new System.Drawing.Size(866, 503);
    154       this.splitContainer2.SplitterDistance = 252;
     133      this.splitContainer2.Size = new System.Drawing.Size(683, 502);
     134      this.splitContainer2.SplitterDistance = 198;
    155135      this.splitContainer2.TabIndex = 0;
    156136      //
     
    189169      this.skipStackOpsCheckBox.UseVisualStyleBackColor = true;
    190170      //
     171      // splitContainer3
     172      //
     173      this.splitContainer3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     174                  | System.Windows.Forms.AnchorStyles.Left)
     175                  | System.Windows.Forms.AnchorStyles.Right)));
     176      this.splitContainer3.Location = new System.Drawing.Point(3, 33);
     177      this.splitContainer3.Name = "splitContainer3";
     178      //
     179      // splitContainer3.Panel1
     180      //
     181      this.splitContainer3.Panel1.Controls.Add(this.splitContainer2);
     182      this.splitContainer3.Panel2.Controls.Add(this.operatorTraceView);
     183      this.splitContainer3.Size = new System.Drawing.Size(866, 502);
     184      this.splitContainer3.SplitterDistance = 683;
     185      this.splitContainer3.TabIndex = 7;
     186      this.operatorTraceView.Dock = System.Windows.Forms.DockStyle.Fill;
     187      //
     188      // executionStackView
     189      //
     190      this.executionStackView.Caption = "Execution Stack View";
     191      this.executionStackView.Content = null;
     192      this.executionStackView.Dock = System.Windows.Forms.DockStyle.Fill;
     193      this.executionStackView.Location = new System.Drawing.Point(0, 0);
     194      this.executionStackView.Name = "executionStackView";
     195      this.executionStackView.ReadOnly = false;
     196      this.executionStackView.Size = new System.Drawing.Size(198, 261);
     197      this.executionStackView.TabIndex = 0;
     198      //
     199      // operationContentView
     200      //
     201      this.operationContentView.Caption = "Operation Content View";
     202      this.operationContentView.Content = null;
     203      this.operationContentView.Dock = System.Windows.Forms.DockStyle.Fill;
     204      this.operationContentView.Location = new System.Drawing.Point(0, 0);
     205      this.operationContentView.Name = "operationContentView";
     206      this.operationContentView.ReadOnly = false;
     207      this.operationContentView.Size = new System.Drawing.Size(481, 502);
     208      this.operationContentView.TabIndex = 0;
     209      //
    191210      // DebugEngineView
    192211      //
    193212      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     213      this.Controls.Add(this.splitContainer3);
    194214      this.Controls.Add(this.skipStackOpsCheckBox);
    195215      this.Controls.Add(this.refreshButton);
    196       this.Controls.Add(this.splitContainer2);
    197216      this.Controls.Add(this.stepButton);
    198217      this.Controls.Add(this.executionTimeTextBox);
     
    206225      this.splitContainer2.Panel2.ResumeLayout(false);
    207226      this.splitContainer2.ResumeLayout(false);
     227      this.splitContainer3.Panel1.ResumeLayout(false);
     228      this.splitContainer3.ResumeLayout(false);
    208229      this.ResumeLayout(false);
    209230      this.PerformLayout();
     
    224245    private System.Windows.Forms.Button refreshButton;
    225246    private System.Windows.Forms.CheckBox skipStackOpsCheckBox;
     247    private System.Windows.Forms.SplitContainer splitContainer3;
     248    private OperatorTraceView operatorTraceView;
    226249
    227250  }
  • branches/HeuristicLab.DebugEngine/DebugEngineView.cs

    r4903 r4904  
    123123            executionStackView.SuspendUpdate();
    124124            logView.Content = null;
     125            operatorTraceView.Content = null;
    125126            break;
    126127          default:
     
    128129            executionStackView.ResumeUpdate();
    129130            operationContentView.Content = new OperationContent(Content.CurrentOperation);
     131            operatorTraceView.Content = Content.OperatorTrace;
    130132            break;
    131133        }
     
    138140        Invoke(new EventHandler<OperationChangedEventArgs>(Content_CurrentOperationChanged), sender, e);
    139141      } else {
    140         if (Content.ExecutionState != ExecutionState.Started)
    141           operationContentView.Content = new OperationContent(Content.CurrentOperation);
    142142      }
    143143    }
  • branches/HeuristicLab.DebugEngine/DebugEngineView.resx

    r4903 r4904  
    122122    <value>
    123123        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    124         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALCwAA
    125         CwsBbQSEtwAAARBJREFUOE9j+P//PwM6Tuh5woxNHJsYhmaQIqABMkDMRIwhWA0onPX8f/zkt0rEGILV
     124        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/gAA
     125        Cv4B5iV4ZgAAARBJREFUOE9j+P//PwM6Tuh5woxNHJsYhmaQIqABMkDMRIwhWA0onPX8f/zkt0rEGILV
    126126        gNyZz/4ndN/7HzfhtQYh72A1IGPK0//z9v/+H9Rw8zXQAFt8huAKg/+z9/3637n173+30sv/gQbY4zIE
    127127        qwGRXY/+T9n263/J0r//E6b//W+TexanIVgNCGx++L917XuwZuOSL/+lo6/9N45c9t+h6Gw8ukuwGuBR
     
    137137    <value>
    138138        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    139         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALEQAA
    140         CxEBf2RfkQAAAmFJREFUOE+dk21IU1EYx3cVVzkhaLCy+UaY0xwlZkYRmiGR7oMEUlAGfRGKvkRFVOQ0
     139        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALBAAA
     140        CwQBG8oqrQAAAmFJREFUOE+dk21IU1EYx3cVVzkhaLCy+UaY0xwlZkYRmiGR7oMEUlAGfRGKvkRFVOQ0
    141141        DddsVmtbvpQWhCFBSvaCUcRAk0gGm8SGM7JtrU1nzYFvu3P33znDRcLpSxceDvdefr/zv+d5Lidaufjg
    142142        QKKIWwNSUo4Tz4u4RAl5xYsgJIuEcADCYlS8oQKLvvvKdam1n+PcqjUyN5ox7PyIVrMB1U9PoKxThZI7
  • branches/HeuristicLab.DebugEngine/ExecutionStackView.Designer.cs

    r4871 r4904  
    6565    private System.Windows.Forms.TreeView treeView;
    6666    private System.Windows.Forms.GroupBox groupBox;
     67
    6768  }
    6869}
  • branches/HeuristicLab.DebugEngine/HeuristicLab.DebugEngine.csproj

    r4876 r4904  
    140140      <DependentUpon>OperationContentView.cs</DependentUpon>
    141141    </Compile>
     142    <Compile Include="OperatorTraceView.cs">
     143      <SubType>UserControl</SubType>
     144    </Compile>
     145    <Compile Include="OperatorTraceView.Designer.cs">
     146      <DependentUpon>OperatorTraceView.cs</DependentUpon>
     147    </Compile>
    142148    <Compile Include="Properties\AssemblyInfo.cs" />
    143149    <Compile Include="Properties\Resources.Designer.cs">
     
    157163    <EmbeddedResource Include="OperationContentView.resx">
    158164      <DependentUpon>OperationContentView.cs</DependentUpon>
     165    </EmbeddedResource>
     166    <EmbeddedResource Include="OperatorTraceView.resx">
     167      <DependentUpon>OperatorTraceView.cs</DependentUpon>
    159168    </EmbeddedResource>
    160169    <EmbeddedResource Include="Properties\Resources.resx">
  • branches/HeuristicLab.DebugEngine/OperationContentView.cs

    r4903 r4904  
    197197    }
    198198
    199     #endregion
    200 
    201199    private void nameTextBox_DoubleClick(object sender, EventArgs e) {
    202200      if (Content != null && Content.IsAtomic && Content.AtomicOperation.Operator != null)
     
    204202    }
    205203
     204    #endregion
     205
     206
     207
    206208  }
    207209}
Note: See TracChangeset for help on using the changeset viewer.