Skip to content
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

Add public APIs to set trace and profile function in other threads. #93503

Closed
pablogsal opened this issue Jun 5, 2022 · 0 comments · Fixed by #93504
Closed

Add public APIs to set trace and profile function in other threads. #93503

pablogsal opened this issue Jun 5, 2022 · 0 comments · Fixed by #93504

Comments

@pablogsal
Copy link
Member

Currently, we have two public c-apis to set tracing and profile functions: PyEval_SetProfile and PyEval_SetThreadTrace. This allows to set tracing and profiling functions in the calling thread. This works well, but is, unfortunately, is limited because there is no way for debuggers and profilers to set the tracing and profiling functions in all existing running threads, only the ones that are newly created. This makes it impossible to reliable profile or debug already running applications using public APIs or to allow to activate/deactivate said profilers or debuggers.

There are two exposed APIs that are private (have a leading underscore) that do what we need: _PyEval_SetProfile and _PyEval_SetTrace. Unfortunately, these APIs are not fully public and they don't generate audit events.

I propose to expose public-facing versions of these APIs so profilers and debuggers can set their tracing/profiling functions in all existing threads.

pablogsal added a commit to pablogsal/cpython that referenced this issue Aug 4, 2022
pablogsal added a commit to pablogsal/cpython that referenced this issue Aug 24, 2022
pablogsal added a commit that referenced this issue Aug 24, 2022
…ions in the C-API (#93504)

* gh-93503: Add APIs to set profiling and tracing functions in all threads in the C-API

* Use a separate API

* Fix NEWS entry

* Add locks around the loop

* Document ignoring exceptions

* Use the new APIs in the sys module

* Update docs
pablogsal added a commit to pablogsal/cpython that referenced this issue Sep 8, 2022
pablogsal added a commit that referenced this issue Sep 13, 2022
…ocument (#96681)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant