-
Notifications
You must be signed in to change notification settings - Fork 223
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
Initial switch to breakpoint APIs #1119
Initial switch to breakpoint APIs #1119
Conversation
src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
Outdated
Show resolved
Hide resolved
Ah looks like I never wired up Actions at all :) still need to do that |
src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Debugging/BreakpointApiUtils.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/BreakpointHandlers.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/BreakpointHandlers.cs
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs
Outdated
Show resolved
Hide resolved
Honestly... After doing this, I kinda wanna rip out the As it is, Action breakpoints dont work at all. |
I might be remembering this wrong but in the old architecture, there was a bit of a wall between the protocol handlers specific to VSCode/LSP/DAP and the backend PSES "services" which could be used elsewhere apart from the LSP/DAP protocol. But since then the VSCode LSP is now standard (maybe DAP will be eventually) perhaps that separation isn't as important if you expect everyone to use PSES via LSP/DAP. |
I had the same thought -- think it's the right way to go |
ee287d1
to
ff35f29
Compare
ff35f29
to
23304a2
Compare
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.
Had two pending review comments apparently, also here's what's up with the hang on older versions.
src/PowerShellEditorServices/Services/DebugAdapter/Debugging/BreakpointApiUtils.cs
Outdated
Show resolved
Hide resolved
string globalHitCountVarName = | ||
$"$global:{s_psesGlobalVariableNamePrefix}BreakHitCounter_{breakpointHitCounter}"; | ||
|
||
builder.Insert(0, $"if (++{globalHitCountVarName} -eq {parsedHitCount}) {{ ") |
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 know this is out of scope of this PR, but man I'd love to see these global's removed. We should have a "visible but internal" static API that manages stuff like this I think. Something like:
namespace Whatever.EditorServices.Internal
{
[EditorBrowsable(EditorBrowsableState.Never)]
public static class BreakpointStateManager
{
[Hidden, EditorBrowsable(EditorBrowsableState.Never)]
public static bool TestHitCount(string hitCountKeyName, int parsedHitCount);
}
}
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs
Outdated
Show resolved
Hide resolved
I'm removing the WIP. Things seem to be working. |
@@ -18,6 +18,7 @@ | |||
using Microsoft.PowerShell.EditorServices.Services.TextDocument; | |||
using Microsoft.PowerShell.EditorServices.Services.PowerShellContext; | |||
using Microsoft.PowerShell.EditorServices.Services.DebugAdapter; | |||
using System.Collections.Concurrent; |
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.
Is this being used?
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.
removed.
1cab9ef
to
a29dd3c
Compare
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.
LGTM, just a couple requests.
Also I didn't see it in the list, but make sure watch expressions are tested in 7.
src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs
Outdated
Show resolved
Hide resolved
@@ -333,6 +341,12 @@ public async Task<Unit> Handle(PsesAttachRequestArguments request, CancellationT | |||
string debugRunspaceCmd; | |||
if (request.RunspaceName != null) | |||
{ | |||
var ids = await _powerShellContextService.ExecuteScriptStringAsync($"Get-Runspace -Name {request.RunspaceName} | % Id"); |
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.
Could this be switched to PSCommand?
new PSCommand()
.AddCommand("Microsoft.PowerShell.Utility\\Get-Runspace")
.AddParameter("Name", request.RunspaceName)
.AddCommand("Microsoft.PowerShell.Utility\\Select-Object")
.AddParameter("ExpandProperty", "Id")
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.
fixed
Here is an overview of what got changed by this pull request: Issues
======
+ Solved 4
Complexity increasing per file
==============================
- src/PowerShellEditorServices/Services/DebugAdapter/Debugging/BreakpointApiUtils.cs 10
- src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs 2
- src/PowerShellEditorServices/Services/DebugAdapter/Handlers/BreakpointHandlers.cs 1
- src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs 13
Clones removed
==============
+ src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs -2
See the complete overview on Codacy |
This moves to the new breakpoint APIs in PS 7 which enables the ability to debug actual untitled files!
This will also allow things like Azure Functions to not need a Wait-Debugger in their script.
I also accidentally supported Log Points!
To do this, I created a new service
BreakpointService
that helps manage this.I took a bunch of the reflection code from @rjmholt's branch of a similar feature.
NOTE: We should probably discuss the Function breakpoints feature... Today, it works in all versions of PowerShell by creating a temp file on the fly and using that for debugging. That doesn't seem like the best approach... because temp files could go south. Ideally we should use same strategy that I'm doing here for function breakpoints as well... but I feel like that's out of scope for this PR.
Testing checklist
lauch and attaches
Untitled files
Launch current file temp consolecan't be supported without a language server in the temp session... so fail nicelyBreakpoint types
Other