Refined section on logging to one file from multiple processes.
[python.git] / Include / frameobject.h
blob17e7679ac870f0cabe67d05b85fc5a42e230f1d1
2 /* Frame object interface */
4 #ifndef Py_FRAMEOBJECT_H
5 #define Py_FRAMEOBJECT_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 typedef struct {
11 int b_type; /* what kind of block this is */
12 int b_handler; /* where to jump to find handler */
13 int b_level; /* value stack level to pop to */
14 } PyTryBlock;
16 typedef struct _frame {
17 PyObject_VAR_HEAD
18 struct _frame *f_back; /* previous frame, or NULL */
19 PyCodeObject *f_code; /* code segment */
20 PyObject *f_builtins; /* builtin symbol table (PyDictObject) */
21 PyObject *f_globals; /* global symbol table (PyDictObject) */
22 PyObject *f_locals; /* local symbol table (any mapping) */
23 PyObject **f_valuestack; /* points after the last local */
24 /* Next free slot in f_valuestack. Frame creation sets to f_valuestack.
25 Frame evaluation usually NULLs it, but a frame that yields sets it
26 to the current stack top. */
27 PyObject **f_stacktop;
28 PyObject *f_trace; /* Trace function */
30 /* If an exception is raised in this frame, the next three are used to
31 * record the exception info (if any) originally in the thread state. See
32 * comments before set_exc_info() -- it's not obvious.
33 * Invariant: if _type is NULL, then so are _value and _traceback.
34 * Desired invariant: all three are NULL, or all three are non-NULL. That
35 * one isn't currently true, but "should be".
37 PyObject *f_exc_type, *f_exc_value, *f_exc_traceback;
39 PyThreadState *f_tstate;
40 int f_lasti; /* Last instruction if called */
41 /* Call PyFrame_GetLineNumber() instead of reading this field
42 directly. As of 2.3 f_lineno is only valid when tracing is
43 active (i.e. when f_trace is set). At other times we use
44 PyCode_Addr2Line to calculate the line from the current
45 bytecode index. */
46 int f_lineno; /* Current line number */
47 int f_iblock; /* index in f_blockstack */
48 PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
49 PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
50 } PyFrameObject;
53 /* Standard object interface */
55 PyAPI_DATA(PyTypeObject) PyFrame_Type;
57 #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
58 #define PyFrame_IsRestricted(f) \
59 ((f)->f_builtins != (f)->f_tstate->interp->builtins)
61 PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
62 PyObject *, PyObject *);
65 /* The rest of the interface is specific for frame objects */
67 /* Block management functions */
69 PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int);
70 PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *);
72 /* Extend the value stack */
74 PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int);
76 /* Conversions between "fast locals" and locals in dictionary */
78 PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int);
79 PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
81 PyAPI_FUNC(int) PyFrame_ClearFreeList(void);
83 /* Return the line of code the frame is currently executing. */
84 PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
86 #ifdef __cplusplus
88 #endif
89 #endif /* !Py_FRAMEOBJECT_H */