8000 gh-116750: Add clear_tool_id function to unregister events and callbacks by gaogaotiantian · Pull Request #124568 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-116750: Add clear_tool_id function to unregister events and callbacks #124568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 1, 2024
Prev Previous commit
Next Next commit
Revert "Only set tool verions for external tool ids"
This reverts commit fd74a55.
  • Loading branch information
gaogaotiantian committed Sep 27, 2024
commit 82b42ec3fed0d189020d2fc8e673572b12b366c2
6 changes: 3 additions & 3 deletions Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
extern "C" {
#endif

/* Total tool ids available for external use */
#define _PY_MONITORING_EXTENAL_TOOL_IDS 6
/* Total tool ids available */
#define _PY_MONITORING_TOOL_IDS 8
/* Count of all local monitoring events */
#define _PY_MONITORING_LOCAL_EVENTS 10
/* Count of all "real" monitoring events (not derived from other events) */
Expand Down Expand Up @@ -60,7 +60,7 @@ typedef struct {
/* The tools that are to be notified for events for the matching code unit */
uint8_t *tools;
/* The version of tools when they instrument the code */
uintptr_t tool_versions[_PY_MONITORING_EXTENAL_TOOL_IDS];
uintptr_t tool_versions[_PY_MONITORING_TOOL_IDS];
/* Information to support line events */
_PyCoLineInstrumentationData *lines;
/* The tools that are to be notified for line events for the matching code unit */
Expand Down
3 changes: 1 addition & 2 deletions Include/internal/pycore_interp.h
Original file line number Diff 8000 line number Diff line change
Expand Up @@ -272,8 +272,7 @@ struct _is {
Py_ssize_t sys_tracing_threads; /* Count of threads with c_tracefunc set */
PyObject *monitoring_callables[PY_MONITORING_TOOL_IDS][_PY_MONITORING_EVENTS];
PyObject *monitoring_tool_names[PY_MONITORING_TOOL_IDS];
// Only external available tool ids need versioning.
uintptr_t monitoring_tool_versions[PY_MONITORING_SYS_PROFILE_ID];
uintptr_t monitoring_tool_versions[PY_MONITORING_TOOL_IDS];

struct _Py_interp_cached_objects cached_objects;
struct _Py_interp_static_objects static_objects;
Expand Down
2 changes: 1 addition & 1 deletion Python/instrumentation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ update_instrumentation_data(PyCodeObject *code, PyInterpreterState *interp)
}
// If the local monitors are out of date, clear them up
_Py_LocalMonitors *local_monitors = &code->_co_monitoring->local_monitors;
for (int i = 0; i < PY_MONITORING_SYS_PROFILE_ID; i++) {
for (int i = 0; i < PY_MONITORING_TOOL_IDS; i++) {
if (code->_co_monitoring->tool_versions[i] != interp->monitoring_tool_versions[i]) {
for (int j = 0; j < _PY_MONITORING_LOCAL_EVENTS; j++) {
local_monitors->tools[j] &= ~(1 << i);
Expand Down
2 changes: 0 additions & 2 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,6 @@ init_interpreter(PyInterpreterState *interp,
interp->monitoring_callables[t][e] = NULL;

}
}
for (int t = 0; t < PY_MONITORING_SYS_PROFILE_ID; t++) {
interp->monitoring_tool_versions[t] = 0;
}
interp->sys_profile_initialized = false;
Expand Down
Loading
0