Skip to content

Commit d73ef76

Browse files
committed
Fix loading of C++ generic types in VS2019
Caused by the change in the debugger returning generic types without spaces between >> characters and still requireing spaces in the input for GetExpression. Add DebuggerWrapper and custom CppExpression implementation returning normalized C++ types with spaces suitable for inputs.
1 parent 45e163b commit d73ef76

File tree

4 files changed

+150
-1
lines changed

4 files changed

+150
-1
lines changed

Visual_Studio_2017/GraphicalDebugging/ExpressionLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private ExpressionLoader(DTE2 dte)
7474
ThreadHelper.ThrowIfNotOnUIThread();
7575

7676
this.dte = dte;
77-
this.debugger = dte.Debugger;
77+
this.debugger = new Wrappers.DebuggerWrapper(dte.Debugger);
7878
this.debuggerEvents = this.dte.Events.DebuggerEvents;
7979
this.debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;
8080

Visual_Studio_2017/GraphicalDebugging/GraphicalDebugging.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
<Compile Include="Util.cs" />
119119
<Compile Include="VariableItem.cs" />
120120
<Compile Include="Viewport.cs" />
121+
<Compile Include="Wrappers.cs" />
121122
</ItemGroup>
122123
<ItemGroup>
123124
<None Include="packages.config">

Visual_Studio_2017/GraphicalDebugging/Util.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,21 @@ public static string TypeId(string type)
119119
return type;
120120
}
121121

122+
public static string CppNormalizeType(string type)
123+
{
124+
string result = "";
125+
char prev = '\0';
126+
foreach (char c in type)
127+
{
128+
if (c == '>' && prev == '>')
129+
result += " >";
130+
else
131+
result += c;
132+
prev = c;
133+
}
134+
return result;
135+
}
136+
122137
// TODO: Basic generic parameters
123138
public static List<string> TypesList(string type,
124139
char begCh = '<',
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
using EnvDTE;
2+
3+
namespace GraphicalDebugging
4+
{
5+
class Wrappers
6+
{
7+
public class CppExpression : Expression
8+
{
9+
public CppExpression(Expression expression)
10+
{
11+
this.expression = expression;
12+
this.normalizedType = Util.CppNormalizeType(expression.Type);
13+
}
14+
15+
private Expression expression;
16+
17+
public string Name => expression.Name;
18+
19+
public string Type { get { return this.normalizedType; } }
20+
21+
public Expressions DataMembers => expression.DataMembers;
22+
23+
public string Value { get => expression.Value; set => expression.Value = value; }
24+
25+
public bool IsValidValue => expression.IsValidValue;
26+
27+
public DTE DTE => expression.DTE;
28+
29+
public Debugger Parent => expression.Parent;
30+
31+
public Expressions Collection => expression.Collection;
32+
33+
private string normalizedType;
34+
}
35+
36+
public class DebuggerWrapper : Debugger
37+
{
38+
public DebuggerWrapper(Debugger debugger)
39+
{
40+
this.debugger = debugger;
41+
}
42+
private Debugger debugger;
43+
44+
public Expression GetExpression(string ExpressionText, bool UseAutoExpandRules = false, int Timeout = -1)
45+
{
46+
Expression expr = debugger.GetExpression(ExpressionText, UseAutoExpandRules, Timeout);
47+
return CurrentStackFrame.Language == "C++" ? new CppExpression(expr) : expr;
48+
}
49+
50+
public void DetachAll()
51+
{
52+
debugger.DetachAll();
53+
}
54+
55+
public void StepInto(bool WaitForBreakOrEnd = true)
56+
{
57+
debugger.StepInto(WaitForBreakOrEnd);
58+
}
59+
60+
public void StepOver(bool WaitForBreakOrEnd = true)
61+
{
62+
debugger.StepOver(WaitForBreakOrEnd);
63+
}
64+
65+
public void StepOut(bool WaitForBreakOrEnd = true)
66+
{
67+
debugger.StepOut(WaitForBreakOrEnd);
68+
}
69+
70+
public void Go(bool WaitForBreakOrEnd = true)
71+
{
72+
debugger.Go(WaitForBreakOrEnd);
73+
}
74+
75+
public void Break(bool WaitForBreakMode = true)
76+
{
77+
debugger.Break(WaitForBreakMode);
78+
}
79+
80+
public void Stop(bool WaitForDesignMode = true)
81+
{
82+
debugger.Stop(WaitForDesignMode);
83+
}
84+
85+
public void SetNextStatement()
86+
{
87+
debugger.SetNextStatement();
88+
}
89+
90+
public void RunToCursor(bool WaitForBreakOrEnd = true)
91+
{
92+
debugger.RunToCursor(WaitForBreakOrEnd);
93+
}
94+
95+
public void ExecuteStatement(string Statement, int Timeout = -1, bool TreatAsExpression = false)
96+
{
97+
debugger.ExecuteStatement(Statement, Timeout, TreatAsExpression);
98+
}
99+
100+
public void TerminateAll()
101+
{
102+
debugger.TerminateAll();
103+
}
104+
105+
public Breakpoints Breakpoints => debugger.Breakpoints;
106+
107+
public Languages Languages => debugger.Languages;
108+
109+
public dbgDebugMode CurrentMode => debugger.CurrentMode;
110+
111+
public Process CurrentProcess { get => debugger.CurrentProcess; set => debugger.CurrentProcess = value; }
112+
public Program CurrentProgram { get => debugger.CurrentProgram; set => debugger.CurrentProgram = value; }
113+
public Thread CurrentThread { get => debugger.CurrentThread; set => debugger.CurrentThread = value; }
114+
public StackFrame CurrentStackFrame { get => debugger.CurrentStackFrame; set => debugger.CurrentStackFrame = value; }
115+
public bool HexDisplayMode { get => debugger.HexDisplayMode; set => debugger.HexDisplayMode = value; }
116+
public bool HexInputMode { get => debugger.HexInputMode; set => debugger.HexInputMode = value; }
117+
118+
public dbgEventReason LastBreakReason => debugger.LastBreakReason;
119+
120+
public Breakpoint BreakpointLastHit => debugger.BreakpointLastHit;
121+
122+
public Breakpoints AllBreakpointsLastHit => debugger.AllBreakpointsLastHit;
123+
124+
public Processes DebuggedProcesses => debugger.DebuggedProcesses;
125+
126+
public Processes LocalProcesses => debugger.LocalProcesses;
127+
128+
public DTE DTE => debugger.DTE;
129+
130+
public DTE Parent => debugger.Parent;
131+
}
132+
}
133+
}

0 commit comments

Comments
 (0)