Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-106597: Add debugging struct with offsets for out-of-process tools#106598
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -53,12 +53,101 @@ typedef struct _Py_AuditHookEntry { | ||
| void *userData; | ||
| } _Py_AuditHookEntry; | ||
| typedef struct _Py_DebugOffsets { | ||
pablogsal marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page.
pablogsal marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| char cookie[8]; | ||
| uint64_t version; | ||
| // Runtime state offset; | ||
| struct _runtime_state { | ||
| off_t finalizing; | ||
| off_t interpreters_head; | ||
| } runtime_state; | ||
| // Interpreter state offset; | ||
| struct _interpreter_state { | ||
| off_t next; | ||
| off_t threads_head; | ||
| off_t gc; | ||
| off_t imports_modules; | ||
| off_t sysdict; | ||
| off_t builtins; | ||
| off_t ceval_gil; | ||
| off_t gil_runtime_state_locked; | ||
| off_t gil_runtime_state_holder; | ||
| } interpreter_state; | ||
| // Thread state offset; | ||
| struct _thread_state{ | ||
| off_t prev; | ||
| off_t next; | ||
| off_t interp; | ||
| off_t cframe; | ||
| off_t thread_id; | ||
| off_t native_thread_id; | ||
| } thread_state; | ||
| // InterpreterFrame offset; | ||
| struct _interpreter_frame { | ||
| off_t previous; | ||
| off_t executable; | ||
| off_t prev_instr; | ||
| off_t localsplus; | ||
| off_t owner; | ||
| } interpreter_frame; | ||
| // CFrame offset; | ||
| struct _cframe { | ||
| off_t current_frame; | ||
| off_t previous; | ||
| } cframe; | ||
| // Code object offset; | ||
| struct _code_object { | ||
| off_t filename; | ||
| off_t name; | ||
| off_t linetable; | ||
| off_t firstlineno; | ||
| off_t argcount; | ||
| off_t localsplusnames; | ||
| off_t localspluskinds; | ||
| off_t co_code_adaptive; | ||
| } code_object; | ||
| // PyObject offset; | ||
| struct _pyobject { | ||
| off_t ob_type; | ||
| } pyobject; | ||
| // PyTypeObject object offset; | ||
| struct _type_object { | ||
| off_t tp_name; | ||
| } type_object; | ||
| // PyTuple object offset; | ||
| struct _tuple_object { | ||
| off_t ob_item; | ||
| } tuple_object; | ||
| } _Py_DebugOffsets; | ||
| /* Full Python runtime state */ | ||
| /* _PyRuntimeState holds the global state for the CPython runtime. | ||
| That data is exposed in the internal API as a static variable (_PyRuntime). | ||
| */ | ||
| typedef struct pyruntimestate { | ||
| /* This field must be first to facilitate locating it by out of process | ||
| * debuggers. Out of process debuggers will use the offsets contained in this | ||
| * field to be able to locate other fields in several interpreter structures | ||
| * in a way that doesn't require them to know the exact layout of those | ||
| * structures. | ||
| * | ||
| * IMPORTANT: | ||
| * This struct is **NOT** backwards compatible between minor version of the | ||
| * interpreter and the members, order of members and size can change between | ||
| * minor versions. This struct is only guaranteed to be stable between patch | ||
| * versions for a given minor version of the interpreter. | ||
| */ | ||
| _Py_DebugOffsets debug_offsets; | ||
| /* Has been initialized to a safe state. | ||
| In order to be effective, this must be set to 0 during or right | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletionsMisc/NEWS.d/next/Core and Builtins/2023-07-10-15-30-45.gh-issue-106597.WAZ14y.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| A new debug structure of offsets has been added to the ``_PyRuntimeState`` | ||
| that will help out-of-process debuggers and profilers to obtain the offsets | ||
| to relevant interpreter structures in a way that is agnostic of how Python | ||
| was compiled and that doesn't require copying the headers. Patch by Pablo | ||
| Galindo |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.