Skip to content

Commit f56a683

Browse files
committed
Initial work to support breakpoint hit count.
1 parent dba6515 commit f56a683

File tree

8 files changed

+29
-6
lines changed

8 files changed

+29
-6
lines changed

src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public class InitializeResponseBody
4747
/// </summary>
4848
public bool SupportsConditionalBreakpoints { get; set; }
4949

50+
/// <summary>
51+
/// Gets or sets a boolean value that determines whether the debug adapter
52+
/// supports breakpoints that break execution after a specified number of hits.
53+
/// </summary>
54+
public bool SupportsHitConditionalBreakpoints { get; set; }
55+
5056
/// <summary>
5157
/// Gets or sets a boolean value that determines whether the debug adapter
5258
/// supports a (side effect free) evaluate request for data hovers.

src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class SourceBreakpoint
3434
public int? Column { get; set; }
3535

3636
public string Condition { get; set; }
37+
38+
public string HitCondition { get; set; }
3739
}
3840

3941
public class SetBreakpointsResponseBody

src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ public class FunctionBreakpoint
2727
public string Name { get; set; }
2828

2929
public string Condition { get; set; }
30+
31+
public string HitCondition { get; set; }
3032
}
3133
}

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ await requestContext.SendResult(
262262
scriptFile.FilePath,
263263
srcBreakpoint.Line,
264264
srcBreakpoint.Column,
265-
srcBreakpoint.Condition);
265+
srcBreakpoint.Condition,
266+
srcBreakpoint.HitCondition);
266267
}
267268

268269
// If this is a "run without debugging (Ctrl+F5)" session ignore requests to set breakpoints.
@@ -294,7 +295,8 @@ protected async Task HandleSetFunctionBreakpointsRequest(
294295
FunctionBreakpoint funcBreakpoint = setBreakpointsParams.Breakpoints[i];
295296
breakpointDetails[i] = CommandBreakpointDetails.Create(
296297
funcBreakpoint.Name,
297-
funcBreakpoint.Condition);
298+
funcBreakpoint.Condition,
299+
funcBreakpoint.HitCondition);
298300
}
299301

300302
// If this is a "run without debugging (Ctrl+F5)" session ignore requests to set breakpoints.

src/PowerShellEditorServices.Protocol/Server/DebugAdapterBase.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ private async Task HandleInitializeRequest(
5858
await requestContext.SendResult(
5959
new InitializeResponseBody {
6060
SupportsConfigurationDoneRequest = true,
61-
SupportsConditionalBreakpoints = true,
6261
SupportsFunctionBreakpoints = true,
62+
SupportsConditionalBreakpoints = true,
63+
SupportsHitConditionalBreakpoints = true,
6364
SupportsSetVariable = true
6465
});
6566

src/PowerShellEditorServices/Debugging/BreakpointDetails.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ private BreakpointDetails()
4242
/// <param name="line"></param>
4343
/// <param name="column"></param>
4444
/// <param name="condition"></param>
45+
/// <param name="hitCondition"></param>
4546
/// <returns></returns>
4647
public static BreakpointDetails Create(
4748
string source,
4849
int line,
4950
int? column = null,
50-
string condition = null)
51+
string condition = null,
52+
string hitCondition = null)
5153
{
5254
Validate.IsNotNull("source", source);
5355

@@ -57,7 +59,8 @@ public static BreakpointDetails Create(
5759
Source = source,
5860
LineNumber = line,
5961
ColumnNumber = column,
60-
Condition = condition
62+
Condition = condition,
63+
HitCondition = hitCondition
6164
};
6265
}
6366

src/PowerShellEditorServices/Debugging/BreakpointDetailsBase.cs

+5
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,10 @@ public abstract class BreakpointDetailsBase
2727
/// Gets the breakpoint condition string.
2828
/// </summary>
2929
public string Condition { get; protected set; }
30+
31+
/// <summary>
32+
/// Gets the breakpoint hit condition string.
33+
/// </summary>
34+
public string HitCondition { get; protected set; }
3035
}
3136
}

src/PowerShellEditorServices/Debugging/CommandBreakpointDetails.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ private CommandBreakpointDetails()
2929
/// </summary>
3030
/// <param name="name">The name of the command to break on.</param>
3131
/// <param name="condition">Condition string that would be applied to the breakpoint Action parameter.</param>
32+
/// <param name="hitCondition">Hit condition string that would be applied to the breakpoint Action parameter.</param>
3233
/// <returns></returns>
3334
public static CommandBreakpointDetails Create(
3435
string name,
35-
string condition = null)
36+
string condition = null,
37+
string hitCondition = null)
3638
{
3739
Validate.IsNotNull(nameof(name), name);
3840

0 commit comments

Comments
 (0)