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

[Feature Request]: PowerShell support #69

Closed
TylerLeonhardt opened this issue Nov 2, 2019 · 19 comments
Closed

[Feature Request]: PowerShell support #69

TylerLeonhardt opened this issue Nov 2, 2019 · 19 comments
Labels
enhancement New feature or request help wanted Extra attention is needed Server support A debug server exists, test that it works, and document it

Comments

@TylerLeonhardt
Copy link

Describe the solution you'd like
This is the issue to discuss what we need to do to support PowerShell Editor Services PowerShell's language server and debug adapter.

Additional context
PowerShell Editor Services uses Named Pipes/unix domain sockets for the communication layer. This is because we typically have the LSP and DAP being used at the same time.

In vscode, we bridge stdio to the named pipes using this TypeScript file which acts as the "entry point" or "executable" for vscode.

I think we can leverage this as well for vimspector.

My ideal situation is to start PowerShell Editor Services up with either coc-powershell or YCM (which I'd love guidance on :)) and then connect to that using vimspector.

What do you think? 😄

@puremourning puremourning changed the title [Feature Request]: Short summary of request [Feature Request]: Powershell support Nov 2, 2019
@puremourning puremourning added enhancement New feature or request Server support A debug server exists, test that it works, and document it labels Nov 2, 2019
@puremourning
Copy link
Owner

puremourning commented Nov 2, 2019

Can the powershell adapter open a TCP port for the DAP channel? If so, vimspector can talk to it the same way it does the java adapter. #3

#3 (comment)

@puremourning
Copy link
Owner

Oh one more thing - vimspector (almost certainly) doesn't work on Windows.

@TylerLeonhardt TylerLeonhardt changed the title [Feature Request]: Powershell support [Feature Request]: PowerShell support Nov 2, 2019
@TylerLeonhardt
Copy link
Author

TylerLeonhardt commented Nov 2, 2019

Can the powershell adapter open a TCP port for the DAP channel?

Sadly no, we've found it to be a bit too insecure for our liking... We could have secured it... But Named Pipes made more sense considering PSES is on the same file system as the client and they're easy to secure.

Oh one more thing - vimspector (almost certainly) doesn't work on Windows.

That's ok, PowerShell works cross-platform 😎 I want to use this on my mac.

@TylerLeonhardt
Copy link
Author

It seems like we need to do something similar to Java. As a stopgap we can use the bridge. Essentially, PSES writes a tiny json file with the name of the pipe we need to connect to. The path to the session file might be hard to find, but that can be manual for now like the Java experience.

@puremourning
Copy link
Owner

puremourning commented Nov 2, 2019

That's ok, PowerShell works cross-platform

TIL. Thanks.

It seems like we need to do something similar to Java.

I guess we're limited to what vim's channels support. I haven't attempted to open a domain socket using ch_open, but I suppose it might be possible, by passing the path to the socket as the address.

It might just work if you use an adapter config like the java one:

{
  "adapters": { "PowerShell": { "port": "ask" } },
  "configurations": { "launch": { "adapter": "PowerShell", "configuration": { ... } }
}

Then when asked for the port, pass the path to the socket. I haven't tried this.

@puremourning
Copy link
Owner

OK well I tried it and it doesn't work. Doesn't look like ch_open can open a domain socket.

ch_open({address} [, {options}])				*ch_open()*
		Open a channel to {address}.  See |channel|.
		Returns a Channel.  Use |ch_status()| to check for failure.

		{address} has the form "hostname:port", e.g.,
		"localhost:8765".

@puremourning
Copy link
Owner

Well there's always a hack around....

ssh -L <port>:<domain socket> localhost

But it just crashed...

2019-11-02 19:26:25.576 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70059
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:26:26.003 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_5ilyxybh.mpg

2019-11-02 19:26:26.009 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_ml1kp4jd.p1m

2019-11-02 19:27:57.678 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70123
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:27:57.694 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_qfpq41tq.4rc

2019-11-02 19:27:57.699 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_3gnofqoh.t5q

2019-11-02 19:32:02.656 [NORMAL] tid:7 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70251
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:32:02.918 [NORMAL] tid:7 in 'Initialize' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 221
    PowerShell runtime version: 6.2.3, edition: Core

2019-11-02 19:32:03.489 [NORMAL] tid:7 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = Stdio, endpoint =  InOut pipe: 

2019-11-02 19:32:03.772 [ERROR] tid:14 in 'ExecuteCommand' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 565
    Execution of the following command(s) completed with errors:
    
        Import-Module /Users/ben/.vim/bundle/vimspector/gadgets/macos/PowerShellEditorServices/PowerShellEditorServices/bin/Core/..\..\Commands/PowerShellEditorServices.Commands.psd1
    
    

2019-11-02 19:32:53.704 [NORMAL] tid:7 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70310
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:32:53.722 [NORMAL] tid:7 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_5dsvos3t.20j

2019-11-02 19:32:53.727 [NORMAL] tid:7 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_nch4fn4r.uc4

2019-11-02 19:46:46.596 [NORMAL] tid:20 in 'Initialize' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 221
    PowerShell runtime version: 6.2.3, edition: Core

2019-11-02 19:46:47.276 [ERROR] tid:22 in 'OnListenTaskCompleted' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: line 391
    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.HandleStackTraceRequest(StackTraceRequestArguments stackTraceParams, RequestContext`1 requestContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.HandleStackTraceRequest(StackTraceRequestArguments stackTraceParams, RequestContext`1 requestContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---
    

2019-11-02 19:46:47.276 [ERROR] tid:22 in 'ProtocolEndpoint_UnhandledException' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 448
    PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.

2019-11-02 19:46:47.299 [ERROR] tid:1 in 'PopRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 2109
    Caller attempted to pop a runspace when no runspaces are on the stack.

2019-11-02 19:46:47.299 [ERROR] tid:1 in 'PopRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 2109
    Caller attempted to pop a runspace when no runspaces are on the stack.


@puremourning
Copy link
Owner

puremourning commented Nov 2, 2019

Vimspector session including messages:

2019-11-02 19:54:57,497 - INFO - Configuration: {"adapter": "PowerShell", "configuration": {"request": "launch", "Script": "/Users/ben/.vim/bundle/vimspector/support/test/powershell/test.ps1", "NoDebug": false, "StopOnEntry": true, "Args": [], "Cwd": "/Users/ben/.vim/bundle/vimspector/support/test/powershell", "CreateTemporaryIntegratedConsole": true, "Env": {}}}
2019-11-02 19:54:57,497 - INFO - Adapter: {"name": "PowerShell", "port": "ask", "type": "PowerShell"}
2019-11-02 19:54:57,551 - INFO - Starting debug adapter with: {"name": "PowerShell", "port": "ask", "type": "PowerShell"}
2019-11-02 19:55:00,752 - INFO - Debug Adapter Started
2019-11-02 19:55:00,752 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "PowerShell", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2019-11-02 19:55:00,938 - DEBUG - Message received: {'type': 'response', 'request_seq': 0, 'command': 'initialize', 'success': True, 'body': {'supportsConfigurationDoneRequest': True, 'supportsFunctionBreakpoints': True, 'supportsConditionalBreakpoints': True, 'supportsHitConditionalBreakpoints': True, 'supportsEvaluateForHovers': False, 'supportsSetVariable': True}}
2019-11-02 19:55:00,939 - DEBUG - LAUNCH!
2019-11-02 19:55:00,939 - DEBUG - Sending Message: {"command": "launch", "arguments": {"request": "launch", "Script": "/Users/ben/.vim/bundle/vimspector/support/test/powershell/test.ps1", "NoDebug": false, "StopOnEntry": true, "Args": [], "Cwd": "/Users/ben/.vim/bundle/vimspector/support/test/powershell", "CreateTemporaryIntegratedConsole": true, "Env": {}, "name": "test"}, "seq": 1, "type": "request"}
2019-11-02 19:55:00,956 - DEBUG - Message received: {'type': 'response', 'request_seq': 1, 'command': 'launch', 'success': True, 'body': None}
2019-11-02 19:55:00,962 - DEBUG - Message received: {'type': 'event', 'event': 'initialized', 'body': None}
2019-11-02 19:55:00,962 - DEBUG - Sending Message: {"command": "setFunctionBreakpoints", "arguments": {"breakpoints": []}, "seq": 2, "type": "request"}
2019-11-02 19:55:00,980 - DEBUG - Message received: {'type': 'response', 'request_seq': 2, 'command': 'setFunctionBreakpoints', 'success': True, 'body': {'breakpoints': []}}
2019-11-02 19:55:00,981 - DEBUG - Breakpoints at this point: {}
2019-11-02 19:55:00,981 - DEBUG - Sending Message: {"command": "configurationDone", "seq": 3, "type": "request"}
2019-11-02 19:55:00,996 - DEBUG - Message received: {'type': 'response', 'request_seq': 3, 'command': 'configurationDone', 'success': True, 'body': None}
2019-11-02 19:55:00,996 - DEBUG - Sending Message: {"command": "threads", "seq": 4, "type": "request"}
2019-11-02 19:55:01,003 - DEBUG - Message received: {'type': 'response', 'request_seq': 4, 'command': 'threads', 'success': True, 'body': {'threads': [{'id': 1, 'name': 'Main Thread'}]}}
2019-11-02 19:55:01,004 - DEBUG - Sending Message: {"command": "stackTrace", "arguments": {"threadId": 1}, "seq": 5, "type": "request"}
2019-11-02 19:55:01,016 - DEBUG - Message received: {'type': 'event', 'event': 'terminated', 'body': {'restart': False}}
2019-11-02 19:55:01,016 - INFO - User Msg: Debugging was terminated by the server.
2019-11-02 19:55:01,074 - INFO - The server has terminated with status 0
2019-11-02 19:55:01,074 - DEBUG - Closing down: Aborting request {'command': 'stackTrace', 'arguments': {'threadId': 1}, 'seq': 5, 'type': 'request'}
2019-11-02 19:55:01,075 - INFO - User Msg: Request for stackTrace aborted: Closing down
2019-11-02 19:55:01,075 - DEBUG - No server exit handler

@puremourning
Copy link
Owner

With verbose output:

2019-11-02 19:26:25.576 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70059
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:26:26.003 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_5ilyxybh.mpg

2019-11-02 19:26:26.009 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_ml1kp4jd.p1m

2019-11-02 19:27:57.678 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70123
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:27:57.694 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_qfpq41tq.4rc

2019-11-02 19:27:57.699 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_3gnofqoh.t5q

2019-11-02 19:32:02.656 [NORMAL] tid:7 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70251
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:32:02.918 [NORMAL] tid:7 in 'Initialize' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 221
    PowerShell runtime version: 6.2.3, edition: Core

2019-11-02 19:32:03.489 [NORMAL] tid:7 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = Stdio, endpoint =  InOut pipe: 

2019-11-02 19:32:03.772 [ERROR] tid:14 in 'ExecuteCommand' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 565
    Execution of the following command(s) completed with errors:
    
        Import-Module /Users/ben/.vim/bundle/vimspector/gadgets/macos/PowerShellEditorServices/PowerShellEditorServices/bin/Core/..\..\Commands/PowerShellEditorServices.Commands.psd1
    
    

2019-11-02 19:32:53.704 [NORMAL] tid:7 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70310
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:32:53.722 [NORMAL] tid:7 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_5dsvos3t.20j

2019-11-02 19:32:53.727 [NORMAL] tid:7 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_nch4fn4r.uc4

2019-11-02 19:46:46.596 [NORMAL] tid:20 in 'Initialize' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 221
    PowerShell runtime version: 6.2.3, edition: Core

2019-11-02 19:46:47.276 [ERROR] tid:22 in 'OnListenTaskCompleted' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: line 391
    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.HandleStackTraceRequest(StackTraceRequestArguments stackTraceParams, RequestContext`1 requestContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.HandleStackTraceRequest(StackTraceRequestArguments stackTraceParams, RequestContext`1 requestContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---
    

2019-11-02 19:46:47.276 [ERROR] tid:22 in 'ProtocolEndpoint_UnhandledException' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 448
    PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.

2019-11-02 19:46:47.299 [ERROR] tid:1 in 'PopRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 2109
    Caller attempted to pop a runspace when no runspaces are on the stack.

2019-11-02 19:46:47.299 [ERROR] tid:1 in 'PopRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 2109
    Caller attempted to pop a runspace when no runspaces are on the stack.

2019-11-02 19:53:52.294 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70642
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 19:53:52.310 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_5ydspxyt.ro2

2019-11-02 19:53:52.315 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_qha2j5de.urf

2019-11-02 19:55:00.788 [NORMAL] tid:19 in 'Initialize' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 221
    PowerShell runtime version: 6.2.3, edition: Core

2019-11-02 19:55:01.028 [ERROR] tid:23 in 'OnListenTaskCompleted' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: line 391
    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.HandleStackTraceRequest(StackTraceRequestArguments stackTraceParams, RequestContext`1 requestContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.HandleStackTraceRequest(StackTraceRequestArguments stackTraceParams, RequestContext`1 requestContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---
    

2019-11-02 19:55:01.028 [ERROR] tid:23 in 'ProtocolEndpoint_UnhandledException' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 448
    PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.

2019-11-02 19:55:01.061 [ERROR] tid:1 in 'PopRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 2109
    Caller attempted to pop a runspace when no runspaces are on the stack.

2019-11-02 19:55:01.061 [ERROR] tid:1 in 'PopRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 2109
    Caller attempted to pop a runspace when no runspaces are on the stack.

2019-11-02 20:01:29.620 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70753
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 20:01:29.634 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_qvus5wma.ldi

2019-11-02 20:01:29.639 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_4jtm325u.rqi

2019-11-02 20:03:15.647 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70865
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 20:03:15.667 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_ln5vw4ax.r4w

2019-11-02 20:03:15.672 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_g2zry2bd.1d4

2019-11-02 20:03:44.080 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70923
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 20:03:44.096 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_1nvx2gfv.rro

2019-11-02 20:03:44.102 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_zjaboquw.1x1

2019-11-02 20:07:25.350 [NORMAL] tid:7 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 70967
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 20:07:25.365 [NORMAL] tid:7 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_2jm5ndw4.apk

2019-11-02 20:07:25.369 [NORMAL] tid:7 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_w0afti3f.jjc

2019-11-02 20:09:08.544 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 71072
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 20:09:08.566 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_asq11nbu.0wc

2019-11-02 20:09:08.572 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_iyo541oj.5mk

2019-11-02 20:10:28.485 [NORMAL] tid:15 in 'StartLogging' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 183
    
    PowerShell Editor Services Host v1.13.0.0 starting (PID 71169
    
      Host application details:
    
        Name:      My Client
        Version:   1.0.0
        ProfileId: myclient
        Arch:      X64
    
      Operating system details:
    
        Version: Darwin 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
        Arch:    X64
    
      Build information:
    
        Version: 
        Origin:  VSTS
        Date:    2019-09-20T23:36:27
    

2019-11-02 20:10:28.500 [NORMAL] tid:15 in 'StartLanguageService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 202
    Language service started, type = NamedPipe, endpoint =  InOut pipe: PSES_45sk4le2.vpr

2019-11-02 20:10:28.506 [NORMAL] tid:15 in 'StartDebugService' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 279
    Debug service started, type = NamedPipe, endpoint =  InOut pipe: PSES_ipzrymni.azx

2019-11-02 20:10:40.800 [NORMAL] tid:10 in 'Initialize' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 221
    PowerShell runtime version: 6.2.3, edition: Core

2019-11-02 20:10:40.846 [VERBOSE] tid:10 in 'SetExecutionPolicy' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 1629
    Current execution policy: ExecutionPolicy.Unrestricted

2019-11-02 20:10:40.848 [VERBOSE] tid:10 in 'SetProfileVariableInCurrentRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 1747
    Setting $profile variable in runspace.  Current user host profile path: /Users/ben/.config/powershell/myclient_profile.ps1

2019-11-02 20:10:40.935 [VERBOSE] tid:20 in 'ReadMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'initialize' with id 0

2019-11-02 20:10:40.951 [VERBOSE] tid:20 in 'ExecuteCommand' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 492
    Attempting to execute command(s):
    
        Microsoft.PowerShell.Utility\Get-PSBreakpoint
        Microsoft.PowerShell.Utility\Remove-PSBreakpoint
    

2019-11-02 20:10:40.955 [VERBOSE] tid:10 in 'OnSessionStateChanged' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 1311
    Session state changed --
    
        Old state: Ready
        New state: Running
        Result: NotFinished

2019-11-02 20:10:40.957 [VERBOSE] tid:10 in 'OnSessionStateChanged' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 1311
    Session state changed --
    
        Old state: Running
        New state: Ready
        Result: Completed

2019-11-02 20:10:40.961 [VERBOSE] tid:20 in 'ExecuteCommand' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 571
    Execution completed successfully.

2019-11-02 20:10:40.975 [VERBOSE] tid:20 in 'WriteMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Response 'initialize' with id 0

2019-11-02 20:10:40.984 [VERBOSE] tid:20 in 'ReadMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'launch' with id 1

2019-11-02 20:10:40.997 [VERBOSE] tid:20 in 'HandleLaunchRequest' D:\a\1\s\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: line 300
    Working dir set to '/Users/ben/.vim/bundle/vimspector/support/test/powershell'

2019-11-02 20:10:40.998 [VERBOSE] tid:20 in 'WriteMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Response 'launch' with id 1

2019-11-02 20:10:41.003 [VERBOSE] tid:20 in 'WriteMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Event 'initialized'

2019-11-02 20:10:41.005 [VERBOSE] tid:20 in 'ReadMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'setFunctionBreakpoints' with id 2

2019-11-02 20:10:41.013 [VERBOSE] tid:20 in 'ExecuteCommand' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 492
    Attempting to execute command(s):
    
        Microsoft.PowerShell.Utility\Get-PSBreakpoint -Type Command
        Microsoft.PowerShell.Utility\Remove-PSBreakpoint
    

2019-11-02 20:10:41.013 [VERBOSE] tid:10 in 'OnSessionStateChanged' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 1311
    Session state changed --
    
        Old state: Ready
        New state: Running
        Result: NotFinished

2019-11-02 20:10:41.015 [VERBOSE] tid:10 in 'OnSessionStateChanged' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 1311
    Session state changed --
    
        Old state: Running
        New state: Ready
        Result: Completed

2019-11-02 20:10:41.017 [VERBOSE] tid:20 in 'ExecuteCommand' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 571
    Execution completed successfully.

2019-11-02 20:10:41.022 [VERBOSE] tid:20 in 'WriteMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Response 'setFunctionBreakpoints' with id 2

2019-11-02 20:10:41.029 [VERBOSE] tid:20 in 'ReadMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'configurationDone' with id 3

2019-11-02 20:10:41.036 [VERBOSE] tid:20 in 'ExecuteCommand' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 492
    Attempting to execute command(s):
    
        /Users/ben/.vim/bundle/vimspector/support/test/powershell/test.ps1
        Out-Default
    

2019-11-02 20:10:41.036 [VERBOSE] tid:7 in 'OnSessionStateChanged' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 1311
    Session state changed --
    
        Old state: Ready
        New state: Running
        Result: NotFinished

2019-11-02 20:10:41.037 [VERBOSE] tid:20 in 'WriteMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Response 'configurationDone' with id 3

2019-11-02 20:10:41.039 [VERBOSE] tid:20 in 'ReadMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'threads' with id 4

2019-11-02 20:10:41.044 [VERBOSE] tid:7 in 'OnSessionStateChanged' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 1311
    Session state changed --
    
        Old state: Running
        New state: Ready
        Result: Completed

2019-11-02 20:10:41.045 [VERBOSE] tid:20 in 'WriteMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Response 'threads' with id 4

2019-11-02 20:10:41.047 [VERBOSE] tid:20 in 'ExecuteCommand' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 571
    Execution completed successfully.

2019-11-02 20:10:41.051 [VERBOSE] tid:20 in 'ReadMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'stackTrace' with id 5

2019-11-02 20:10:41.052 [VERBOSE] tid:7 in 'OnExecutionCompleted' D:\a\1\s\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: line 117
    Execution completed, terminating...

2019-11-02 20:10:41.057 [VERBOSE] tid:20 in 'WriteMessage' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Event 'terminated'

2019-11-02 20:10:41.057 [VERBOSE] tid:7 in 'Post' D:\a\1\s\src\PowerShellEditorServices\Utility\ThreadSynchronizationContext.cs: line 64
    Attempted to post message to synchronization context after it's already completed

2019-11-02 20:10:41.070 [ERROR] tid:7 in 'OnListenTaskCompleted' D:\a\1\s\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: line 391
    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.HandleStackTraceRequest(StackTraceRequestArguments stackTraceParams, RequestContext`1 requestContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.HandleStackTraceRequest(StackTraceRequestArguments stackTraceParams, RequestContext`1 requestContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---
    

2019-11-02 20:10:41.071 [ERROR] tid:7 in 'ProtocolEndpoint_UnhandledException' D:\a\1\s\src\PowerShellEditorServices.Host\EditorServicesHost.cs: line 448
    PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.

2019-11-02 20:10:41.088 [ERROR] tid:1 in 'PopRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 2109
    Caller attempted to pop a runspace when no runspaces are on the stack.

2019-11-02 20:10:41.088 [ERROR] tid:1 in 'PopRunspace' D:\a\1\s\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 2109
    Caller attempted to pop a runspace when no runspaces are on the stack.

@TylerLeonhardt
Copy link
Author

Can you share with me how you started PSES?

@puremourning
Copy link
Owner

puremourning commented Nov 2, 2019

@TylerLeonhardt sure thing. I used the following 2 scripts:

  • run
#!/usr/bin/env bash

PSES_BUNDLE_PATH=$HOME/.vim/bundle/vimspector/gadgets/macos/PowerShellEditorServices
SESSION_TEMP_PATH=$(pwd)

pwsh -NoProfile \
     -Command \
       "$PSES_BUNDLE_PATH/PowerShellEditorServices/Start-EditorServices.ps1 \
        -BundledModulesPath $PSES_BUNDLE_PATH \
        -LogPath $SESSION_TEMP_PATH/logs.log \
        -SessionDetailsPath $SESSION_TEMP_PATH/session.json \
        -FeatureFlags @() \
        -AdditionalModules @() \
        -HostName 'My Client' \
        -HostProfileId 'myclient' \
        -HostVersion 1.0.0 \
        -LogLevel Verbose"
  • connect
#!/usr/bin/env bash

PIPE=$(python -c 'import json; print( json.load( open( "session.json" ))["debugServicePipeName"] )')

ssh -L 4321:$PIPE localhost

And the following .vimspector.json (using 4321 as the port when asked):

{
  "configurations": {
    "launch": {
      "adapter": "PowerShell",
      "configuration": {
        "request": "launch",
        "Script": "${file}",
        "NoDebug": false,
        "StopOnEntry": true,
        "Args": [],
        "Cwd": "${workspaceRoot}",
        "CreateTemporaryIntegratedConsole": true,
        "Env": {}
      }
    }
  }
}

And the following modification to install_gadget.py:

diff --git a/install_gadget.py b/install_gadget.py
index 6da3b35..8248559 100755
--- a/install_gadget.py
+++ b/install_gadget.py
@@ -128,7 +128,8 @@ GADGETS = {
     },
     'macos': {
       'file_name': 'netcoredbg-osx-master.tar.gz',
-      'checksum': '',
+      'checksum':
+        '775c588b0b9acd86318d0c9e8a4af37f74e0bafb8d0564df410f687872d6f7d3',
     },
     'linux': {
       'file_name': 'netcoredbg-linux-master.tar.gz',
@@ -260,6 +261,32 @@ GADGETS = {
       },
     },
   },
+  'PowerShellEditorServices': {
+    'language': 'powershell',
+    'enabled': False,
+    'download': {
+      'url': 'https://github.com/PowerShell/PowerShellEditorServices/releases/'
+             'download/v${version}/PowerShellEditorServices.zip',
+      'format': 'zip',
+    },
+    'do': ( lambda name, root:
+              MakeSymlink( gadget_dir,
+                           name,
+                           os.path.join( root, 'PowerShellEditorServices' ) ) ),
+    'all': {
+      'version': '1.13.0',
+      'file_name': 'PowerShellEditorServices.zip',
+      'checksum':
+        'd10bda5c7d36795bb8f860b2d09a637f8f98ee401c60ac4c40a636f8606565b9'
+    },
+    'adapters': {
+      'PowerShell': {
+        'name': 'PowerShell',
+        'type': 'PowerShell',
+        'port': 'ask',
+      },
+    },
+  }
 }


@@ -453,7 +480,8 @@ class ModePreservingZipFile( zipfile.ZipFile ):

     ret_val = self._extract_member( member, path, pwd )
     attr = member.external_attr >> 16
-    os.chmod( ret_val, attr )
+    if attr:
+      os.chmod( ret_val, attr )
     return ret_val

@TylerLeonhardt
Copy link
Author

Ah! That's with the LSP mode on as well (default behavior). Can you try with adding the -DebugServiceOnly

@puremourning
Copy link
Owner

When I add that I get this:

chmod: /var/folders/s3/v5q17n8532x05nn495s125yh0000gn/T/CoreFxPipe_P
SES_tvkz5ccu.dun: No such file or directory
stat: /var/folders/s3/v5q17n8532x05nn495s125yh0000gn/T/CoreFxPipe_PS
ES_tvkz5ccu.dun: stat: No such file or directory


Permissions to the pipe file were not set properly. Expected: 600 Ac
tual:  for file: /var/folders/s3/v5q17n8532x05nn495s125yh0000gn/T/Co
reFxPipe_PSES_tvkz5ccu.dun
                                   

Without the flag it doesn't print that.

puremourning added a commit that referenced this issue Nov 2, 2019
Doeesn't work due to debugger crashing on stack trace request.

Related #69
@puremourning
Copy link
Owner

pushed the changes with the files in case you want to try it.

@TylerLeonhardt
Copy link
Author

TylerLeonhardt commented Nov 2, 2019

You know what, I think the latest release is kinda broken for "debug only" on non-Windows. We're doing a preview release on Monday with all of that fixed.

I can give this a go. I'm currently on vacation, but I promise as soon as I get back I'll be more helpful 😅

Thanks for all your interest so far, I am excited to set this all up!

@TylerLeonhardt
Copy link
Author

TylerLeonhardt commented Nov 18, 2019

@puremourning hi! Finally got around to trying this... I'm having trouble getting vimspector working...

Error detected while processing function vimspector#internal#state#Reset:
line    1:
E319: Sorry, the command is not available in this version:     py3 << EOF
Error detected while processing function vimspector#Continue:
line    1:

I have python3 installed... perhaps I'm missing something?

@puremourning
Copy link
Owner

Your vim has to be compiled with python 3 support.

@zoechi
Copy link

zoechi commented Nov 29, 2019

Your vim has to be compiled with python 3 support.

How to do that? (sorry, pretty new to this "suff")
I get the same error.

Edit

Debian provides VIm with Python3 support as vim-nox package.

@puremourning puremourning added the help wanted Extra attention is needed label Jan 9, 2020
@puremourning
Copy link
Owner

https://github.com/puremourning/vimspector/wiki/languages

I'm unlikely to add further niche languages as core features. Rather community-maintained plugin files above.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed Server support A debug server exists, test that it works, and document it
Projects
None yet
Development

No branches or pull requests

3 participants