I know how to use PyCharm's debugger but that has only deepened my curiosity of how it accomplishes the task of being so tightly coupled to the Python interpreter.
Does cPython have some sort of intrepreter hooks buried in itself or does PyCharm somehow copy the source code, instrument the code, and then exec it?
Thanks to @unholySheep I was able to go from the github src on PyDev.Debugger back to sys.settrace which lead to a post on Python Module of the week on settrace.
Once the tracing script has the stack frame, it is likely a non-trivial task of inspecting the frame's stack content and or using code/exec/eval
to run "watch" statements in context. As for break points, that would be trivial as it is just a task of matching the frame's line number and filepath.
来源:https://stackoverflow.com/questions/54026890/how-does-pycharm-work-how-did-they-hook-into-the-interpreter