Skip to content

Commit

Permalink
Implement memory access for C# List.
Browse files Browse the repository at this point in the history
  • Loading branch information
awulkiew committed Apr 25, 2019
1 parent 43dc8f3 commit cf63145
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions Visual_Studio_2015/GraphicalDebugging/ExpressionLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2540,11 +2540,7 @@ public override bool MatchType(string type, string id)

public override string ElementType(string type)
{
string name = "";
int begin = type.LastIndexOf('[');
if (begin > 0)
name = type.Substring(0, begin);
return name;
return ElemTypeFromType(type);
}

public override int LoadSize(Debugger debugger, string name)
Expand Down Expand Up @@ -2574,9 +2570,19 @@ public override bool ForEachMemoryBlock(Debugger debugger, string name, MemoryRe
ElementPtrName(name),
elementConverter, memoryBlockPredicate);
}

// type -> name[]
static public string ElemTypeFromType(string type)
{
string name = "";
int begin = type.LastIndexOf('[');
if (begin > 0 && begin + 1 < type.Length && type[begin + 1] == ']')
name = type.Substring(0, begin);
return name;
}
}

class CSList : RandomAccessContainer
class CSList : ContiguousContainer
{
public override string Id() { return "System.Collections.Generic.List"; }

Expand All @@ -2593,12 +2599,19 @@ public override int LoadSize(Debugger debugger, string name)

public override string ElementPtrName(string name)
{
return "";
return "(&" + name + "._items[0])";
}

public override bool ForEachMemoryBlock(Debugger debugger, string name, MemoryReader.Converter<double> elementConverter, MemoryBlockPredicate memoryBlockPredicate)
{
return false;
Expression expr = debugger.GetExpression(name + "._items");
if (!expr.IsValidValue || CSArray.ElemTypeFromType(expr.Type).Length <= 0)
return false;

return this.ForEachMemoryBlock(debugger,
name,
ElementPtrName(name),
elementConverter, memoryBlockPredicate);
}
}

Expand Down

0 comments on commit cf63145

Please sign in to comment.