Skip to content

Commit bebde89

Browse files
committed
Fix bug in user-defined container loaders. Element type expected to be the first template argument.
1 parent 9d56b2d commit bebde89

File tree

2 files changed

+73
-7
lines changed

2 files changed

+73
-7
lines changed

Visual_Studio_2017/GraphicalDebugging/ExpressionLoader_ContainerLoader.cs

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ abstract class ContainerLoader : Loader
3333
// With ReadArray knowing which memory copying optimizations can be made based on ElementLoader's type
3434
// Or not
3535

36-
// TODO: Move from here into specific classes
37-
virtual public string ElementType(string type)
38-
{
39-
List<string> tparams = Util.Tparams(type);
40-
return tparams.Count > 0 ? tparams[0] : "";
41-
}
42-
36+
abstract public string ElementType(string type);
4337
abstract public string ElementName(string name, string elemType);
4438
public delegate bool MemoryBlockPredicate(double[] values);
4539
abstract public bool ForEachMemoryBlock(MemoryReader mreader, Debugger debugger,
@@ -187,6 +181,12 @@ class StdArray : ContiguousContainer
187181
{
188182
public override string Id() { return "std::array"; }
189183

184+
public override string ElementType(string type)
185+
{
186+
List<string> tparams = Util.Tparams(type);
187+
return tparams.Count > 0 ? tparams[0] : "";
188+
}
189+
190190
public override string ElementName(string name, string elType)
191191
{
192192
return name + "._Elems[0]";
@@ -215,6 +215,12 @@ class BoostContainerVector : ContiguousContainer
215215
{
216216
public override string Id() { return "boost::container::vector"; }
217217

218+
public override string ElementType(string type)
219+
{
220+
List<string> tparams = Util.Tparams(type);
221+
return tparams.Count > 0 ? tparams[0] : "";
222+
}
223+
218224
public override string ElementName(string name, string elType)
219225
{
220226
return name + ".m_holder.m_start[0]";
@@ -267,6 +273,12 @@ public override int LoadSize(Debugger debugger, string name)
267273
return ExpressionParser.LoadSize(debugger, name + ".m_size");
268274
}
269275

276+
public override string ElementType(string type)
277+
{
278+
List<string> tparams = Util.Tparams(type);
279+
return tparams.Count > 0 ? tparams[0] : "";
280+
}
281+
270282
public override string ElementName(string name, string elType)
271283
{
272284
return "(*(" + name + ".m_first))";
@@ -359,6 +371,12 @@ public override string RandomAccessElementName(string rawName, int i)
359371
return FirstStr(rawName) + "[" + i + "]";
360372
}
361373

374+
public override string ElementType(string type)
375+
{
376+
List<string> tparams = Util.Tparams(type);
377+
return tparams.Count > 0 ? tparams[0] : "";
378+
}
379+
362380
public override string ElementName(string name, string elType)
363381
{
364382
return FirstStr(name) + "[0]";
@@ -399,6 +417,12 @@ class StdDeque : RandomAccessContainer
399417
{
400418
public override string Id() { return "std::deque"; }
401419

420+
public override string ElementType(string type)
421+
{
422+
List<string> tparams = Util.Tparams(type);
423+
return tparams.Count > 0 ? tparams[0] : "";
424+
}
425+
402426
public override string ElementName(string name, string elType)
403427
{
404428
return ElementStr(name, 0);
@@ -541,6 +565,12 @@ class StdList : ContainerLoader
541565
{
542566
public override string Id() { return "std::list"; }
543567

568+
public override string ElementType(string type)
569+
{
570+
List<string> tparams = Util.Tparams(type);
571+
return tparams.Count > 0 ? tparams[0] : "";
572+
}
573+
544574
public override string ElementName(string name, string elType)
545575
{
546576
return HeadStr(name) + "->_Next->_Myval";
@@ -657,6 +687,12 @@ class StdSet : ContainerLoader
657687
{
658688
public override string Id() { return "std::set"; }
659689

690+
public override string ElementType(string type)
691+
{
692+
List<string> tparams = Util.Tparams(type);
693+
return tparams.Count > 0 ? tparams[0] : "";
694+
}
695+
660696
public override string ElementName(string name, string elType)
661697
{
662698
return HeadStr(name) + "->_Myval";
@@ -845,6 +881,12 @@ public override string RandomAccessElementName(string rawName, int i)
845881
return rawName + "._items[" + i + "]";
846882
}
847883

884+
public override string ElementType(string type)
885+
{
886+
List<string> tparams = Util.Tparams(type);
887+
return tparams.Count > 0 ? tparams[0] : "";
888+
}
889+
848890
public override string ElementName(string name, string elType)
849891
{
850892
return name + "._items[0]";
@@ -869,6 +911,12 @@ class CSLinkedList : ContainerLoader
869911
{
870912
public override string Id() { return "System.Collections.Generic.LinkedList"; }
871913

914+
public override string ElementType(string type)
915+
{
916+
List<string> tparams = Util.Tparams(type);
917+
return tparams.Count > 0 ? tparams[0] : "";
918+
}
919+
872920
public override string ElementName(string name, string elType)
873921
{
874922
return name + ".head.item";

Visual_Studio_2017/GraphicalDebugging/ExpressionLoader_UserDefined.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,18 @@ public override void Initialize(Debugger debugger, string name)
3636
string type = ExpressionParser.GetValueType(debugger, name);
3737
exprPointer.Initialize(debugger, name, type);
3838
exprSize.Initialize(debugger, name, type);
39+
40+
string elemName = exprPointer.GetString(name) + "[0]";
41+
elemType = ExpressionParser.GetValueType(debugger, elemName);
3942
}
4043

4144
public override string Id() { return id; }
4245

46+
public override string ElementType(string type)
47+
{
48+
return elemType == null ? "" : elemType;
49+
}
50+
4351
public override string RandomAccessElementName(string rawName, int i)
4452
{
4553
return exprPointer.GetString(rawName) + "[" + i + "]";
@@ -58,6 +66,7 @@ public override int LoadSize(Debugger debugger, string name)
5866
string id;
5967
ClassScopeExpression exprPointer;
6068
ClassScopeExpression exprSize;
69+
string elemType;
6170
}
6271

6372
// TODO: The code is similar to std::list loader, unify if possible
@@ -85,10 +94,18 @@ public override void Initialize(Debugger debugger, string name)
8594
string headType = ExpressionParser.GetValueType(debugger, headName);
8695
exprNextPointer.Initialize(debugger, headName, headType);
8796
exprValue.Initialize(debugger, headName, headType);
97+
98+
string elemName = exprValue.GetString(headName);
99+
elemType = ExpressionParser.GetValueType(debugger, elemName);
88100
}
89101

90102
public override string Id() { return id; }
91103

104+
public override string ElementType(string type)
105+
{
106+
return elemType == null ? "" : elemType;
107+
}
108+
92109
public override string ElementName(string name, string elType)
93110
{
94111
// TODO: Only C++ ?
@@ -170,6 +187,7 @@ public override bool ForEachElement(Debugger debugger, string name, ElementPredi
170187
ClassScopeExpression exprNextPointer;
171188
ClassScopeExpression exprValue;
172189
ClassScopeExpression exprSize;
190+
string elemType;
173191
}
174192

175193
class UserPoint : PointLoader

0 commit comments

Comments
 (0)