diff --git a/src/MIDebugEngine/AD7.Impl/AD7Thread.cs b/src/MIDebugEngine/AD7.Impl/AD7Thread.cs index 212845a2c..8d6f3c726 100644 --- a/src/MIDebugEngine/AD7.Impl/AD7Thread.cs +++ b/src/MIDebugEngine/AD7.Impl/AD7Thread.cs @@ -11,7 +11,7 @@ namespace Microsoft.MIDebugEngine { // This class implements IDebugThread2 which represents a thread running in a program. - internal class AD7Thread : IDebugThread2 + internal sealed class AD7Thread : IDebugThread2 { private readonly AD7Engine _engine; private readonly DebuggedThread _debuggedThread; diff --git a/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs b/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs index b0db63117..2fb0e41a5 100755 --- a/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs +++ b/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs @@ -25,7 +25,7 @@ internal class DebuggedProcess : MICore.Debugger public AD7Engine Engine { get; private set; } public List VariablesToDelete { get; private set; } public List ActiveVariables { get; private set; } - + public VariableInformation ReturnValue { get; private set; } public SourceLineCache SourceLineCache { get; private set; } public ThreadCache ThreadCache { get; private set; } public Disassembly Disassembly { get; private set; } @@ -1053,6 +1053,7 @@ private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest br varInfo.Dispose(); } this.ActiveVariables.Clear(); + ReturnValue = null; // already disposed above } ThreadCache.MarkDirty(); @@ -1235,8 +1236,19 @@ private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest br } } } - else if (reason == "end-stepping-range" || reason == "function-finished") + // step over/into + // NB: unfortunately this event does not provide a return value: https://sourceware.org/bugzilla/show_bug.cgi?id=26354 + else if (reason == "end-stepping-range") + _callback.OnStepComplete(thread); + // step out + else if (reason == "function-finished") { + string resultVar = results.Results.TryFindString("gdb-result-var"); // a gdb value history var like "$1" + if (!string.IsNullOrEmpty(resultVar)) + { + ReturnValue = new VariableInformation("$ReturnValue", resultVar, cxt, Engine, (AD7Thread)thread.Client, isParameter: false); + await ReturnValue.Eval(); + } _callback.OnStepComplete(thread); } else if (reason == "signal-received") @@ -1874,6 +1886,9 @@ internal async Task> GetLocalsAndParameters(AD7Thread variables.Add(vi); } + if (ReturnValue != null && ctx.Level == 0 && ReturnValue.Client.Id == thread.Id) + variables.Add(ReturnValue); + return variables; } diff --git a/src/MIDebugEngine/Engine.Impl/Variables.cs b/src/MIDebugEngine/Engine.Impl/Variables.cs index a5fcb0b7d..f24d82447 100644 --- a/src/MIDebugEngine/Engine.Impl/Variables.cs +++ b/src/MIDebugEngine/Engine.Impl/Variables.cs @@ -60,7 +60,7 @@ internal SimpleVariableInformation(string name, bool isParam = false, string val internal async Task CreateMIDebuggerVariable(ThreadContext ctx, AD7Engine engine, AD7Thread thread) { - VariableInformation vi = new VariableInformation(Name, ctx, engine, thread, IsParameter); + VariableInformation vi = new VariableInformation(Name, Name, ctx, engine, thread, IsParameter); await vi.Eval(); return vi; } @@ -73,7 +73,7 @@ public ArgumentList(int level, List args) { } } - internal class VariableInformation : IVariableInformation + internal sealed class VariableInformation : IVariableInformation { public string Name { get; private set; } public string Value { get; private set; } @@ -190,12 +190,12 @@ private VariableInformation(ThreadContext ctx, AD7Engine engine, AD7Thread threa } //this constructor is used to create root nodes (local/params) - internal VariableInformation(string expr, ThreadContext ctx, AD7Engine engine, AD7Thread thread, bool isParameter = false) + internal VariableInformation(string displayName, string expr, ThreadContext ctx, AD7Engine engine, AD7Thread thread, bool isParameter = false) : this(ctx, engine, thread) { // strip off formatting string _strippedName = StripFormatSpecifier(expr, out _format); - Name = expr; + Name = displayName; IsParameter = isParameter; _parent = null; VariableNodeType = NodeType.Root; diff --git a/src/MIDebugEngine/Natvis.Impl/Natvis.cs b/src/MIDebugEngine/Natvis.Impl/Natvis.cs index c0e4f3ecc..bcb1c1192 100755 --- a/src/MIDebugEngine/Natvis.Impl/Natvis.cs +++ b/src/MIDebugEngine/Natvis.Impl/Natvis.cs @@ -433,7 +433,7 @@ internal IVariableInformation GetVariable(string expr, AD7StackFrame frame) if (expr.EndsWith(",viz", StringComparison.Ordinal)) { expr = expr.Substring(0, expr.Length - 4); - variable = new VariableInformation(expr, frame.ThreadContext, frame.Engine, frame.Thread); + variable = new VariableInformation(expr, expr, frame.ThreadContext, frame.Engine, frame.Thread); variable.SyncEval(); if (!variable.Error) { @@ -442,7 +442,7 @@ internal IVariableInformation GetVariable(string expr, AD7StackFrame frame) } else { - variable = new VariableInformation(expr, frame.ThreadContext, frame.Engine, frame.Thread); + variable = new VariableInformation(expr, expr, frame.ThreadContext, frame.Engine, frame.Thread); } return variable; }