@@ -31,6 +31,10 @@ def _debug_print(self, message):
3131 """Print debug message only if debug logging is enabled."""
3232 if self .debug_logging :
3333 print (message )
34+
35+ @property
36+ def _baremetal (self ) -> bool :
37+ return sys .platform not in ("linux" ) # to be expanded
3438
3539 def start (self ):
3640 """Start the debug session message loop."""
@@ -369,15 +373,23 @@ def _handle_source(self, seq, args):
369373 """Handle source request."""
370374 source = args .get ("source" , {})
371375 source_path = source .get ("path" , "" )
372-
376+ if self ._baremetal or not source_path :
377+ # BUGBUG: unable to read the source on ESP32
378+ # Possible an effect of the import / inialization sequence ?
379+ # Nothe that other source files ( other.py) do not seem to get requested in the same way
380+ self .channel .send_response (CMD_SOURCE , seq , success = False )
381+ return
382+ self ._debug_print (f"[DAP] Processing source request for path: { source } " )
373383 try :
374384 # Try to read the source file
375- with open (source_path , 'r' ) as f :
385+ with open (source_path ) as f :
376386 content = f .read ()
377387 self .channel .send_response (CMD_SOURCE , seq , body = {"content" : content })
378388 except Exception as e :
379389 self .channel .send_response (CMD_SOURCE , seq , success = False ,
380- message = f"Could not read source: { e } " )
390+ message = "cancelled"
391+ # message=f"Could not read source: {e}"
392+ )
381393
382394 def _trace_function (self , frame , event , arg ):
383395 """Trace function called by sys.settrace."""
0 commit comments