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
As mentioned in #111963, we don't have a way to fully unload the monitoring tool and this is a bad experience for users. Debuggers have to track code objects of their breakpoints if they want to do it with local events. I think we should have a sys.monitoring.clear_tool_id(tool_id: int) to clear up all the residues for the tool without giving up the tool_id. Also sys.monitoring.free_tool_id() should run clear_tool_id first - it's just safer and makes more sense.
Global events should be trivial, by set_events(tool_id, 0) all the global events should be disabled and if the next tool claims the id, it needs to explicitly set them again anyway. Callbacks are easy as they are just in an array.
The hard part is local events, as they are instrumented lazily. Currently we don't have a way to inform the code object that a tool is unloaded(cleared) and we don't track all the instrumented code objects.
I think the way to go is to version the tool and the local monitors. Each time a tool is registered (cleared), a new version number is assigned to the tool (same source of the code object, global_version basically). The increment of the version number will force all the code object to check their instrumentation, and in update_instrumentation_data, we can check whether the local monitors are in sync with the tools. Remove the tool if they are not.
Impacts:
For each _Py_LocalMonitors, another uint32_t versions[PY_MONITORING_TOOL_IDS] to keep the version of the tools
Extra check in update_instrumentation_data
No run-time impact on programs without instrumentation
Feature or enhancement
Proposal:
As mentioned in #111963, we don't have a way to fully unload the monitoring tool and this is a bad experience for users. Debuggers have to track code objects of their breakpoints if they want to do it with local events. I think we should have a
sys.monitoring.clear_tool_id(tool_id: int)
to clear up all the residues for the tool without giving up thetool_id
. Alsosys.monitoring.free_tool_id()
should runclear_tool_id
first - it's just safer and makes more sense.Global events should be trivial, by
set_events(tool_id, 0)
all the global events should be disabled and if the next tool claims the id, it needs to explicitly set them again anyway. Callbacks are easy as they are just in an array.The hard part is local events, as they are instrumented lazily. Currently we don't have a way to inform the code object that a tool is unloaded(cleared) and we don't track all the instrumented code objects.
I think the way to go is to version the tool and the local monitors. Each time a tool is registered (cleared), a new version number is assigned to the tool (same source of the code object, global_version basically). The increment of the version number will force all the code object to check their instrumentation, and in
update_instrumentation_data
, we can check whether the local monitors are in sync with the tools. Remove the tool if they are not.Impacts:
_Py_LocalMonitors
, anotheruint32_t versions[PY_MONITORING_TOOL_IDS]
to keep the version of the toolsupdate_instrumentation_data
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: