@@ -21,6 +21,7 @@ import { shouldIgnoreException } from './ignore'
2121import { varExportProperty } from './varExport'
2222import { supportedEngine } from './xdebugUtils'
2323import { varJsonProperty } from './varJson'
24+ import * as abs from 'abstract-socket'
2425
2526if ( process . env [ 'VSCODE_NLS_CONFIG' ] ) {
2627 try {
@@ -1432,10 +1433,47 @@ class PhpDebugSession extends vscode.DebugSession {
14321433 }
14331434 }
14341435
1435- protected pauseRequest (
1436+ protected async pauseRequest (
14361437 response : VSCodeDebugProtocol . PauseResponse ,
14371438 args : VSCodeDebugProtocol . PauseArguments
1438- ) : void {
1439+ ) : Promise < void > {
1440+ // test
1441+ let connection : xdebug . Connection | undefined
1442+ connection = this . _connections . get ( args . threadId )
1443+ if ( ! connection ) {
1444+ return this . sendErrorResponse ( response , new Error ( `Unknown thread ID ${ args . threadId } ` ) )
1445+ }
1446+
1447+ let initPacket = await connection . waitForInitPacket ( )
1448+ const supportedControl =
1449+ process . platform === 'linux' &&
1450+ initPacket . engineName === 'Xdebug' &&
1451+ semver . valid ( initPacket . engineVersion , { loose : true } ) &&
1452+ ( semver . gte ( initPacket . engineVersion , '3.4.0' , { loose : true } ) || initPacket . engineVersion === '3.4.0-dev' )
1453+
1454+ if ( supportedControl ) {
1455+ let cs = `\0xdebug-ctrl.${ initPacket . appId } y` . padEnd ( 108 , 'x' )
1456+ try {
1457+ const sock = abs . connect ( cs , ( ) => {
1458+ sock . write ( "pause\0" )
1459+ if ( this . _skippingFiles . has ( args . threadId ) ) {
1460+ this . _skippingFiles . set ( args . threadId , false )
1461+ }
1462+ this . sendResponse ( response )
1463+ } )
1464+ sock . on ( 'data' , ( data ) => {
1465+ // todo
1466+ } )
1467+ sock . on ( 'error' , ( error ) => {
1468+ this . sendErrorResponse ( response , new Error ( 'Cannot connect to Xdebug control socket' ) )
1469+ } )
1470+ return
1471+ } catch ( error ) {
1472+ this . sendErrorResponse ( response , new Error ( 'Cannot connect to Xdebug control socket' ) )
1473+ return
1474+ }
1475+ }
1476+ // test
14391477 if ( this . _skippingFiles . has ( args . threadId ) ) {
14401478 this . _skippingFiles . set ( args . threadId , false )
14411479 this . sendResponse ( response )
0 commit comments