code: def set_pdb_trace(pm=False):
      
      import sys
      import pdb
  
      for attr in ("stdin", "stdout", "stderr"):
          setattr(sys, attr, getattr(sys, "__%s__" % attr))
      if pm:
          # Post-mortem debugging of an exception
          pdb.post_mortem()
      else:
          pdb.set_trace()
docs: Start the Python debugger when robotframework is running.
  
      This makes sure that pdb can use stdin/stdout even though
      robotframework has redirected I/O.