@@ -84,6 +84,18 @@ def __init__(self, debug_config=None):
8484
8585 self .client_id = "vscode"
8686
87+ self .capabilities = {
88+ "pathFormat" : "path" ,
89+ "clientID" : self .client_id ,
90+ "adapterID" : "test" ,
91+ "linesStartAt1" : True ,
92+ "columnsStartAt1" : True ,
93+ "supportsVariableType" : True ,
94+ "supportsRunInTerminalRequest" : True ,
95+ "supportsArgsCanBeInterpretedByShell" : True ,
96+ "supportsStartDebuggingRequest" : False ,
97+ }
98+
8799 self .debuggee = None
88100 """psutil.Popen instance for the debuggee process."""
89101
@@ -502,6 +514,10 @@ def _process_request(self, request):
502514 except Exception as exc :
503515 log .swallow_exception ('"runInTerminal" failed:' )
504516 raise request .cant_handle (str (exc ))
517+ elif request .command == "startDebugging" :
518+ pid = request ("configuration" , dict )("subProcessId" , int )
519+ watchdog .register_spawn (pid , f"{ self .debuggee_id } -subprocess-{ pid } " )
520+ return {}
505521 else :
506522 raise request .isnt_valid ("not supported" )
507523
@@ -551,19 +567,7 @@ def _start_channel(self, stream):
551567 )
552568 )
553569
554- self .request (
555- "initialize" ,
556- {
557- "pathFormat" : "path" ,
558- "clientID" : self .client_id ,
559- "adapterID" : "test" ,
560- "linesStartAt1" : True ,
561- "columnsStartAt1" : True ,
562- "supportsVariableType" : True ,
563- "supportsRunInTerminalRequest" : True ,
564- "supportsArgsCanBeInterpretedByShell" : True ,
565- },
566- )
570+ self .request ("initialize" , self .capabilities )
567571
568572 def all_events (self , event , body = some .object ):
569573 return [
@@ -783,7 +787,15 @@ def wait_for_stop(
783787 return StopInfo (stopped , frames , tid , fid )
784788
785789 def wait_for_next_subprocess (self ):
786- return Session (self .wait_for_next_event ("debugpyAttach" ))
790+ message = self .timeline .wait_for_next (timeline .Event ("debugpyAttach" ) | timeline .Request ("startDebugging" ))
791+ if isinstance (message , timeline .EventOccurrence ):
792+ config = message .body
793+ assert "request" in config
794+ elif isinstance (message , timeline .RequestOccurrence ):
795+ config = dict (message .body ("configuration" , dict ))
796+ assert "request" not in config
797+ config ["request" ] = "attach"
798+ return Session (config )
787799
788800 def wait_for_disconnect (self ):
789801 self .timeline .wait_until_realized (timeline .Mark ("disconnect" ), freeze = True )
0 commit comments