Skip to content

Commit de09daa

Browse files
authored
Change -stack-list-arguments call to be more performant in some cases (#673)
Made change to call -stack-list-arguments with --no-values when the value flag is not specified. This improves perf for large objects in stack walks but it does add an extra call per variable to -var-create and -var-delete to get the type. The calls to -var-create/-var-delete are faster overall than the -stack-list-arguments with --simple-values. If both value and types are requested, we fall back to requesting -stack-list-arguments with simple values which will return types and values.
1 parent 2c57666 commit de09daa

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ private List<LaunchCommand> GetInitializeCommands()
725725
{
726726
commands.Add(new LaunchCommand("-exec-arguments " + _launchOptions.ExeArguments));
727727
}
728-
728+
729729
Func<string, Task> breakMainSuccessHandler = (string bkptResult) =>
730730
{
731731
int index = bkptResult.IndexOf("number=", StringComparison.Ordinal);
@@ -749,7 +749,7 @@ private List<LaunchCommand> GetInitializeCommands()
749749
};
750750

751751
commands.Add(new LaunchCommand("-break-insert main", ignoreFailures: true, successHandler: breakMainSuccessHandler));
752-
752+
753753
if (null != localLaunchOptions)
754754
{
755755
string destination = localLaunchOptions.MIDebuggerServerAddress;
@@ -1064,7 +1064,7 @@ private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest br
10641064
TupleValue frame = results.Results.TryFind<TupleValue>("frame");
10651065
AD7BoundBreakpoint[] bkpt = _breakpointManager.FindHitBreakpoints(bkptno, addr, frame, out fContinue);
10661066

1067-
if (bkpt != null)
1067+
if (bkpt != null)
10681068
{
10691069
if (frame != null && addr != 0)
10701070
{
@@ -1229,7 +1229,7 @@ private async void OnEntrypointHit()
12291229
await ConsoleCmdAsync("process handle --pass true --stop false --notify false SIGHUP", true);
12301230
}
12311231

1232-
if(this._deleteEntryPointBreakpoint && !String.IsNullOrWhiteSpace(this._entryPointBreakpoint))
1232+
if (this._deleteEntryPointBreakpoint && !String.IsNullOrWhiteSpace(this._entryPointBreakpoint))
12331233
{
12341234
await MICommandFactory.BreakDelete(this._entryPointBreakpoint);
12351235
this._deleteEntryPointBreakpoint = false;
@@ -1747,7 +1747,8 @@ public async Task<List<SimpleVariableInformation>> GetParameterInfoOnly(AD7Threa
17471747
//NOTE: eval is not called
17481748
public async Task<List<ArgumentList>> GetParameterInfoOnly(AD7Thread thread, bool values, bool types, uint low, uint high)
17491749
{
1750-
var frames = await MICommandFactory.StackListArguments(values || types ? PrintValues.SimpleValues : PrintValues.NoValues, thread.Id, low, high);
1750+
// If values are requested, request simple values, otherwise we'll use -var-create to get the type of argument it is.
1751+
var frames = await MICommandFactory.StackListArguments(values ? PrintValues.SimpleValues : PrintValues.NoValues, thread.Id, low, high);
17511752
List<ArgumentList> parameters = new List<ArgumentList>();
17521753

17531754
foreach (var f in frames)
@@ -1771,13 +1772,31 @@ public async Task<List<ArgumentList>> GetParameterInfoOnly(AD7Thread thread, boo
17711772
string[] names = ((ResultListValue)argList).FindAllStrings("name");
17721773
foreach (var n in names)
17731774
{
1774-
args.Add(new SimpleVariableInformation(n, /*isParam*/ true, null, null));
1775+
// If the types of the arguments are requested, get that from a call to -var-create
1776+
if (types)
1777+
{
1778+
Debug.Assert(!values, "GetParameterInfoOnly should not reach here if values is true");
1779+
Results results = await MICommandFactory.VarCreate(n, thread.Id, (uint)level, 0);
1780+
1781+
string type = results.FindString("type");
1782+
args.Add(new SimpleVariableInformation(n, /*isParam*/ true, null, String.IsNullOrWhiteSpace(type) ? null : type));
1783+
1784+
string varName = results.TryFindString("name");
1785+
if (!String.IsNullOrWhiteSpace(varName))
1786+
{
1787+
// Remove the variable we created as we don't track it.
1788+
await MICommandFactory.VarDelete(varName);
1789+
}
1790+
}
1791+
else
1792+
{
1793+
args.Add(new SimpleVariableInformation(n, /*isParam*/ true, null, null));
1794+
}
17751795
}
17761796
}
17771797
}
17781798
parameters.Add(new ArgumentList(level, args));
17791799
}
1780-
17811800
return parameters;
17821801
}
17831802

0 commit comments

Comments
 (0)