pdb-attach icon indicating copy to clipboard operation
pdb-attach copied to clipboard

Support non-pdb debuggers using `breakpoint()`

Open matt-bernstein opened this issue 1 year ago • 1 comments

Hi, thanks for the very useful project!

I generally like to use ipdb rather than pdb for the full ipython kernel in interact mode. This is accomplished by setting the environment variable:

export PYTHONBREAKPOINT=ipdb.set_trace

and then calling breakpoint() in python code will drop into ipdb rather than pdb. Looking at the source, it seems that this could be supported easily in pdb-attach by rewriting the function:

    def set_trace(self, frame=None):
        """Accept the connection to the client and start tracing the program."""
        serv, _ = self._sock.accept()
        sock_io = PdbIOWrapper(serv)
        self.stdin = self.stdout = sock_io
        pdb.Pdb.set_trace(self, frame)

to use breakpoint instead of set_trace. There are also other debuggers that have the same interface using breakpoint that would become supported.

Does this sound worth trying?

matt-bernstein avatar Jun 28 '23 19:06 matt-bernstein

Hi @matt-bernstein, thanks for reaching out. Yes I agree supporting ipdb would be ideal. I need to further investigate before guaranteeing its inclusion though.

spenceforce avatar Jun 29 '23 01:06 spenceforce