Browse Source

Added some debugging info into debug tooltips

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1629 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 19 years ago
parent
commit
dbde99cc31
  1. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs
  2. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  3. 39
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Util.cs
  4. 16
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs
  5. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs
  6. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs
  7. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs
  8. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs
  9. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs
  10. 29
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs
  11. 68
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  12. 22
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs
  13. 18
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/ICorDebugGenericValue.cs

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs

@ -192,6 +192,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -192,6 +192,7 @@ namespace ICSharpCode.SharpDevelop.Services
subMenu[2].Text = subCollection.Name;
subMenu[3].Text = subCollection.Value;
subMenu.ShowMinusWhileExpanded = true;
subMenu.ShowPlus = !subCollection.IsEmpty;
EventHandler<DynamicListEventArgs> populate = null;
populate = delegate {

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -381,6 +381,7 @@ @@ -381,6 +381,7 @@
<Compile Include="Src\Variables\Evals\Eval.NewStringEval.cs" />
<Compile Include="Src\Variables\Variable.cs" />
<Compile Include="Src\Variables\ObjectValue.cs" />
<Compile Include="Src\Debugger\Util.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="README.TXT" />

39
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Util.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using Debugger.Wrappers.CorDebug;
namespace Debugger
{
public static class Util
{
public static List<T> MergeLists<T>(T a, IEnumerable<T> b)
{
return MergeLists(new T[] {a}, b);
}
public static List<T> MergeLists<T>(IEnumerable<T> a, T b)
{
return MergeLists(a, new T[] {b});
}
public static List<T> MergeLists<T>(IEnumerable<T> a, IEnumerable<T> b)
{
List<T> newList = new List<T>();
if (a != null) newList.AddRange(a);
if (b != null) newList.AddRange(b);
return newList;
}
}
}

16
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs

@ -133,19 +133,17 @@ namespace Debugger @@ -133,19 +133,17 @@ namespace Debugger
}
}
public override bool MayHaveSubVariables {
get {
return true;
}
protected override bool GetMayHaveSubVariables()
{
return true;
}
public override VariableCollection SubVariables {
get {
return new VariableCollection(GetSubVariables());
}
protected override VariableCollection GetSubVariables()
{
return new VariableCollection(GetSubVariablesEnum());
}
IEnumerable<Variable> GetSubVariables()
IEnumerable<Variable> GetSubVariablesEnum()
{
uint[] indices = new uint[rank];

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs

@ -25,14 +25,6 @@ namespace Debugger @@ -25,14 +25,6 @@ namespace Debugger
Variable thisValue;
Variable[] args;
static List<T> MergeLists<T>(IEnumerable<T> a, IEnumerable<T> b)
{
List<T> newList = new List<T>();
if (a != null) newList.AddRange(a);
if (b != null) newList.AddRange(b);
return newList;
}
public CallFunctionEval(NDebugger debugger, string moduleName, string containgType, string functionName, bool reevaluateAfterDebuggeeStateChange, Variable thisValue, Variable[] args)
:this(debugger, null, reevaluateAfterDebuggeeStateChange, thisValue, args)
{
@ -42,7 +34,7 @@ namespace Debugger @@ -42,7 +34,7 @@ namespace Debugger
}
public CallFunctionEval(NDebugger debugger, ICorDebugFunction corFunction, bool reevaluateAfterDebuggeeStateChange, Variable thisValue, Variable[] args)
:base(debugger, reevaluateAfterDebuggeeStateChange, thisValue == null? args : MergeLists(new Variable[] {thisValue}, args).ToArray())
:base(debugger, reevaluateAfterDebuggeeStateChange, thisValue == null? args : Util.MergeLists(new Variable[] {thisValue}, args).ToArray())
{
this.corFunction = corFunction;
this.thisValue = thisValue;

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs

@ -41,10 +41,9 @@ namespace Debugger @@ -41,10 +41,9 @@ namespace Debugger
}
public override bool MayHaveSubVariables {
get {
return false;
}
protected override bool GetMayHaveSubVariables()
{
return false;
}
}
}

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs

@ -78,16 +78,14 @@ namespace Debugger @@ -78,16 +78,14 @@ namespace Debugger
}
}
public override bool MayHaveSubVariables {
get {
return true;
}
protected override bool GetMayHaveSubVariables()
{
return true;
}
public override VariableCollection SubVariables {
get {
return topClass.SubVariables;
}
protected override VariableCollection GetSubVariables()
{
return topClass.SubVariables;
}
}
}

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs

@ -55,10 +55,9 @@ namespace Debugger @@ -55,10 +55,9 @@ namespace Debugger
{
}
public override bool MayHaveSubVariables {
get {
return false;
}
protected override bool GetMayHaveSubVariables()
{
return false;
}
}
}

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs

@ -33,10 +33,9 @@ namespace Debugger @@ -33,10 +33,9 @@ namespace Debugger
this.message = message;
}
public override bool MayHaveSubVariables {
get {
return false;
}
protected override bool GetMayHaveSubVariables()
{
return false;
}
}
}

29
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs

@ -63,16 +63,37 @@ namespace Debugger @@ -63,16 +63,37 @@ namespace Debugger
}
}
public abstract bool MayHaveSubVariables {
get;
public bool MayHaveSubVariables {
get {
#if DEBUG
return true;
#else
return GetMayHaveSubVariables();
#endif
}
}
public virtual VariableCollection SubVariables {
protected abstract bool GetMayHaveSubVariables();
public VariableCollection SubVariables {
get {
return new VariableCollection(new Variable[] {});
VariableCollection subVars = GetSubVariables();
#if DEBUG
return new VariableCollection(subVars.Name,
subVars.Value,
Util.MergeLists(variable.GetDebugInfo(), subVars.SubCollections).ToArray(),
subVars.Items);
#else
return subVars;
#endif
}
}
protected virtual VariableCollection GetSubVariables()
{
return new VariableCollection(new Variable[] {});
}
public Variable this[string variableName] {
get {
foreach(Variable v in SubVariables) {

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

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
@ -267,6 +268,73 @@ namespace Debugger @@ -267,6 +268,73 @@ namespace Debugger
throw new CannotGetValueException("Unknown value type");
}
}
public VariableCollection GetDebugInfo()
{
return GetDebugInfo(this.RawCorValue);
}
public static VariableCollection GetDebugInfo(ICorDebugValue corValue)
{
List<VariableCollection> items = new List<VariableCollection>();
if (corValue.Is<ICorDebugValue>()) {
List<VariableCollection> more = new List<VariableCollection>();
more.Add(new VariableCollection("type", ((CorElementType)corValue.Type).ToString()));
more.Add(new VariableCollection("size", corValue.Size.ToString()));
more.Add(new VariableCollection("address", corValue.Address.ToString("X")));
items.Add(new VariableCollection("ICorDebugValue", "", more, null));
}
if (corValue.Is<ICorDebugValue2>()) items.Add(new VariableCollection("ICorDebugValue2", "", null, null));
if (corValue.Is<ICorDebugGenericValue>()) {
List<VariableCollection> more = new List<VariableCollection>();
try {
byte[] bytes = corValue.CastTo<ICorDebugGenericValue>().RawValue;
for(int i = 0; i < bytes.Length; i += 8) {
string val = "";
for(int j = i; j < bytes.Length && j < i + 8; j++) {
val += bytes[j].ToString("X2") + " ";
}
more.Add(new VariableCollection("data" + i.ToString("X2"), val));
}
} catch (ArgumentException) {
more.Add(new VariableCollection("data", "N/A"));
}
items.Add(new VariableCollection("ICorDebugGenericValue", "", more, null));
}
if (corValue.Is<ICorDebugReferenceValue>()) {
List<VariableCollection> more = new List<VariableCollection>();
ICorDebugReferenceValue refValue = corValue.CastTo<ICorDebugReferenceValue>();
bool isNull = refValue.IsNull != 0;
more.Add(new VariableCollection("isNull", isNull.ToString()));
if (!isNull) {
more.Add(new VariableCollection("address", refValue.Value.ToString("X")));
VariableCollection deRef = GetDebugInfo(refValue.Dereference());
more.Add(new VariableCollection("dereferenced", deRef.Value, deRef.SubCollections, deRef.Items));
}
items.Add(new VariableCollection("ICorDebugReferenceValue", "", more, null));
}
if (corValue.Is<ICorDebugHeapValue>()) items.Add(new VariableCollection("ICorDebugHeapValue", "", null, null));
if (corValue.Is<ICorDebugHeapValue2>()) items.Add(new VariableCollection("ICorDebugHeapValue2", "", null, null));
if (corValue.Is<ICorDebugObjectValue>()) {
List<VariableCollection> more = new List<VariableCollection>();
bool isValue = corValue.CastTo<ICorDebugObjectValue>().IsValueClass != 0;
more.Add(new VariableCollection("isValue", isValue.ToString()));
items.Add(new VariableCollection("ICorDebugObjectValue", "", more, null));
}
if (corValue.Is<ICorDebugObjectValue2>()) items.Add(new VariableCollection("ICorDebugObjectValue2", "", null, null));
if (corValue.Is<ICorDebugBoxValue>()) {
List<VariableCollection> more = new List<VariableCollection>();
VariableCollection unboxed = GetDebugInfo(corValue.CastTo<ICorDebugBoxValue>().Object.CastTo<ICorDebugValue>());
more.Add(new VariableCollection("unboxed", unboxed.Value, unboxed.SubCollections, unboxed.Items));
items.Add(new VariableCollection("ICorDebugBoxValue", "", more, null));
}
if (corValue.Is<ICorDebugStringValue>()) items.Add(new VariableCollection("ICorDebugStringValue", "", null, null));
if (corValue.Is<ICorDebugArrayValue>()) items.Add(new VariableCollection("ICorDebugArrayValue", "", null, null));
if (corValue.Is<ICorDebugHandleValue>()) items.Add(new VariableCollection("ICorDebugHandleValue", "", null, null));
return new VariableCollection("$debugInfo", ((CorElementType)corValue.Type).ToString(), items.ToArray(), null);
}
}
class CannotGetValueException: System.Exception

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

@ -59,10 +59,8 @@ namespace Debugger @@ -59,10 +59,8 @@ namespace Debugger
public bool IsEmpty {
get {
foreach(VariableCollection col in SubCollections) {
if (!col.IsEmpty) return false;
}
return !Items.GetEnumerator().MoveNext();
return !SubCollections.GetEnumerator().MoveNext() &&
!Items.GetEnumerator().MoveNext();
}
}
@ -71,12 +69,24 @@ namespace Debugger @@ -71,12 +69,24 @@ namespace Debugger
{
}
public VariableCollection(string name, string val):this(name, val, null, null)
{
}
public VariableCollection(string name, string val, IEnumerable<VariableCollection> subCollectionsEnum, IEnumerable<Variable> collectionEnum)
{
this.name = name;
this.val = val;
this.subCollectionsEnum = subCollectionsEnum;
this.collectionEnum = collectionEnum;
if (subCollectionsEnum != null) {
this.subCollectionsEnum = subCollectionsEnum;
} else {
this.subCollectionsEnum = new VariableCollection[0];
}
if (collectionEnum != null) {
this.collectionEnum = collectionEnum;
} else {
this.collectionEnum = new Variable[0];
}
}

18
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/ICorDebugGenericValue.cs

@ -12,6 +12,24 @@ namespace Debugger.Wrappers.CorDebug @@ -12,6 +12,24 @@ namespace Debugger.Wrappers.CorDebug
public partial class ICorDebugGenericValue
{
public unsafe Byte[] RawValue {
get {
Byte[] retValue = new Byte[(int)Size];
IntPtr pValue = Marshal.AllocHGlobal(retValue.Length);
GetValue(pValue);
Marshal.Copy(pValue, retValue, 0, retValue.Length);
Marshal.FreeHGlobal(pValue);
return retValue;
}
set {
if (Size != value.Length) throw new ArgumentException("Incorrect length");
IntPtr pValue = Marshal.AllocHGlobal(value.Length);
Marshal.Copy(value, 0, pValue, value.Length);
SetValue(pValue);
Marshal.FreeHGlobal(pValue);
}
}
public unsafe object Value {
get {
object retValue;

Loading…
Cancel
Save