-
Notifications
You must be signed in to change notification settings - Fork 236
Fix debugging with PSES pipeline thread changes #1574
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
Fix debugging with PSES pipeline thread changes #1574
Conversation
// Ensure the debugger mode is set correctly | ||
_debugContext.EnableDebugMode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required for remote debugging to work
@@ -44,7 +46,7 @@ internal class BreakpointService | |||
|
|||
public async Task<List<Breakpoint>> GetBreakpointsAsync() | |||
{ | |||
if (BreakpointApiUtils.SupportsBreakpointApis) | |||
if (_editorServicesHost.CurrentRunspace.PowerShellVersionDetails.Version >= s_minimumBreakpointApiVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure if this logic is correct -- ideally it should depend on the client not the remote. I'll need to try out the old logic and see if that works before we merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BreakpointApiUtils.SupportsBreakpointApis
should eventually be fixed to answer this question correctly.
else if ( | ||
e.ChangeAction == RunspaceChangeAction.Exit && false) | ||
// _powerShellContextService.IsDebuggerStopped) | ||
switch (e.ChangeAction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a style change
} | ||
} | ||
|
||
private void PowerShellContext_DebuggerResumed(object sender, DebuggerResumeAction e) | ||
private void PowerShellContext_DebuggerResuming(object sender, DebuggerResumingEventArgs e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably rename this method
@@ -408,7 +408,7 @@ public async Task<string> SetVariableAsync(int variableContainerReferenceId, str | |||
// Evaluate the expression to get back a PowerShell object from the expression string. | |||
// This may throw, in which case the exception is propagated to the caller | |||
PSCommand evaluateExpressionCommand = new PSCommand().AddScript(value); | |||
object expressionResult = (await _executionService.ExecutePSCommandAsync<object>(evaluateExpressionCommand, new PowerShellExecutionOptions(), CancellationToken.None)).FirstOrDefault(); | |||
object expressionResult = (await _executionService.ExecutePSCommandAsync<object>(evaluateExpressionCommand, CancellationToken.None)).FirstOrDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a ConfigureAwait(false)
src/PowerShellEditorServices/Services/PowerShell/Host/InternalHost.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Host/InternalHost.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Host/InternalHost.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
/* | ||
private void PopOrReinitializeRunspace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this as a sort of last ditch attempt to stop the extension from falling over when everything goes wrong. The code currently isn't compatible with the new implementation, so we should review it and decide whether it's worth keeping in any way or should just be gotten rid of
src/PowerShellEditorServices/Services/PowerShell/Host/PowerShellFactory.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/Extension/ExtensionService.cs
Outdated
Show resolved
Hide resolved
/// This behavior is unlikely to change and ensuring its correctness at our layer is likely to be costly. | ||
/// See https://stackoverflow.com/q/26472251. | ||
/// </remarks> | ||
internal class BlockingConcurrentDeque<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where this is used anywhere in this PR.
Also, should this not have a Dispose() method to clean up collections, event objects?
It is not clear to me what this is for, it would be nice to have comments illustrating its use.
src/PowerShellEditorServices/Services/PowerShell/Host/InternalHost.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add copyright headers
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs
Outdated
Show resolved
Hide resolved
Looking great! I did an initial run of feedback. It's mostly just a few missing Hopefully the "suggestions" work, haven't tried to add them from the VSCode PR extension yet. I'll also need to spend some time with the build and see how it all feels, but I'm loving the changes and it all looks very well done. Great work Rob! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it didn't submit the review with the comment. 🤷
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs
Outdated
Show resolved
Hide resolved
public SecureString ReadSecureLine() => ReadSecureLineAsync(CancellationToken.None).GetAwaiter().GetResult(); | ||
public string ReadLine(CancellationToken cancellationToken) | ||
{ | ||
return _psesHost.InvokeDelegate<string>(representation: "ReadLine", new ExecutionOptions { MustRunInForeground = true }, InvokePSReadLine, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making the delegate creation here static (assuming we can pass state in one of these parameters).
e.g.
static (@this, ct) => @this.InvokeReadLine(ct)
src/PowerShellEditorServices/Services/PowerShell/Execution/SynchronousPowerShellTask.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Execution/SynchronousTask.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Host/InternalHost.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Utility/PowerShellExtensions.cs
Outdated
Show resolved
Hide resolved
FYI the analyzer is enabled so if this is somewhat up to date with |
src/PowerShellEditorServices/Services/PowerShell/Debugging/DscBreakpointCapability.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Debugging/DscBreakpointCapability.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Debugging/PowerShellDebugContext.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Debugging/PowerShellDebugContext.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Execution/BlockingConcurrentDeque.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/Workspace/RemoteFileManagerService.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/Workspace/RemoteFileManagerService.cs
Outdated
Show resolved
Hide resolved
I'm going to merge this in now so we can continue work on the main branch, breaking out smaller work items into new PRs. You can see the changes I've made to address comments in individual commits, which will be preserved in the work branch by a merge commit. |
This PR moves the host REPL implementation off of its own thread and back into the host itself for a synchronous implementation. This makes the host more monolithic, but because of the required coupling of the internals of the host this is pretty hard to avoid (and trying to avoid it introduces other complexity). There's still some complexity here, both because the design itself is pretty big and hard to juggle, but also because some interfaces are deliberately separated out to try and not expose the host to everything.
With the REPL integrated back in, hooking up the debugger is simpler and is now done.