1212
1313namespace Microsoft . PowerShell . EditorServices
1414{
15+ /// <summary>
16+ /// Provides a high-level service for interacting with the
17+ /// PowerShell debugger in the context of a PowerShellSession.
18+ /// </summary>
1519 public class DebugService
1620 {
1721 #region Fields
1822
1923 private PowerShellSession powerShellSession ;
20- private ConsoleServicePSHost consoleServicePSHost ;
2124
2225 // TODO: This needs to be managed per nested session
2326 private Dictionary < string , List < Breakpoint > > breakpointsPerFile =
@@ -31,6 +34,13 @@ public class DebugService
3134
3235 #region Constructors
3336
37+ /// <summary>
38+ /// Initializes a new instance of the DebugService class and uses
39+ /// the given PowerShellSession for all future operations.
40+ /// </summary>
41+ /// <param name="powerShellSession">
42+ /// The PowerShellSession to use for all debugging operations.
43+ /// </param>
3444 public DebugService ( PowerShellSession powerShellSession )
3545 {
3646 Validate . IsNotNull ( "powerShellSession" , powerShellSession ) ;
@@ -44,6 +54,13 @@ public DebugService(PowerShellSession powerShellSession)
4454
4555 #region Public Methods
4656
57+ /// <summary>
58+ /// Sets the list of breakpoints for the current debugging session.
59+ /// </summary>
60+ /// <param name="scriptFile">The ScriptFile in which breakpoints will be set.</param>
61+ /// <param name="lineNumbers">The line numbers at which breakpoints will be set.</param>
62+ /// <param name="clearExisting">If true, causes all existing breakpoints to be cleared before setting new ones.</param>
63+ /// <returns>An awaitable Task that will provide details about the breakpoints that were set.</returns>
4764 public async Task < BreakpointDetails [ ] > SetBreakpoints (
4865 ScriptFile scriptFile ,
4966 int [ ] lineNumbers ,
@@ -76,41 +93,68 @@ await this.powerShellSession.ExecuteCommand<Breakpoint>(
7693 return new BreakpointDetails [ 0 ] ;
7794 }
7895
96+ /// <summary>
97+ /// Sends a "continue" action to the debugger when stopped.
98+ /// </summary>
7999 public void Continue ( )
80100 {
81101 this . powerShellSession . ResumeDebugger (
82102 DebuggerResumeAction . Continue ) ;
83103 }
84104
105+ /// <summary>
106+ /// Sends a "step over" action to the debugger when stopped.
107+ /// </summary>
85108 public void StepOver ( )
86109 {
87110 this . powerShellSession . ResumeDebugger (
88111 DebuggerResumeAction . StepOver ) ;
89112 }
90113
114+ /// <summary>
115+ /// Sends a "step in" action to the debugger when stopped.
116+ /// </summary>
91117 public void StepIn ( )
92118 {
93119 this . powerShellSession . ResumeDebugger (
94120 DebuggerResumeAction . StepInto ) ;
95121 }
96122
123+ /// <summary>
124+ /// Sends a "step out" action to the debugger when stopped.
125+ /// </summary>
97126 public void StepOut ( )
98127 {
99128 this . powerShellSession . ResumeDebugger (
100129 DebuggerResumeAction . StepOut ) ;
101130 }
102131
132+ /// <summary>
133+ /// Causes the debugger to break execution wherever it currently
134+ /// is at the time. This is equivalent to clicking "Pause" in a
135+ /// debugger UI.
136+ /// </summary>
103137 public void Break ( )
104138 {
105139 // Break execution in the debugger
106140 this . powerShellSession . BreakExecution ( ) ;
107141 }
108142
109- public void Stop ( )
143+ /// <summary>
144+ /// Aborts execution of the debugger while it is running, even while
145+ /// it is stopped. Equivalent to calling PowerShellSession.AbortExecution.
146+ /// </summary>
147+ public void Abort ( )
110148 {
111149 this . powerShellSession . AbortExecution ( ) ;
112150 }
113151
152+ /// <summary>
153+ /// Gets the list of variables that are children of the scope or variable
154+ /// that is identified by the given referenced ID.
155+ /// </summary>
156+ /// <param name="variableReferenceId"></param>
157+ /// <returns>An array of VariableDetails instances which describe the requested variables.</returns>
114158 public VariableDetails [ ] GetVariables ( int variableReferenceId )
115159 {
116160 VariableDetails [ ] childVariables = null ;
@@ -148,6 +192,15 @@ public VariableDetails[] GetVariables(int variableReferenceId)
148192 return childVariables ;
149193 }
150194
195+ /// <summary>
196+ /// Evaluates an expression in the context of the stopped
197+ /// debugger. For now, this just does simple evaluation of
198+ /// a variable in the session. In the future it will execute
199+ /// commands in the PowerShellSession.
200+ /// </summary>
201+ /// <param name="expressionString">The expression string to execute.</param>
202+ /// <param name="stackFrameId">The ID of the stack frame in which the expression should be executed.</param>
203+ /// <returns>A VariableDetails object containing the result.</returns>
151204 public VariableDetails EvaluateExpression ( string expressionString , int stackFrameId )
152205 {
153206 // Break up the variable path
@@ -183,11 +236,24 @@ public VariableDetails EvaluateExpression(string expressionString, int stackFram
183236 return resolvedVariable ;
184237 }
185238
239+ /// <summary>
240+ /// Gets the list of stack frames at the point where the
241+ /// debugger sf stopped.
242+ /// </summary>
243+ /// <returns>
244+ /// An array of StackFrameDetails instances that contain the stack trace.
245+ /// </returns>
186246 public StackFrameDetails [ ] GetStackFrames ( )
187247 {
188248 return this . callStackFrames ;
189249 }
190250
251+ /// <summary>
252+ /// Gets the list of variable scopes for the stack frame that
253+ /// is identified by the given ID.
254+ /// </summary>
255+ /// <param name="stackFrameId">The ID of the stack frame at which variable scopes should be retrieved.</param>
256+ /// <returns>The list of VariableScope instances which describe the available variable scopes.</returns>
191257 public VariableScope [ ] GetVariableScopes ( int stackFrameId )
192258 {
193259 // TODO: Return different scopes based on PowerShell scoping mechanics
@@ -260,6 +326,9 @@ private async Task FetchStackFrames()
260326
261327 #region Events
262328
329+ /// <summary>
330+ /// Raised when the debugger stops execution at a breakpoint or when paused.
331+ /// </summary>
263332 public event EventHandler < DebuggerStopEventArgs > DebuggerStopped ;
264333
265334 private async void OnDebuggerStop ( object sender , DebuggerStopEventArgs e )
@@ -275,6 +344,9 @@ private async void OnDebuggerStop(object sender, DebuggerStopEventArgs e)
275344 }
276345 }
277346
347+ /// <summary>
348+ /// Raised when a breakpoint is added/removed/updated in the debugger.
349+ /// </summary>
278350 public event EventHandler < BreakpointUpdatedEventArgs > BreakpointUpdated ;
279351
280352 private void OnBreakpointUpdated ( object sender , BreakpointUpdatedEventArgs e )
0 commit comments