11import asyncio
22import functools
3+ import os
34import threading
45import warnings
56from typing import (
@@ -103,7 +104,9 @@ async def start_debugpy_async(
103104 global config_done_callback
104105
105106 def connect_debugpy (server : "DebugAdapterServer" ) -> None :
106- server .protocol .send_event (Event (event = "debugpyStarted" , body = {"port" : port , "addresses" : addresses }))
107+ server .protocol .send_event (
108+ Event (event = "debugpyStarted" , body = {"port" : port , "addresses" : addresses , "processId" : os .getpid ()})
109+ )
107110
108111 if wait_for_debugpy_client :
109112 wait_for_debugpy_connected ()
@@ -134,11 +137,13 @@ async def run_debugger(
134137 group_output : bool = False ,
135138) -> int :
136139 if debug and debugpy and not is_debugpy_installed ():
137- print ( "debugpy not installed." )
140+ app . warning ( "Debugpy not installed." )
138141
139142 if debug and debugpy :
143+ app .verbose ("Try to start debugpy session." )
140144 await start_debugpy_async (debugpy_port , addresses , debugpy_wait_for_client , wait_for_client_timeout )
141145
146+ app .verbose ("Start robotcode debugger thread." )
142147 server_future = run_coroutine_in_thread (
143148 _debug_adapter_server_ , config_done_callback , mode , addresses , port , pipe_name
144149 )
@@ -148,6 +153,7 @@ async def run_debugger(
148153
149154 try :
150155 if wait_for_client :
156+ app .verbose ("Wait for incomming connections." )
151157 try :
152158 await run_coroutine_from_thread_async (
153159 server .protocol .wait_for_client ,
@@ -162,6 +168,7 @@ async def run_debugger(
162168 await run_coroutine_from_thread_async (server .protocol .wait_for_initialized , loop = server .loop )
163169
164170 if wait_for_client :
171+ app .verbose ("Wait for debug configuration." )
165172 try :
166173 await run_coroutine_from_thread_async (
167174 server .protocol .wait_for_configuration_done ,
@@ -174,6 +181,7 @@ async def run_debugger(
174181 raise ConnectionError ("Timeout to get configuration from client." ) from e
175182
176183 if debugpy and debugpy_wait_for_client :
184+ app .verbose ("Wait for debugpy incomming connections." )
177185 wait_for_debugpy_connected ()
178186
179187 args = [
@@ -192,12 +200,15 @@ async def run_debugger(
192200 Debugger .instance ().debug = debug
193201 Debugger .instance ().set_main_thread (threading .current_thread ())
194202 Debugger .instance ().server_loop = server .loop
203+
204+ app .verbose ("Start the debugger instance." )
195205 Debugger .instance ().start ()
196206
197207 exit_code = 0
198208 try :
199209 from robotcode .runner .cli .robot import robot
200210
211+ app .verbose ("Start robot." )
201212 try :
202213 robot_ctx = robot .make_context ("robot" , args , parent = ctx )
203214 robot .invoke (robot_ctx )
0 commit comments