Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c0f200

Browse files
committed
Move call_trace(..., PyTrace_CALL, ...) call to top of eval_frame. That
way it's called each time a generator is resumed. The tracing of normal functions should be unaffected by this change.
1 parent 1b41079 commit 6c0f200

1 file changed

Lines changed: 35 additions & 35 deletions

File tree

Python/ceval.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,41 @@ eval_frame(PyFrameObject *f)
588588
assert(stack_pointer != NULL);
589589
f->f_stacktop = NULL;
590590

591+
if (tstate->use_tracing) {
592+
if (tstate->c_tracefunc != NULL) {
593+
/* tstate->c_tracefunc, if defined, is a
594+
function that will be called on *every* entry
595+
to a code block. Its return value, if not
596+
None, is a function that will be called at
597+
the start of each executed line of code.
598+
(Actually, the function must return itself
599+
in order to continue tracing.) The trace
600+
functions are called with three arguments:
601+
a pointer to the current frame, a string
602+
indicating why the function is called, and
603+
an argument which depends on the situation.
604+
The global trace function is also called
605+
whenever an exception is detected. */
606+
if (call_trace(tstate->c_tracefunc, tstate->c_traceobj,
607+
f, PyTrace_CALL, Py_None)) {
608+
/* XXX Need way to compute arguments?? */
609+
/* Trace function raised an error */
610+
return NULL;
611+
}
612+
}
613+
if (tstate->c_profilefunc != NULL) {
614+
/* Similar for c_profilefunc, except it needn't
615+
return itself and isn't called for "line" events */
616+
if (call_trace(tstate->c_profilefunc,
617+
tstate->c_profileobj,
618+
f, PyTrace_CALL, Py_None)) {
619+
/* XXX Need way to compute arguments?? */
620+
/* Profile function raised an error */
621+
return NULL;
622+
}
623+
}
624+
}
625+
591626
#ifdef LLTRACE
592627
lltrace = PyDict_GetItemString(f->f_globals,"__lltrace__") != NULL;
593628
#endif
@@ -2496,41 +2531,6 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
24962531
}
24972532
}
24982533

2499-
if (tstate->use_tracing) {
2500-
if (tstate->c_tracefunc != NULL) {
2501-
/* tstate->c_tracefunc, if defined, is a
2502-
function that will be called on *every* entry
2503-
to a code block. Its return value, if not
2504-
None, is a function that will be called at
2505-
the start of each executed line of code.
2506-
(Actually, the function must return itself
2507-
in order to continue tracing.) The trace
2508-
functions are called with three arguments:
2509-
a pointer to the current frame, a string
2510-
indicating why the function is called, and
2511-
an argument which depends on the situation.
2512-
The global trace function is also called
2513-
whenever an exception is detected. */
2514-
if (call_trace(tstate->c_tracefunc, tstate->c_traceobj,
2515-
f, PyTrace_CALL, Py_None)) {
2516-
/* XXX Need way to compute arguments?? */
2517-
/* Trace function raised an error */
2518-
goto fail;
2519-
}
2520-
}
2521-
if (tstate->c_profilefunc != NULL) {
2522-
/* Similar for c_profilefunc, except it needn't
2523-
return itself and isn't called for "line" events */
2524-
if (call_trace(tstate->c_profilefunc,
2525-
tstate->c_profileobj,
2526-
f, PyTrace_CALL, Py_None)) {
2527-
/* XXX Need way to compute arguments?? */
2528-
/* Profile function raised an error */
2529-
goto fail;
2530-
}
2531-
}
2532-
}
2533-
25342534
if (co->co_flags & CO_GENERATOR) {
25352535
/* Don't need to keep the reference to f_back, it will be set
25362536
* when the generator is resumed. */

0 commit comments

Comments
 (0)