diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-08-30 17:11:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-30 17:11:18 (GMT) |
commit | 6d791a97364b68d5f9c3514a0470aac487fc538d (patch) | |
tree | 745205d7e8698ea7398eb353311f55dc973507bf /Include | |
parent | 0f733fffe8f4caaac3ce1b5306af86b42fb0c7fa (diff) | |
download | cpython-6d791a97364b68d5f9c3514a0470aac487fc538d.zip cpython-6d791a97364b68d5f9c3514a0470aac487fc538d.tar.gz cpython-6d791a97364b68d5f9c3514a0470aac487fc538d.tar.bz2 |
gh-96143: Allow Linux perf profiler to see Python calls (GH-96123)
:warning: :warning: Note for reviewers, hackers and fellow systems/low-level/compiler engineers :warning: :warning:
If you have a lot of experience with this kind of shenanigans and want to improve the **first** version, **please make a PR against my branch** or **reach out by email** or **suggest code changes directly on GitHub**.
If you have any **refinements or optimizations** please, wait until the first version is merged before starting hacking or proposing those so we can keep this PR productive.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/initconfig.h | 1 | ||||
-rw-r--r-- | Include/internal/pycore_ceval.h | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h index 3b6d593..c6057a4 100644 --- a/Include/cpython/initconfig.h +++ b/Include/cpython/initconfig.h @@ -142,6 +142,7 @@ typedef struct PyConfig { unsigned long hash_seed; int faulthandler; int tracemalloc; + int perf_profiling; int import_time; int code_debug_ranges; int show_ref_count; diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h index 2fcdaad..4914948c 100644 --- a/Include/internal/pycore_ceval.h +++ b/Include/internal/pycore_ceval.h @@ -65,6 +65,27 @@ extern PyObject* _PyEval_BuiltinsFromGlobals( PyThreadState *tstate, PyObject *globals); +// Trampoline API + +typedef struct { + // Callback to initialize the trampoline state + void* (*init_state)(void); + // Callback to register every trampoline being created + void (*write_state)(void* state, const void *code_addr, + unsigned int code_size, PyCodeObject* code); + // Callback to free the trampoline state + int (*free_state)(void* state); +} _PyPerf_Callbacks; + +extern int _PyPerfTrampoline_SetCallbacks(_PyPerf_Callbacks *); +extern void _PyPerfTrampoline_GetCallbacks(_PyPerf_Callbacks *); +extern int _PyPerfTrampoline_Init(int activate); +extern int _PyPerfTrampoline_Fini(void); +extern int _PyIsPerfTrampolineActive(void); +extern PyStatus _PyPerfTrampoline_AfterFork_Child(void); +#ifdef PY_HAVE_PERF_TRAMPOLINE +extern _PyPerf_Callbacks _Py_perfmap_callbacks; +#endif static inline PyObject* _PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag) |