What is frame?● 儲存 function 執行時的相關資訊，如區域變數、函數位址等資訊。● 作用像 C 的 call stack( run-time stack )。
PyFrameObjectf_back next outer frame object (this frame’s caller)f_code code object being executed in this framef_exc_traceback traceback if raised in this frame, or Nonef_exc_type exception type if raised in this frame, or Nonef_exc_value exception value if raised in this frame, or Nonef_globals global namespace seen by this framef_lineno current line number in Python source codef_locals local namespace seen by this framef_trace tracing function for this frame, or NoneREF: http://docs.python.org/2/library/inspect.html
More Detailsf_trace, if not None, is a function called at the start of each source code line(this is used by the debugger)f_lineno is the current line number of the frame — writing to this from within atrace function jumps to the given line (only for the bottom-most frame).
sys._getframe([depth])¶Return a frame object from the call stack. If optional integer depth is given,return the frame object that many calls below the top of the stack. If that isdeeper than the call stack, ValueError is raised. The default for depthis zero,returning the frame at the top of the call stack.sys.settrace(tracefunc)Set the system’s trace function, which allows you to implement a Python sourcecode debugger in Python. The function is thread-specific; for a debugger tosupport multiple threads, it must be registered using settrace() for each threadbeing debugged.
why?it must be registered using settrace() for each thread being debugged.Because: each thread have their own starck. In the python, the stack meansthe frame.processthreadprocessthread thread thread
recoverable_pdb● github: https://github.com/ya790206/recoverable_pdb● Like time machine, you can recover the runtime to thepoint you save.● addition command:○ save point_name: save the current frame to the point.○ restore point_name: restore frame from the frame yousaved.○ diff point_name: compare the current frame and theanother you saved.● limit:○ same as jump command.○ it cant recover file or database.