Let tools know when tracing/profiling is enabled/disabled

While audit hooks notify us when sys.setprofile/sys.settrace is called, they do not report the argument passed to these functions. This means we cannot distinguish between tracing/profiling being enabled (a function is set) versus disabled (cleared with None).
This forces tools that want different behavior based on tracing/profiling enablement (e.g. JIT compilers) to poll on every function call, adding significant overhead. PEP-523 established frame evaluation hooks as an officially supported extension point. However, tools using this API have no efficient way to know when tracing/profiling is enabled/disabled.

For example, it’s difficult for a JIT to support debugging/profiling workflows. The simplest solution would be for the JIT may just want to fall back to the interpreter when tracing/profiling is enabled.

I propose adding a small C API enhancement allowing callbacks to be registered when trace/profile functions are set or cleared (PR).
Alternatively, if we modify audit hooks to report the argument in addition to the sys.setprofile/sys.settrace event then that would be sufficient as well. Since audit hooks run before the function completes, just knowing if sys.setprofile/sys.settrace was called isn’t enough to know if tracing/profiling is enabled.