bloomberg / pystack

🔍 🐍 Like pstack but for Python!
https://bloomberg.github.io/pystack
Apache License 2.0
1.01k stars 45 forks source link

Use _Py_DebugOffsets instead of hardcoded offsets when possible #206

Closed godlygeek closed 1 month ago

godlygeek commented 1 month ago

Python 3.13 adds a new _Py_DebugOffsets structure to _PyRuntimeState which tells us more or less everything that we need to know in order to decode the interpreter's data structures. Look for this structure and, if we find it, use the offsets contained in it rather than the offsets compiled into pystack at build time.

This allows us to decode stacks for interpreters with different build time sizes of different structures, including those running in a python3.13t free-threaded interpreter.

godlygeek commented 1 month ago

@pablogsal I've addressed all of your suggestions. I've also rebased this on main, and fixed conflicts that arose due to the fix for handling shim frames. Take another look when you get a chance, please.