Browse Source

Worked on Local variables pad

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@235 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
45fb709e2b
  1. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 43
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BaseClassItem.cs
  3. 128
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  4. 15
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/PlaceHolderItem.cs
  5. 79
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableItem.cs
  6. 69
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItem.cs
  7. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  8. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  9. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayVariable.cs
  10. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/BuiltInVariable.cs
  11. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullRefVariable.cs
  12. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectVariable.cs
  13. 19
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs
  14. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownVariable.cs
  15. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  16. 23
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -41,12 +41,16 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<Compile Include="Configuration\AssemblyInfo.cs" /> <Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\Pads\BaseClassItem.cs" />
<Compile Include="Src\Pads\BreakPointsPad.cs" /> <Compile Include="Src\Pads\BreakPointsPad.cs" />
<Compile Include="Src\Pads\CallStackPad.cs" /> <Compile Include="Src\Pads\CallStackPad.cs" />
<Compile Include="Src\Pads\ExceptionHistoryPad.cs" /> <Compile Include="Src\Pads\ExceptionHistoryPad.cs" />
<Compile Include="Src\Pads\LoadedModulesPad.cs" /> <Compile Include="Src\Pads\LoadedModulesPad.cs" />
<Compile Include="Src\Pads\LocalVarPad.cs" /> <Compile Include="Src\Pads\LocalVarPad.cs" />
<Compile Include="Src\Pads\PlaceHolderItem.cs" />
<Compile Include="Src\Pads\RunningThreadsPad.cs" /> <Compile Include="Src\Pads\RunningThreadsPad.cs" />
<Compile Include="Src\Pads\VariableItem.cs" />
<Compile Include="Src\Pads\VariableListItem.cs" />
<Compile Include="Src\Service\ExceptionForm.cs"> <Compile Include="Src\Service\ExceptionForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

43
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BaseClassItem.cs

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Text;
using DebuggerLibrary;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
class BaseClassItem: VariableListItem
{
ObjectVariable variable;
public override bool IsValid {
get {
return variable != null &&
variable.HasBaseClass &&
variable.BaseClass.Type != "System.Object";
}
}
public BaseClassItem(Variable baseClassOfVariable): base()
{
this.variable = baseClassOfVariable as ObjectVariable;
Refresh();
}
public override void Refresh()
{
if (!IsValid) {
return;
}
SetTexts("<Base class>",
variable.BaseClass.Value.ToString(),
variable.BaseClass.Type);
ImageIndex = 0; // Class
if (variable.BaseClass.MayHaveSubVariables) { // Always true
Items.Add(new PlaceHolderItem()); // Show plus icon
}
}
}
}

128
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs

@ -16,6 +16,7 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
using DebuggerLibrary; using DebuggerLibrary;
using System.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Gui.Pads namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
@ -99,103 +100,72 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
type.Text = "Type"; type.Text = "Type";
} }
void RefreshList() private void debuggerService_OnDebuggingPaused(object sender, DebuggingPausedEventArgs e)
{ {
if (debugger.IsDebugging && debugger.IsProcessRunning == false) { RefreshList();
debuggerService_OnDebuggingPaused(this, new DebuggingPausedEventArgs(debuggerCore, PausedReason.StepComplete));
}
} }
private void debuggerService_OnDebuggingPaused(object sender, DebuggingPausedEventArgs e) void RefreshList()
{ {
localVarList.BeginUpdate(); if (debugger.IsDebugging && debugger.IsProcessRunning == false) {
localVarList.Items.Clear(); UpdateVariables(localVarList.Items, debuggerCore.LocalVariables);
}
AddVariables(localVarList.Items, debuggerCore.LocalVariables);
localVarList.EndUpdate();
} }
private void localVarList_BeforeExpand(object sender, TreeListViewCancelEventArgs e) private void localVarList_BeforeExpand(object sender, TreeListViewCancelEventArgs e)
{ {
localVarList.BeginUpdate(); if (debugger.IsDebugging && debugger.IsProcessRunning == false) {
e.Item.Items.Clear(); ((VariableListItem)e.Item).PrepareForExpansion();
} else {
ObjectVariable var = e.Item.Tag as ObjectVariable; // TODO: Some message telling user that he can not explore variable since
if (var != null && var.HasBaseClass && var.BaseClass.Type != "System.Object") // the debugger has been resumed.
{ e.Cancel = true;
TreeListViewItem newItem = new TreeListViewItem();
newItem.Text = "<Base class>";
newItem.SubItems.Add(var.BaseClass.Value.ToString());
newItem.SubItems.Add(var.BaseClass.Type);
newItem.Tag = var.BaseClass;
newItem.ImageIndex = 0; // Class
newItem.Items.Add(""); // Show plus icon
e.Item.Items.Add(newItem);
} }
AddVariables(e.Item.Items, ((Variable)e.Item.Tag).SubVariables);
localVarList.EndUpdate();
} }
void AddVariables (TreeListViewItemCollection items, VariableCollection vars) static VariableItem FindVariableItem(TreeListViewItemCollection items, Variable variable)
{ {
foreach (Variable var in vars) { foreach (VariableListItem item in items) {
if (var.Name.StartsWith("CS$")) continue; VariableItem variableItem = item as VariableItem;
TreeListViewItem newItem = new TreeListViewItem(); if (variableItem != null && variableItem.Variable.Name == variable.Name) {
newItem.Tag = var; return variableItem;
newItem.Text = var.Name; }
newItem.SubItems.Add(var.Value.ToString()); }
newItem.SubItems.Add(var.Type); return null;
items.Add(newItem);
RefreshVariable(var);
if (var is PropertyVariable) {
((PropertyVariable)var).ValueEvaluated += new EventHandler<DebuggerEventArgs>(PropertyEvaluated);
}
}
} }
void PropertyEvaluated (object sender, DebuggerEventArgs args)
{
RefreshVariable((Variable)sender);
}
void RefreshVariable (Variable var) public static void UpdateVariables(TreeListViewItemCollection items, VariableCollection variables)
{ {
RefreshVariableInItemConnection(var, localVarList.Items); // Add new variables and refresh existing ones
} foreach (Variable variable in variables) {
VariableItem item = FindVariableItem(items, variable);
void RefreshVariableInItemConnection (Variable var, TreeListViewItemCollection items) if (item != null) {
{ item.Variable = variable;
foreach (TreeListViewItem item in items) { item.Refresh();
// Refresh in sub trees } else {
RefreshVariableInItemConnection(var, item.Items); item = new VariableItem(variable);
if (item.IsValid) {
if (item.Tag == var) { items.Add(item);
if (item.SubItems[1].Text == null) {
item.SubItems[1].Text = var.Value.ToString();
}
item.SubItems[2].Text = var.Type;
item.Items.Clear();
if (var is ObjectVariable && ((ObjectVariable)var).HasBaseClass) {
// It is a class
item.ImageIndex = 0; // Class
item.Items.Add(""); // Show plus icon
//object devNull = (var as ObjectVariable).SubVariables; // Cache variables TODO: LAME
} else if (var is PropertyVariable){
// It is a property
item.ImageIndex = 2; // Property
if ((var as PropertyVariable).IsEvaluated && (var as PropertyVariable).Value is ObjectVariable) {
item.Items.Add(""); // Show plus icon
}
} else {
item.ImageIndex = 1; // Field
} }
} }
} }
// Delete invalid or removed variables
List<VariableListItem> toBeRemoved = new List<VariableListItem>();
foreach (VariableListItem item in items) {
if (!item.IsValid) {
toBeRemoved.Add(item);
continue;
}
VariableItem variableItem = item as VariableItem;
if (variableItem != null && !variables.Contains(variableItem.Variable.Name)) {
toBeRemoved.Add(item);
}
}
foreach (VariableListItem item in toBeRemoved) {
item.Remove();
}
} }
} }
} }

15
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/PlaceHolderItem.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
class PlaceHolderItem: VariableListItem
{
public override bool IsValid {
get {
return false;
}
}
}
}

79
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableItem.cs

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Text;
using DebuggerLibrary;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
class VariableItem: VariableListItem
{
Variable variable;
bool baseClassItemAdded = false;
public Variable Variable {
get {
return variable;
}
set {
variable = value;
}
}
public override bool IsValid {
get {
return variable != null &&
!variable.Name.StartsWith("CS$");
}
}
public VariableItem(Variable variable): base()
{
this.variable = variable;
Refresh();
}
public override void PrepareForExpansion()
{
UpdateSubVariables();
}
public override void Refresh()
{
if (!IsValid) {
return;
}
SetTexts(variable.Name,
variable.Value.ToString(),
variable.Type);
if (variable is ObjectVariable) {
ImageIndex = 0; // Class
} else if (variable is PropertyVariable){
ImageIndex = 2; // Property
} else {
ImageIndex = 1; // Field
}
if (variable.MayHaveSubVariables && !IsExpanded) {
Items.Add(new PlaceHolderItem()); // Show plus icon
}
if (IsExpanded) {
UpdateSubVariables();
}
}
void UpdateSubVariables() {
if (!baseClassItemAdded) {
VariableListItem baseClassItem = new BaseClassItem(variable);
if (baseClassItem.IsValid) {
this.Items.Add(baseClassItem);
}
baseClassItemAdded = true;
}
LocalVarPad.UpdateVariables(this.Items, Variable.SubVariables);
}
}
}

69
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItem.cs

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
abstract class VariableListItem: TreeListViewItem
{
bool textsInitialized;
public abstract bool IsValid {
get;
}
public VariableListItem()
{
Reset();
}
public virtual void PrepareForExpansion()
{
}
public virtual void Reset()
{
SubItems.Clear();
Text = "";
SubItems.Add("");
SubItems.Add("");
}
public virtual void Refresh()
{
}
protected void SetTexts(string name, string value, string type)
{
if (value == SubItems[1].Text || !textsInitialized) {
// Value has not changed since last setting
if (SubItems[1].ForeColor != Color.Black) {
SubItems[1].ForeColor = Color.Black;
SubItems[1].Font = new Font(SubItems[1].Font, FontStyle.Regular);
}
} else {
// Value has changed since last setting
if (SubItems[1].ForeColor != Color.Blue) {
SubItems[1].ForeColor = Color.Blue;
SubItems[1].Font = new Font(SubItems[1].Font, FontStyle.Bold);
}
}
if (SubItems[0].Text != name) {
SubItems[0].Text = name;
}
if (SubItems[1].Text != value) {
SubItems[1].Text = value;
}
if (SubItems[2].Text != type) {
SubItems[2].Text = type;
}
textsInitialized = true;
}
}
}

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs

@ -89,8 +89,8 @@ namespace DebuggerLibrary
void ExitCallback_Paused(PausedReason reason) void ExitCallback_Paused(PausedReason reason)
{ {
if (reason != PausedReason.EvalComplete) { if (reason != PausedReason.EvalComplete) {
debugger.OnDebuggingPaused(reason);
debugger.OnIsProcessRunningChanged(); debugger.OnIsProcessRunningChanged();
debugger.OnDebuggingPaused(reason);
} }
handlingCallback = false; handlingCallback = false;
} }

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -299,7 +299,7 @@ namespace DebuggerLibrary
public VariableCollection LocalVariables { public VariableCollection LocalVariables {
get { get {
if (!IsDebugging) return VariableCollection.Empty; if (!IsDebugging) return VariableCollection.Empty;
return CurrentProcess.CurrentThread.CurrentFunction.GetLocalVariables(); return CurrentProcess.CurrentThread.CurrentFunction.GetVariables();
} }
} }

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayVariable.cs

@ -105,6 +105,11 @@ namespace DebuggerLibrary
} }
} }
public override bool MayHaveSubVariables {
get {
return true;
}
}
protected override VariableCollection GetSubVariables() protected override VariableCollection GetSubVariables()
{ {

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/BuiltInVariable.cs

@ -72,5 +72,11 @@ namespace DebuggerLibrary
internal BuiltInVariable(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name) internal BuiltInVariable(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name)
{ {
} }
public override bool MayHaveSubVariables {
get {
return false;
}
}
} }
} }

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullRefVariable.cs

@ -40,5 +40,11 @@ namespace DebuggerLibrary
{ {
} }
public override bool MayHaveSubVariables {
get {
return false;
}
}
} }
} }

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectVariable.cs

@ -62,6 +62,11 @@ namespace DebuggerLibrary
corModuleSuperclass = corModule; corModuleSuperclass = corModule;
} }
public override bool MayHaveSubVariables {
get {
return true;
}
}
protected override unsafe VariableCollection GetSubVariables() protected override unsafe VariableCollection GetSubVariables()
{ {

19
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs

@ -46,15 +46,24 @@ namespace DebuggerLibrary
return currentValue.Type; return currentValue.Type;
} }
} }
public override VariableCollection SubVariables { public override bool MayHaveSubVariables {
get { get {
if (!IsEvaluated) { if (IsEvaluated) {
Evaluate(); return currentValue.MayHaveSubVariables;
} else {
return true;
} }
return currentValue.SubVariables;
} }
} }
protected override VariableCollection GetSubVariables()
{
if (!IsEvaluated) {
Evaluate();
}
return currentValue.SubVariables;
}
/// <summary> /// <summary>
/// Executes evaluation of variable and doesn't return /// Executes evaluation of variable and doesn't return

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownVariable.cs

@ -30,5 +30,11 @@ namespace DebuggerLibrary
{ {
} }
public override bool MayHaveSubVariables {
get {
return false;
}
}
} }
} }

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -53,7 +53,11 @@ namespace DebuggerLibrary
} }
} }
public virtual VariableCollection SubVariables { public abstract bool MayHaveSubVariables {
get;
}
public VariableCollection SubVariables {
get{ get{
if (subVariables == null) subVariables = GetSubVariables(); if (subVariables == null) subVariables = GetSubVariables();
return subVariables; return subVariables;

23
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

@ -24,6 +24,26 @@ namespace DebuggerLibrary
} }
public bool Contains(Variable variable)
{
foreach (Variable v in InnerList) {
if (v == variable) {
return true;
}
}
return false;
}
public bool Contains(string variableName)
{
foreach (Variable v in InnerList) {
if (v.Name == variableName) {
return true;
}
}
return false;
}
static VariableCollection() static VariableCollection()
{ {
Empty = new VariableCollection(); Empty = new VariableCollection();
@ -46,8 +66,7 @@ namespace DebuggerLibrary
} }
} }
public Variable this[string variableName] public Variable this[string variableName] {
{
get { get {
foreach (Variable v in InnerList) { foreach (Variable v in InnerList) {
if (v.Name == variableName) { if (v.Name == variableName) {

Loading…
Cancel
Save