You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
f_trace_opcodes frame attribute to switch to per-opcode tracing #75525
In order to test bpo-29988 reliably, we want the ability to run trace hooks for every opcode in a frame, rather than for every line.
The simplest API we've been able to come up with for that is a "f_trace_opcodes" attribute on the frame which we set from the trace hook the first time that it runs.
The f_trace attribute is writable from a tracing function. There are different restrictions, for example you can't jump inside a 'for' loop from outside. The code of the setter is complex and hard for modifications (see the discussion on PR 2827). Allowing to trace opcodes can make it more complex.
Steve's also requested the ability to *turn off* line debugging, and I'm thinking it may make sense to allow all four configurations:
both line and opcode events disabled
only getting one or the other
getting both kinds of event
Opcode events would definitely be off by default, and if you do turn them on, then you'd be in a situation similar to importing ctypes: the interpreter is no longer guaranteed to work correctly. (Although unlike ctypes, you shouldn't get segfaults because of it)
My posted PR implements the "independent flags" option, where f_trace_lines and f_trace_opcodes allow per-line and per-opcode events to be requested independently.
The default is to emit per-line events (as has historically been the case).
Activity
ncoghlan commentedon Sep 4, 2017
In order to test bpo-29988 reliably, we want the ability to run trace hooks for every opcode in a frame, rather than for every line.
The simplest API we've been able to come up with for that is a "f_trace_opcodes" attribute on the frame which we set from the trace hook the first time that it runs.
serhiy-storchaka commentedon Sep 5, 2017
The f_trace attribute is writable from a tracing function. There are different restrictions, for example you can't jump inside a 'for' loop from outside. The code of the setter is complex and hard for modifications (see the discussion on PR 2827). Allowing to trace opcodes can make it more complex.
njsmith commentedon Sep 5, 2017
Adding Ned to CC in case he wants to comment on the utility of per-opcode tracing from the perspective of coverage.py.
ncoghlan commentedon Sep 5, 2017
Steve's also requested the ability to *turn off* line debugging, and I'm thinking it may make sense to allow all four configurations:
Opcode events would definitely be off by default, and if you do turn them on, then you'd be in a situation similar to importing ctypes: the interpreter is no longer guaranteed to work correctly. (Although unlike ctypes, you shouldn't get segfaults because of it)
ncoghlan commentedon Sep 7, 2017
My posted PR implements the "independent flags" option, where f_trace_lines and f_trace_opcodes allow per-line and per-opcode events to be requested independently.
The default is to emit per-line events (as has historically been the case).
ncoghlan commentedon Sep 8, 2017
New changeset 5a85167 by Nick Coghlan in branch 'master':
bpo-31344: Per-frame control of trace events (GH-3417)
5a85167