Get the latest tech news
Debugging running Python scripts with PDB via GDB
Disconnect3d's blog.
A friend of mine had an interesting case recently where they wanted to debug an already running Python script on Linux and after some testing it turned out this is possible, so let’s see how it can be done in CPython :). I have only tested this method on Python 3.11.6 and generally speaking, I am not sure if this doesn’t corrupt the internal CPython state somehow – and if it does – this could end up crashing our script. I would also like to thanks Ian Smith from Trail of Bits for an interesting problem to solve and ptrtofuture from justCatTheFish team for showing me a similar technique in the past :)
Or read this on Hacker News