Skip to content

Commit

Permalink
Merge pull request #1339 from microsoft/main
Browse files Browse the repository at this point in the history
Merge 'main' into 'release-cpptools'
  • Loading branch information
WardenGnaw authored Aug 17, 2022
2 parents b4bbd66 + 802aa14 commit a034bbd
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 54 deletions.
2 changes: 1 addition & 1 deletion build/package_versions.settings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Microsoft_VisualStudio_Workspace_Version>15.0.392</Microsoft_VisualStudio_Workspace_Version>
<Microsoft_VisualStudio_Workspace_VSIntegration_Version>15.0.392</Microsoft_VisualStudio_Workspace_VSIntegration_Version>
<Microsoft_VisualStudio_TextManager_Interop_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_TextManager_Interop_Version>
<Microsoft_VSSDK_BuildTools_Version>17.0.1600</Microsoft_VSSDK_BuildTools_Version>
<Microsoft_VSSDK_BuildTools_Version>17.3.2093</Microsoft_VSSDK_BuildTools_Version>
<System_Runtime_Loader_Version>4.3.0</System_Runtime_Loader_Version>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion build/version.settings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--SxS: These three properties should be changed at the start of a new version, VersionZeroYear should be the year
before the start of the project.-->
<MajorVersion>17</MajorVersion>
<MinorVersion>1</MinorVersion>
<MinorVersion>4</MinorVersion>
<VersionZeroYear>2020</VersionZeroYear>
<!-- Note: for compatibility, we leave the default assembly version of the repo at 14.0.
If we ever decide to change this, make sure that you notify partner teams such as C++ IOT -->
Expand Down
13 changes: 7 additions & 6 deletions src/MIDebugEngine/Engine.Impl/Variables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,13 @@ private string StripFormatSpecifier(string exp, out string formatSpecifier)
// TODO: could return '(T(*)[n])(exp)' but requires T
var m = Regex.Match(trimmed, @"^\[?(\d+)\]?$");
if (m.Success)
{
if (_engine.DebuggedProcess.MICommandFactory.Mode == MIMode.Gdb)
return "*" + exp.Substring(0, lastComma) + "@" + trimmed; // this does not work for lldb

return exp.Substring(0, lastComma);
}


// array with dynamic size
if (Regex.Match(trimmed, @"^\[([a-zA-Z_][a-zA-Z_\d]*)\]$").Success)
Expand Down Expand Up @@ -518,13 +524,8 @@ internal async Task Eval(uint radix, enum_EVALFLAGS dwFlags = 0, DAPEvalFlags dw
string consoleResults = null;

consoleResults = await MIDebugCommandDispatcher.ExecuteCommand(consoleCommand, _debuggedProcess, ignoreFailures: true);
Value = String.Empty;
Value = consoleResults;
this.TypeName = null;

if (!String.IsNullOrEmpty(consoleResults))
{
_debuggedProcess.WriteOutput(consoleResults);
}
}
else
{
Expand Down
200 changes: 169 additions & 31 deletions src/MIDebugEngine/Natvis.Impl/Natvis.cs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/MIDebugEngine/ResourceStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/MIDebugEngine/ResourceStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
<data name="ModuleLoadedWithSymbols" xml:space="preserve">
<value>Symbols loaded.</value>
</data>
<data name="MoreView" xml:space="preserve">
<value>[More...]</value>
</data>
<data name="SymbolsLoadedInfo" xml:space="preserve">
<value>Symbols loaded - {0}</value>
</data>
Expand Down
4 changes: 3 additions & 1 deletion src/OpenDebugAD7/AD7DebugSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,6 @@ private void StepInternal(int threadId, enum_STEPKIND stepKind, SteppingGranular
}
}

BeforeContinue();
ErrorBuilder builder = new ErrorBuilder(() => errorMessage);
m_isStepping = true;

Expand All @@ -837,6 +836,9 @@ private void StepInternal(int threadId, enum_STEPKIND stepKind, SteppingGranular
m_isStopped = true;
throw;
}
// The program should now be stepping, so it is safe to discard the
// cached program state.
BeforeContinue();
}

private enum ClientId
Expand Down
57 changes: 47 additions & 10 deletions test/CppTests/Tests/NatvisTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,13 @@ public void TestIndexListItems(ITestSettings settings)

this.Comment("Verifying IndexListItems natvis");
var arr = currentFrame.GetVariable("arr");
Assert.Equal("{ size=15 }", arr.Value);
Assert.Equal("{ size=52 }", arr.Value);

// Index element for IndexListItems
// Natvis retrieves items in reverse order.
Assert.Equal("196", arr.GetVariable("[0]").Value);
Assert.Equal("16", arr.GetVariable("[10]").Value);
Assert.Equal("0", arr.GetVariable("[14]").Value);
// TODO: Add test below when we can support the [More..] expansion to handle >50 elements
Assert.Equal("2601", arr.GetVariable("[0]").Value);
Assert.Equal("1681", arr.GetVariable("[10]").Value);
Assert.Equal("0", arr.GetVariable("[More...]").GetVariable("[51]").Value);
}

runner.Expects.ExitedEvent(exitCode: 0).TerminatedEvent().AfterContinue();
Expand Down Expand Up @@ -168,14 +167,14 @@ public void TestArrayItems(ITestSettings settings)

this.Comment("Verifying ArrayItems natvis");
var ll = currentFrame.GetVariable("vec");
Assert.Equal("{ size=10 }", ll.Value);
Assert.Equal("{ size=52 }", ll.Value);

// Custom Item in natvis
Assert.Equal("10", ll.GetVariable("Size").Value);
Assert.Equal("52", ll.GetVariable("Size").Value);

// Index element for ArrayItems
Assert.Equal("20", ll.GetVariable("[5]").Value);
// TODO: Add test below when we can support the [More..] expansion to handle >50 elements
Assert.Equal("0", ll.GetVariable("[More...]").GetVariable("[51]").Value);
}

runner.Expects.ExitedEvent(exitCode: 0).TerminatedEvent().AfterContinue();
Expand Down Expand Up @@ -220,8 +219,7 @@ public void TestLinkedListItems(ITestSettings settings)

// Index element for LinkedListItems
Assert.Equal("5", ll.GetVariable("[5]").Value);
// TODO: Uncomment line below when we can support the [More..] expansion to handle >50 elements
// Assert.Equal("75", ll.GetVariable("[More...]").GetVariable("[75]").Value);
Assert.Equal("75", ll.GetVariable("[More...]").GetVariable("[75]").Value);
}

runner.Expects.ExitedEvent(exitCode: 0).TerminatedEvent().AfterContinue();
Expand Down Expand Up @@ -330,6 +328,45 @@ public void TestThisConditional(ITestSettings settings)
}
}

[Theory]
[DependsOnTest(nameof(CompileNatvisDebuggee))]
[RequiresTestSettings]
// Disable on macOS
[UnsupportedDebugger(SupportedDebugger.Lldb, SupportedArchitecture.x64 | SupportedArchitecture.x86)]
public void TestArrayPointer(ITestSettings settings)
{
this.TestPurpose("This test checks if the comma format specifier is visualized.");
this.WriteSettings(settings);

IDebuggee debuggee = Debuggee.Open(this, settings.CompilerSettings, NatvisName, DebuggeeMonikers.Natvis.Default);

this.Comment("Run the debuggee, check argument count");
using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
{
this.Comment("Configure launch");
LaunchCommand launch = new LaunchCommand(settings.DebuggerSettings, debuggee.OutputPath);
runner.RunCommand(launch);

this.Comment("Set Breakpoint");
SourceBreakpoints writerBreakpoints = debuggee.Breakpoints(NatvisSourceName, ReturnSourceLine);
runner.SetBreakpoints(writerBreakpoints);

runner.Expects.StoppedEvent(StoppedReason.Breakpoint).AfterConfigurationDone();

using (IThreadInspector threadInspector = runner.GetThreadInspector())
{
IFrameInspector currentFrame = threadInspector.Stack.First();

this.Comment("Verifying comma format specifier");
int[] expected = { 0, 1, 4, 9 };
currentFrame.AssertEvaluateAsIntArray("arr._array,4", EvaluateContext.Watch, expected);
}

runner.Expects.ExitedEvent(exitCode: 0).TerminatedEvent().AfterContinue();
runner.DisconnectAndVerify();
}
}

#endregion
}
}
6 changes: 3 additions & 3 deletions test/CppTests/debuggees/natvis/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char** argv)
{
SimpleDisplayObject obj_1;

SimpleVector vec(10);
SimpleVector vec(52);
vec.Set(5, 20);

SimpleLinkedList ll;
Expand All @@ -32,8 +32,8 @@ int main(int argc, char** argv)
map.Insert(4);
map.Insert(-72);

SimpleArray arr(15);
for (int i = 0 ; i < 15; i++)
SimpleArray arr(52);
for (int i = 0 ; i < 52; i++)
{
arr[i] = i * i;
}
Expand Down
2 changes: 1 addition & 1 deletion test/DebugAdapterRunner/DebugAdapterRunner.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<releaseNotes>https://go.microsoft.com/fwlink/?LinkID=746387</releaseNotes>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<dependencies>
<dependency id="Newtonsoft.Json" version="12.0.2" />
<dependency id="Newtonsoft.Json" version="13.0.1" />
</dependencies>
</metadata>
<files>
Expand Down

0 comments on commit a034bbd

Please sign in to comment.