diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2017-09-08 00:14:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-08 00:14:16 (GMT) |
commit | 5a8516701f5140c8c989c40e261a4f4e20e8af86 (patch) | |
tree | ce7c8c4d443132b27203a834904469458191a154 /Python/ceval.c | |
parent | 2eb0cb4787d02d995a9bb6dc075983792c12835c (diff) | |
download | cpython-5a8516701f5140c8c989c40e261a4f4e20e8af86.zip cpython-5a8516701f5140c8c989c40e261a4f4e20e8af86.tar.gz cpython-5a8516701f5140c8c989c40e261a4f4e20e8af86.tar.bz2 |
bpo-31344: Per-frame control of trace events (GH-3417)
f_trace_lines: enable/disable line trace events
f_trace_opcodes: enable/disable opcode trace events
These are intended primarily for testing of the interpreter
itself, as they make it much easier to emulate signals
arriving at unfortunate times.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 8fc65cd..a072a5f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4458,12 +4458,19 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj, *instr_lb = bounds.ap_lower; *instr_ub = bounds.ap_upper; } - /* If the last instruction falls at the start of a line or if - it represents a jump backwards, update the frame's line - number and call the trace function. */ - if (frame->f_lasti == *instr_lb || frame->f_lasti < *instr_prev) { + /* Always emit an opcode event if we're tracing all opcodes. */ + if (frame->f_trace_opcodes) { + result = call_trace(func, obj, tstate, frame, PyTrace_OPCODE, Py_None); + } + /* If the last instruction falls at the start of a line or if it + represents a jump backwards, update the frame's line number and + then call the trace function if we're tracing source lines. + */ + if ((frame->f_lasti == *instr_lb || frame->f_lasti < *instr_prev)) { frame->f_lineno = line; - result = call_trace(func, obj, tstate, frame, PyTrace_LINE, Py_None); + if (frame->f_trace_lines) { + result = call_trace(func, obj, tstate, frame, PyTrace_LINE, Py_None); + } } *instr_prev = frame->f_lasti; return result; |