-
Notifications
You must be signed in to change notification settings - Fork 237
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
Changes from 51 commits
9e753a7
0f5f5e0
744fd88
0c21f19
4cc3f77
cdd4e3e
248008a
a001af4
b5b3325
5428be9
d3f8e01
502e4bb
9ddfd9c
942e7a6
ec9517f
d50ea57
22d6088
6883f1e
5fa2c4a
aaf27f7
d4ec378
b0af038
a1c94be
b5aab6e
b66cb0a
e8bc341
822f0cc
a08855f
797d38b
c8a691f
a6789aa
2d16735
b39e1fa
298cbf1
e9521ff
c9b782f
c39e298
fc4f0f4
fdb3ea3
bbf838c
fbdd818
bd07885
3207481
98272ff
2230ef9
bd19fae
1fd44f6
22868f6
09b962d
e19878a
c2797d1
0f62b1d
1a62125
0480ab6
1d1cab8
029539a
03f18aa
a07e7da
25d38a1
268eb5f
15b16f0
1e98e9c
d21efeb
543dabe
963fba1
f5b644e
905686c
0a69937
da786c8
fb08b67
1f52dde
27a1735
87022dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,10 @@ | |
using Microsoft.PowerShell.EditorServices.Handlers; | ||
using Microsoft.PowerShell.EditorServices.Services; | ||
using Microsoft.PowerShell.EditorServices.Services.PowerShell; | ||
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Console; | ||
using Microsoft.PowerShell.EditorServices.Utility; | ||
using OmniSharp.Extensions.DebugAdapter.Protocol; | ||
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization; | ||
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Debugging; | ||
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host; | ||
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Runspace; | ||
using OmniSharp.Extensions.DebugAdapter.Server; | ||
using OmniSharp.Extensions.JsonRpc; | ||
using OmniSharp.Extensions.LanguageServer.Server; | ||
|
||
namespace Microsoft.PowerShell.EditorServices.Server | ||
|
@@ -45,7 +43,7 @@ internal class PsesDebugServer : IDisposable | |
|
||
private DebugAdapterServer _debugAdapterServer; | ||
|
||
private PowerShellExecutionService _executionService; | ||
private PowerShellDebugContext _debugContext; | ||
|
||
protected readonly ILoggerFactory _loggerFactory; | ||
|
||
|
@@ -78,7 +76,8 @@ public async Task StartAsync() | |
{ | ||
// We need to let the PowerShell Context Service know that we are in a debug session | ||
// so that it doesn't send the powerShell/startDebugger message. | ||
_executionService = ServiceProvider.GetService<PowerShellExecutionService>(); | ||
_debugContext = ServiceProvider.GetService<PsesInternalHost>().DebugContext; | ||
_debugContext.IsDebugServerActive = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just FYI in master we had more logic added around this, so be careful when merging. |
||
|
||
/* | ||
rjmholt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Needed to make sure PSReadLine's static properties are initialized in the pipeline thread. | ||
|
@@ -99,10 +98,11 @@ public async Task StartAsync() | |
options | ||
.WithInput(_inputStream) | ||
.WithOutput(_outputStream) | ||
.WithServices(serviceCollection => serviceCollection | ||
.AddLogging() | ||
.AddOptions() | ||
.AddPsesDebugServices(ServiceProvider, this, _useTempSession)) | ||
.WithServices(serviceCollection => | ||
serviceCollection | ||
.AddLogging() | ||
.AddOptions() | ||
.AddPsesDebugServices(ServiceProvider, this, _useTempSession)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What a funny function... |
||
// TODO: Consider replacing all WithHandler with AddSingleton | ||
.WithHandler<LaunchAndAttachHandler>() | ||
.WithHandler<DisconnectHandler>() | ||
|
@@ -119,6 +119,9 @@ public async Task StartAsync() | |
// The OnInitialize delegate gets run when we first receive the _Initialize_ request: | ||
// https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize | ||
.OnInitialize(async (server, request, cancellationToken) => { | ||
// Ensure the debugger mode is set correctly - this is required for remote debugging to work | ||
_debugContext.EnableDebugMode(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment for self: want to see what this method does. |
||
|
||
var breakpointService = server.GetService<BreakpointService>(); | ||
// Clear any existing breakpoints before proceeding | ||
await breakpointService.RemoveAllBreakpointsAsync().ConfigureAwait(false); | ||
|
@@ -140,6 +143,10 @@ public async Task StartAsync() | |
|
||
public void Dispose() | ||
{ | ||
// Note that the lifetime of the DebugContext is longer than the debug server; | ||
// It represents the debugger on the PowerShell process we're in, | ||
// while a new debug server is spun up for every debugging session | ||
_debugContext.IsDebugServerActive = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I'm curious if we should make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's document that this is because the |
||
_debugAdapterServer.Dispose(); | ||
_inputStream.Dispose(); | ||
_outputStream.Dispose(); | ||
|
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.
Would like to know what race condition this indicated.