Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The result of GDB -exec evaluate request in all contexts is printed in debug console. #1236

Closed
awulkiew opened this issue Oct 25, 2021 · 4 comments · Fixed by #1334
Closed

Comments

@awulkiew
Copy link

When vscode.DebugSession.customRequest('evaluate', ...) is called for expression starting with -exec the result is printed in debug console no matter what context was specified. It is not returned to the caller in DebugProtocol.EvaluateResponse.result. On the other hand if it doesn't start with -exec it is returned to the caller even if the context is 'repl'.

How to reproduce:

In vscode extension, registerDebugAdapterTrackerFactory, define onDidSendMessage and catch 'stopped' 'event'. Then get threadId and execute 'stackTrace' request to get frameId. Then call:

let exprArgs : DebugProtocol.EvaluateArguments = { expression: '-exec whatis name', frameId: frameId, context: 'watch' };
let test = await session.customRequest('evaluate', exprArgs);

with GDB and name being some identifier in C++ program.

@awulkiew
Copy link
Author

I'm not an expert but from looking at the code it looks like this is the place that is responsible:

if (EngineUtils.IsConsoleExecCmd(_strippedName, out string _, out string consoleCommand))
{
// special case for executing raw mi commands.
string consoleResults = null;
consoleResults = await MIDebugCommandDispatcher.ExecuteCommand(consoleCommand, _debuggedProcess, ignoreFailures: true);
Value = String.Empty;
this.TypeName = null;
if (!String.IsNullOrEmpty(consoleResults))
{
_debuggedProcess.WriteOutput(consoleResults);
}
}

Only EngineUtils.IsConsoleExecCmd is checked here while probably dwDAPFlags should've been checked here as well after appropriate flags were added to DAPEvalFlags here:
public enum DAPEvalFlags
{
/// <summary>
/// No additional Eval Flags from DAP
/// </summary>
NONE = 0,
/// <summary>
/// Evaluation is for a clipboard context
/// </summary>
CLIPBOARD_CONTEXT = 1
}

that correspond to the EvaluateArguments.ContextValue created here:
EvaluateArguments.ContextValue context = responder.Arguments.Context.GetValueOrDefault(EvaluateArguments.ContextValue.Unknown);

which should've probably be converted to DAPEvalFlags in this block as it is done with CLIPBOARD_CONTEXT:
{
DAPEvalFlags dapEvalFlags = DAPEvalFlags.NONE;
if (context == EvaluateArguments.ContextValue.Clipboard)
{
dapEvalFlags |= DAPEvalFlags.CLIPBOARD_CONTEXT;
}
hr = expressionDapObject.EvaluateSync(flags, dapEvalFlags, Constants.EvaluationTimeout, null, out property);
}

@awulkiew
Copy link
Author

FYI, I'm willing to work on a PR addressing this issue.

@tingleby
Copy link

tingleby commented Aug 8, 2022

We also have seen this behavior when working on an extension to enhance the debug session.

@WardenGnaw
Copy link
Member

We will be shipping this in the next VS Code Release 1.12.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants