Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,11 @@ public Guid InstanceId
}

/// <summary>
/// The optional breakpoint objects to use for debugging.
/// Gets or sets a flag that tells PowerShell to automatically perform a BreakAll when the debugger is attached to the remote target.
/// </summary>
[Experimental("Microsoft.PowerShell.Utility.PSDebugRunspaceWithBreakpoints", ExperimentAction.Show)]
[Parameter(Position = 1,
ParameterSetName = DebugRunspaceCommand.InstanceIdParameterSet)]
[Parameter(ParameterSetName = DebugRunspaceCommand.RunspaceParameterSet)]
[Parameter(ParameterSetName = DebugRunspaceCommand.IdParameterSet)]
[Parameter(ParameterSetName = DebugRunspaceCommand.NameParameterSet)]
public Breakpoint[] Breakpoint
{
get;
set;
}
[Experimental("Microsoft.PowerShell.Utility.PSManageBreakpointsInRunspace", ExperimentAction.Show)]
[Parameter]
public SwitchParameter BreakAll { get; set; }

#endregion

Expand Down Expand Up @@ -275,7 +267,7 @@ private void WaitAndReceiveRunspaceOutput()
_debugger.SetDebugMode(DebugModes.LocalScript | DebugModes.RemoteScript);

// Set up host script debugger to debug the runspace.
_debugger.DebugRunspace(_runspace, disableBreakAll: Breakpoint?.Length > 0);
_debugger.DebugRunspace(_runspace, breakAll: BreakAll);

while (_debugging)
{
Expand Down Expand Up @@ -532,10 +524,6 @@ private void PrepareRunspace(Runspace runspace)
{
SetLocalMode(runspace.Debugger, true);
EnableHostDebugger(runspace, false);
if (Breakpoint?.Length > 0)
{
runspace.Debugger?.SetBreakpoints(Breakpoint);
}
}

private void RestoreRunspace(Runspace runspace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,22 +350,6 @@ public SwitchParameter BreakAll
set;
}

/// <summary>
/// Gets or sets the optional breakpoint objects to use for debugging.
/// </summary>
[Experimental("Microsoft.PowerShell.Utility.PSDebugRunspaceWithBreakpoints", ExperimentAction.Show)]
[Parameter(Position = 1,
ParameterSetName = CommonRunspaceCommandBase.RunspaceParameterSet)]
[Parameter(Position = 1,
ParameterSetName = CommonRunspaceCommandBase.RunspaceNameParameterSet)]
[Parameter(Position = 1,
ParameterSetName = CommonRunspaceCommandBase.RunspaceIdParameterSet)]
public Breakpoint[] Breakpoint
{
get;
set;
}

#endregion

#region Overrides
Expand Down Expand Up @@ -428,12 +412,6 @@ protected override void ProcessRecord()
debugger.SetDebuggerStepMode(false);
}
}

// If any breakpoints were provided, set those in the debugger.
if (Breakpoint?.Length > 0)
{
debugger.SetBreakpoints(Breakpoint);
}
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ protected override void ProcessRecord()
foreach (string path in scripts)
{
WriteObject(
Context.Debugger.NewCommandBreakpoint(path.ToString(), Command[i], Action));
Context.Debugger.SetCommandBreakpoint(Command[i], Action, path));
}
}
else
{
WriteObject(
Context.Debugger.NewCommandBreakpoint(Command[i], Action));
Context.Debugger.SetCommandBreakpoint(Command[i], Action));
}
}
}
Expand All @@ -97,13 +97,13 @@ protected override void ProcessRecord()
foreach (string path in scripts)
{
WriteObject(
Context.Debugger.NewVariableBreakpoint(path.ToString(), Variable[i], Mode, Action));
Context.Debugger.SetVariableBreakpoint(Variable[i], Mode, Action, path));
}
}
else
{
WriteObject(
Context.Debugger.NewVariableBreakpoint(Variable[i], Mode, Action));
Context.Debugger.SetVariableBreakpoint(Variable[i], Mode, Action));
}
}
}
Expand All @@ -130,16 +130,8 @@ protected override void ProcessRecord()

foreach (string path in scripts)
{
if (Column != 0)
{
WriteObject(
Context.Debugger.NewStatementBreakpoint(path, Line[i], Column, Action));
}
else
{
WriteObject(
Context.Debugger.NewLineBreakpoint(path, Line[i], Action));
}
WriteObject(
Context.Debugger.SetLineBreakpoint(path, Line[i], Column, Action));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CmdletsToExport = @(
'Set-MarkdownOption', 'Add-Member', 'Get-Member', 'Compare-Object', 'Group-Object', 'Measure-Object',
'New-Object', 'Select-Object', 'Sort-Object', 'Tee-Object', 'Register-ObjectEvent', 'Write-Output',
'Import-PowerShellDataFile', 'Write-Progress', 'Disable-PSBreakpoint', 'Enable-PSBreakpoint',
'Get-PSBreakpoint', 'Remove-PSBreakpoint', 'Set-PSBreakpoint', 'New-PSBreakpoint', 'Get-PSCallStack', 'Export-PSSession',
'Get-PSBreakpoint', 'Remove-PSBreakpoint', 'Set-PSBreakpoint', 'Get-PSCallStack', 'Export-PSSession',
'Import-PSSession', 'Get-Random', 'Invoke-RestMethod', 'Debug-Runspace', 'Get-Runspace',
'Disable-RunspaceDebug', 'Enable-RunspaceDebug', 'Get-RunspaceDebug', 'Start-Sleep', 'Join-String',
'Out-String', 'Select-String', 'ConvertFrom-StringData', 'Format-Table', 'New-TemporaryFile', 'New-TimeSpan',
Expand All @@ -35,8 +35,8 @@ PrivateData = @{
PSData = @{
ExperimentalFeatures = @(
@{
Name = 'Microsoft.PowerShell.Utility.PSDebugRunspaceWithBreakpoints'
Description = "Enables the New-PSBreakpoint cmdlet and the -Breakpoint parameter on Debug-Runspace to set breakpoints in another Runspace upfront."
Name = 'Microsoft.PowerShell.Utility.PSManageBreakpointsInRunspace'
Description = 'Enables -BreakAll parameter on Debug-Runspace and Debug-Job cmdlets to allow users to decide if they want PowerShell to break immediately in the current location when they attach a debugger.'
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CmdletsToExport = @(
'Show-Markdown', 'Get-MarkdownOption', 'Set-MarkdownOption', 'Add-Member', 'Get-Member', 'Compare-Object', 'Group-Object',
'Measure-Object', 'New-Object', 'Select-Object', 'Sort-Object', 'Tee-Object', 'Register-ObjectEvent', 'Write-Output',
'Import-PowerShellDataFile', 'Write-Progress', 'Disable-PSBreakpoint', 'Enable-PSBreakpoint', 'Get-PSBreakpoint',
'Remove-PSBreakpoint', 'Set-PSBreakpoint', 'New-PSBreakpoint', 'Get-PSCallStack', 'Export-PSSession', 'Import-PSSession', 'Get-Random',
'Remove-PSBreakpoint', 'Set-PSBreakpoint', 'Get-PSCallStack', 'Export-PSSession', 'Import-PSSession', 'Get-Random',
'Invoke-RestMethod', 'Debug-Runspace', 'Get-Runspace', 'Disable-RunspaceDebug', 'Enable-RunspaceDebug',
'Get-RunspaceDebug', 'ConvertFrom-SddlString', 'Start-Sleep', 'Join-String', 'Out-String', 'Select-String',
'ConvertFrom-StringData', 'Format-Table', 'New-TemporaryFile', 'New-TimeSpan', 'Get-TraceSource', 'Set-TraceSource',
Expand All @@ -29,4 +29,14 @@ FunctionsToExport = @()
AliasesToExport = @('fhx')
NestedModules = @("Microsoft.PowerShell.Commands.Utility.dll")
HelpInfoURI = 'https://go.microsoft.com/fwlink/?linkid=855960'
PrivateData = @{
PSData = @{
ExperimentalFeatures = @(
@{
Name = 'Microsoft.PowerShell.Utility.PSManageBreakpointsInRunspace'
Description = 'Enables -BreakAll parameter on Debug-Runspace and Debug-Job cmdlets to allow users to decide if they want PowerShell to break immediately in the current location when they attach a debugger.'
}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4550,7 +4550,6 @@ internal static SessionStateAliasEntry[] BuiltInAliases
new SessionStateAliasEntry("mi", "Move-Item", string.Empty, ReadOnly),
new SessionStateAliasEntry("mp", "Move-ItemProperty", string.Empty, ReadOnly),
new SessionStateAliasEntry("nal", "New-Alias", string.Empty, ReadOnly),
new SessionStateAliasEntry("nbp", "New-PSBreakpoint", string.Empty, ReadOnly),
new SessionStateAliasEntry("ndr", "New-PSDrive", string.Empty, ReadOnly),
new SessionStateAliasEntry("ni", "New-Item", string.Empty, ReadOnly),
new SessionStateAliasEntry("nv", "New-Variable", string.Empty, ReadOnly),
Expand Down
6 changes: 6 additions & 0 deletions src/System.Management.Automation/engine/PSVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class PSVersionInfo
private static readonly SemanticVersion s_psV6Version = new SemanticVersion(6, 0, 0, preReleaseLabel: null, buildLabel: null);
private static readonly SemanticVersion s_psV61Version = new SemanticVersion(6, 1, 0, preReleaseLabel: null, buildLabel: null);
private static readonly SemanticVersion s_psV62Version = new SemanticVersion(6, 2, 0, preReleaseLabel: null, buildLabel: null);
private static readonly SemanticVersion s_psV7Version = new SemanticVersion(7, 0, 0, preReleaseLabel: null, buildLabel: null);
private static readonly SemanticVersion s_psSemVersion;
private static readonly Version s_psVersion;

Expand Down Expand Up @@ -329,6 +330,11 @@ internal static SemanticVersion PSV6Version
get { return s_psV6Version; }
}

internal static SemanticVersion PSV7Version
{
get { return s_psV7Version; }
}

internal static SemanticVersion PSCurrentVersion
{
get { return s_psSemVersion; }
Expand Down
16 changes: 5 additions & 11 deletions src/System.Management.Automation/engine/debugger/Breakpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ internal BreakpointAction Trigger()
return BreakpointAction.Continue;
}

internal virtual void RemoveSelf(ScriptDebugger debugger)
{
}
internal virtual bool RemoveSelf(ScriptDebugger debugger) => false;

#endregion methods

Expand Down Expand Up @@ -208,10 +206,8 @@ public override string ToString()
: StringUtil.Format(DebuggerStrings.CommandBreakpointString, Command);
}

internal override void RemoveSelf(ScriptDebugger debugger)
{
internal override bool RemoveSelf(ScriptDebugger debugger) =>
debugger.RemoveCommandBreakpoint(this);
}

private bool CommandInfoMatches(CommandInfo commandInfo)
{
Expand Down Expand Up @@ -350,10 +346,8 @@ internal bool Trigger(string currentScriptFile, bool read)
return false;
}

internal override void RemoveSelf(ScriptDebugger debugger)
{
internal override bool RemoveSelf(ScriptDebugger debugger) =>
debugger.RemoveVariableBreakpoint(this);
}
}

/// <summary>
Expand Down Expand Up @@ -589,7 +583,7 @@ private void SetBreakpoint(FunctionContext functionContext, int sequencePointInd
this.BreakpointBitArray.Set(SequencePointIndex, true);
}

internal override void RemoveSelf(ScriptDebugger debugger)
internal override bool RemoveSelf(ScriptDebugger debugger)
{
if (this.SequencePoints != null)
{
Expand All @@ -612,7 +606,7 @@ internal override void RemoveSelf(ScriptDebugger debugger)
}
}

debugger.RemoveLineBreakpoint(this);
return debugger.RemoveLineBreakpoint(this);
}
}
}
Loading