@@ -116,7 +116,7 @@ export class StatusResponse extends Response {
116
116
}
117
117
}
118
118
119
- export type BreakpointType = "line" | "call" | " return" | "exception " | "conditional" | "watch" ;
119
+ export type BreakpointType = "line" | "return" | "conditional" | "watch" ;
120
120
export type BreakpointState = "enabled" | "disabled" ;
121
121
122
122
/** Abstract base class for all breakpoints */
@@ -130,9 +130,6 @@ export abstract class Breakpoint {
130
130
case "conditional" :
131
131
// eslint-disable-next-line @typescript-eslint/no-use-before-define
132
132
return new ConditionalBreakpoint ( breakpointNode , connection ) ;
133
- case "call" :
134
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
135
- return new CallBreakpoint ( breakpointNode , connection ) ;
136
133
default :
137
134
throw new Error ( `Invalid type ${ breakpointNode . getAttribute ( "type" ) } ` ) ;
138
135
}
@@ -159,6 +156,7 @@ export abstract class Breakpoint {
159
156
this . state = breakpointNode . getAttribute ( "state" ) as BreakpointState ;
160
157
} else {
161
158
this . type = rest [ 0 ] ;
159
+ this . state = "enabled" ;
162
160
}
163
161
}
164
162
/** Removes the breakpoint by sending a breakpoint_remove command */
@@ -214,39 +212,13 @@ export class ClassLineBreakpoint extends LineBreakpoint {
214
212
}
215
213
}
216
214
217
- /** class for call breakpoints. Returned from a breakpoint_list or passed to sendBreakpointSetCommand */
218
- export class CallBreakpoint extends Breakpoint {
219
- /** the function to break on */
220
- public fn : string ;
221
- /** optional expression that must evaluate to true */
222
- public expression : string ;
223
- /** constructs a call breakpoint from an XML node */
224
- public constructor ( breakpointNode : Element , connection : Connection ) ;
225
- /** contructs a call breakpoint for passing to sendSetBreakpointCommand */
226
- public constructor ( fn : string , expression ?: string ) ;
227
- public constructor ( ...rest ) {
228
- if ( typeof rest [ 0 ] === "object" ) {
229
- const breakpointNode : Element = rest [ 0 ] ;
230
- const connection : Connection = rest [ 1 ] ;
231
- super ( breakpointNode , connection ) ;
232
- this . fn = breakpointNode . getAttribute ( "function" ) ;
233
- this . expression = breakpointNode . getAttribute ( "expression" ) ; // Base64 encoded?
234
- } else {
235
- // construct from arguments
236
- super ( "call" ) ;
237
- this . fn = rest [ 0 ] ;
238
- this . expression = rest [ 1 ] ;
239
- }
240
- }
241
- }
242
-
243
215
/** class for conditional breakpoints. Returned from a breakpoint_list or passed to sendBreakpointSetCommand */
244
216
export class ConditionalBreakpoint extends Breakpoint {
245
217
/** File URI */
246
218
public fileUri : string ;
247
219
/** Line (optional) */
248
220
public line : number ;
249
- /** The PHP expression under which to break on */
221
+ /** The expression under which to break on */
250
222
public expression : string ;
251
223
/** Constructs a breakpoint object from an XML node from a XDebug response */
252
224
public constructor ( breakpointNode : Element , connection : Connection ) ;
@@ -543,6 +515,18 @@ export class FeatureSetResponse extends Response {
543
515
}
544
516
}
545
517
518
+ export class FeatureGetResponse extends Response {
519
+ /** the feature that was get */
520
+ public feature : string ;
521
+ /** supported flag for the feature */
522
+ public supported : boolean ;
523
+ public constructor ( document : XMLDocument , connection : Connection ) {
524
+ super ( document , connection ) ;
525
+ this . feature = document . documentElement . getAttribute ( "feature" ) ;
526
+ this . supported = document . documentElement . getAttribute ( "supported" ) === "1" ;
527
+ }
528
+ }
529
+
546
530
/** A command inside the queue */
547
531
interface Command {
548
532
/** The name of the command, like breakpoint_list */
@@ -555,7 +539,7 @@ interface Command {
555
539
resolveFn : ( response : XMLDocument ) => any ;
556
540
/** callback that gets called if an error happened while parsing the response */
557
541
rejectFn : ( error ?: Error ) => any ;
558
- /** whether command results in PHP code being executed or not */
542
+ /** whether command results in code being executed or not */
559
543
isExecuteCommand : boolean ;
560
544
}
561
545
@@ -564,7 +548,7 @@ interface Command {
564
548
*/
565
549
export class Connection extends DbgpConnection {
566
550
/**
567
- * Whether a command was started that executes PHP , which means the connection will be blocked from
551
+ * Whether a command was started that executes code , which means the connection will be blocked from
568
552
* running any additional commands until the execution gets to the next stopping point or exits.
569
553
*/
570
554
public get isPendingExecuteCommand ( ) : boolean {
@@ -682,8 +666,8 @@ export class Connection extends DbgpConnection {
682
666
* - notify_ok
683
667
* or any command.
684
668
*/
685
- public async sendFeatureGetCommand ( feature : string ) : Promise < XMLDocument > {
686
- return await this . _enqueueCommand ( "feature_get" , `-n ${ feature } ` ) ;
669
+ public async sendFeatureGetCommand ( feature : string ) : Promise < FeatureGetResponse > {
670
+ return new FeatureGetResponse ( await this . _enqueueCommand ( "feature_get" , `-n ${ feature } ` ) , this ) ;
687
671
}
688
672
689
673
/**
@@ -712,8 +696,8 @@ export class Connection extends DbgpConnection {
712
696
public async sendBreakpointSetCommand ( breakpoint : Breakpoint ) : Promise < BreakpointSetResponse > {
713
697
let args = `-t ${ breakpoint . type } ` ;
714
698
let data : string | undefined ;
699
+ args += ` -s ${ breakpoint . state } ` ;
715
700
if ( breakpoint instanceof LineBreakpoint ) {
716
- args += ` -s enabled` ;
717
701
args += ` -f ${ breakpoint . fileUri } ` ;
718
702
if ( breakpoint instanceof ClassLineBreakpoint ) {
719
703
args += ` -m ${ breakpoint . method } -n ${ breakpoint . methodOffset } ` ;
@@ -726,9 +710,6 @@ export class Connection extends DbgpConnection {
726
710
args += ` -n ${ breakpoint . line } ` ;
727
711
}
728
712
data = breakpoint . expression ;
729
- } else if ( breakpoint instanceof CallBreakpoint ) {
730
- args += ` -m ${ breakpoint . fn } ` ;
731
- data = breakpoint . expression ;
732
713
}
733
714
return new BreakpointSetResponse ( await this . _enqueueCommand ( "breakpoint_set" , args , data ) , this ) ;
734
715
}
@@ -767,7 +748,17 @@ export class Connection extends DbgpConnection {
767
748
768
749
/** sends a stop command */
769
750
public async sendStopCommand ( ) : Promise < StatusResponse > {
770
- return new StatusResponse ( await this . _enqueueCommand ( "stop" ) , this ) ;
751
+ return new StatusResponse ( await this . _immediateCommand ( "stop" ) , this ) ;
752
+ }
753
+
754
+ /** sends an detach command */
755
+ public async sendDetachCommand ( ) : Promise < StatusResponse > {
756
+ return new StatusResponse ( await this . _immediateCommand ( "detach" ) , this ) ;
757
+ }
758
+
759
+ /** sends an break command */
760
+ public async sendBreakCommand ( ) : Promise < StatusResponse > {
761
+ return new StatusResponse ( await this . _immediateCommand ( "break" ) , this ) ;
771
762
}
772
763
773
764
// ------------------------------ stack ----------------------------------------
@@ -835,8 +826,21 @@ export class Connection extends DbgpConnection {
835
826
} ) ;
836
827
}
837
828
829
+ private _immediateCommand ( name : string , args ?: string , data ?: string ) : Promise < XMLDocument > {
830
+ return new Promise ( ( resolveFn , rejectFn ) : void => {
831
+ this . _executeCommand ( {
832
+ name,
833
+ args,
834
+ data,
835
+ resolveFn,
836
+ rejectFn,
837
+ isExecuteCommand : false ,
838
+ } ) ;
839
+ } ) ;
840
+ }
841
+
838
842
/**
839
- * Pushes a new execute command (one that results in executing PHP code)
843
+ * Pushes a new execute command (one that results in executing code)
840
844
* to the queue that will be executed after all the previous
841
845
* commands have finished and we received a response.
842
846
* If the queue is empty AND there are no pending transactions
0 commit comments