I have been reading about the sys.monitoring API that has been released for Python 3.12. I understand a bit of its working and can point sys.breakpointhook to my own function and print out simple debugging information.
I now want to pause the execution of my script when I hit a breakpoint instead of just printing out information but cannot understand how this can be implemented. Let us just say, I am trying to implement a very basic debugger myself. I know that there are ready to use debuggers out there but I want to understand how they work so I would like to try and implement one myself.
It would be great if someone could point out how Bdb does it as I have browsed the source but haven't figured out much. Is there a sys module call that is used to do this?
code.interact()? It is mentioned on docs.python.org/3/library/pdb.html#pdbcommand-interact. It blocks execution, allows you to run debugging commands, e.g.locals().keys()then you Ctrl D to drop back into normal executioncode.interact(). I think most debuggers at some level flash a banner and then block usinginput()or an equivalent. I will see if this is sufficient for me to get started.