spenceforce / pdb-attach

A python debugger that can attach to running processes.
BSD 3-Clause "New" or "Revised" License
30 stars 1 forks source link

Support non-pdb debuggers using `breakpoint()` #24

Open matt-bernstein opened 1 year ago

matt-bernstein commented 1 year ago

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?

spenceforce commented 1 year ago

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.