From 045558eaee24d66d3e700b881f2d9b2326f3f27f Mon Sep 17 00:00:00 2001 From: Dan Thompson Date: Sun, 4 Apr 2021 23:12:37 -0700 Subject: [PATCH] Fix bp with just an address Set-DbgBreakpoint with just a simple address (like "bp $exentry") was broken, because PS could not resolve the parameter set. This change fixes it by specifying more completely the possible valid parameter sets. (thanks to ReneNyffenegger for the report) --- .../Commands/SetDbgBreakpointCommand.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/DbgProvider/public/Commands/SetDbgBreakpointCommand.cs b/DbgProvider/public/Commands/SetDbgBreakpointCommand.cs index e1555cc..4cbaf9f 100644 --- a/DbgProvider/public/Commands/SetDbgBreakpointCommand.cs +++ b/DbgProvider/public/Commands/SetDbgBreakpointCommand.cs @@ -7,7 +7,7 @@ namespace MS.Dbg.Commands { [Cmdlet( VerbsCommon.Set, "DbgBreakpoint", - DefaultParameterSetName = c_Expression_ScriptBlockCommand_ParamSet )] + DefaultParameterSetName = c_Expression_Only_ParamSet )] [OutputType( typeof( DbgBreakpointInfo ) )] public class SetDbgBreakpointCommand : DbgBaseCommand { @@ -30,6 +30,8 @@ public class SetDbgBreakpointCommand : DbgBaseCommand private const string c_Address_ScriptBlockCommand_ParamSet = "Address_ScriptBlockCommand_ParamSet"; private const string c_Expression_DbgEngCommand_ParamSet = "Expression_DbgEngCommand_ParamSet"; private const string c_Address_DbgEngCommand_ParamSet = "Address_DbgEngCommand_ParamSet"; + private const string c_Expression_Only_ParamSet = "Expression_Only_ParamSet"; + private const string c_Address_Only_ParamSet = "Address_Only_ParamSet"; [Parameter( Mandatory = true, @@ -40,6 +42,10 @@ public class SetDbgBreakpointCommand : DbgBaseCommand Position = 0, ValueFromPipeline = true, ParameterSetName = c_Expression_DbgEngCommand_ParamSet )] + [Parameter( Mandatory = true, + Position = 0, + ValueFromPipeline = true, + ParameterSetName = c_Expression_Only_ParamSet )] [ValidateNotNullOrEmpty] public string Expression { get; set; } @@ -52,6 +58,10 @@ public class SetDbgBreakpointCommand : DbgBaseCommand Position = 0, ValueFromPipeline = true, ParameterSetName = c_Address_DbgEngCommand_ParamSet )] + [Parameter( Mandatory = true, + Position = 0, + ValueFromPipeline = true, + ParameterSetName = c_Address_Only_ParamSet )] public ulong Address { get; set; } @@ -63,12 +73,12 @@ public class SetDbgBreakpointCommand : DbgBaseCommand [Alias( "Passes" )] public uint PassCount { get; set; } - [Parameter( Mandatory = false, ParameterSetName = c_Expression_ScriptBlockCommand_ParamSet )] - [Parameter( Mandatory = false, ParameterSetName = c_Address_ScriptBlockCommand_ParamSet )] + [Parameter( Mandatory = true, ParameterSetName = c_Expression_ScriptBlockCommand_ParamSet )] + [Parameter( Mandatory = true, ParameterSetName = c_Address_ScriptBlockCommand_ParamSet )] public ScriptBlock Command { get; set; } - [Parameter( Mandatory = false, ParameterSetName = c_Expression_DbgEngCommand_ParamSet )] - [Parameter( Mandatory = false, ParameterSetName = c_Address_DbgEngCommand_ParamSet )] + [Parameter( Mandatory = true, ParameterSetName = c_Expression_DbgEngCommand_ParamSet )] + [Parameter( Mandatory = true, ParameterSetName = c_Address_DbgEngCommand_ParamSet )] public string DbgEngCommand { get; set; } @@ -130,7 +140,8 @@ protected override void ProcessRecord() { addr = Address; Util.Assert( (c_Address_ScriptBlockCommand_ParamSet == this.ParameterSetName) || - (c_Address_DbgEngCommand_ParamSet == this.ParameterSetName) ); + (c_Address_DbgEngCommand_ParamSet == this.ParameterSetName) || + (c_Address_Only_ParamSet == this.ParameterSetName) ); Expression = DbgProvider.FormatAddress( Address, Debugger.TargetIs32Bit, true ).ToString( false ); } else