MCPcopy Index your code
hub / github.com/python/cpython / set_trace_async

Method set_trace_async

Lib/pdb.py:444–493  ·  view source on GitHub ↗
(self, frame=None, *, commands=None)

Source from the content-addressed store, hash-verified

442 super().set_trace(frame)
443
444 async def set_trace_async(self, frame=None, *, commands=None):
445 if self.async_awaitable is not None:
446 # We are already in a set_trace_async call, do not mess with it
447 return
448
449 if frame is None:
450 frame = sys._getframe().f_back
451
452 # We need set_trace to set up the basics, however, this will call
453 # set_stepinstr() will we need to compensate for, because we don't
454 # want to trigger on calls
455 self.set_trace(frame, commands=commands)
456 # Changing the stopframe will disable trace dispatch on calls
457 self.stopframe = frame
458 # We need to stop tracing because we don't have the privilege to avoid
459 # triggering tracing functions as normal, as we are not already in
460 # tracing functions
461 self.stop_trace()
462
463 self.async_shim_frame = sys._getframe()
464 self.async_awaitable = None
465
466 while True:
467 self.async_awaitable = None
468 # Simulate a trace event
469 # This should bring up pdb and make pdb believe it's debugging the
470 # caller frame
471 self.trace_dispatch(frame, "opcode", None)
472 if self.async_awaitable is not None:
473 try:
474 if self.breaks:
475 with self.set_enterframe(frame):
476 # set_continue requires enterframe to work
477 self.set_continue()
478 self.start_trace()
479 await self.async_awaitable
480 except Exception:
481 self._error_exc()
482 else:
483 break
484
485 self.async_shim_frame = None
486
487 # start the trace (the actual command is already set by set_* calls)
488 if self.returnframe is None and self.stoplineno == -1 and not self.breaks:
489 # This means we did a continue without any breakpoints, we should not
490 # start the trace
491 return
492
493 self.start_trace()
494
495 def sigint_handler(self, signum, frame):
496 if self.allow_kbdint:

Callers 1

set_trace_asyncFunction · 0.95

Calls 7

set_traceMethod · 0.95
_error_excMethod · 0.95
set_enterframeMethod · 0.80
stop_traceMethod · 0.45
trace_dispatchMethod · 0.45
set_continueMethod · 0.45
start_traceMethod · 0.45

Tested by

no test coverage detected