[WIP] Python 3.13 Support
Initial support for python 3.13 . This works as far as getting basic stack traces from python 3.13 programs, but there are still some remaining tasks:
- [x] Line numbers are broken
- [ ] Leverage pyruntime.debug_offsets for figuring out interpreter head location
- [ ] Fix cases where PyInterpreterFrame.f_executable doesn't point to a
PyCodeObject - [ ] Thread names
Exciting! Happy to review this when it's ready, if you want.
@zanieb - that would be great, I'd appreciate it! I'll ping you when its ready
This doesn't fully handle freethreaded/nogil python interpreters - but I'm leaning towards handling that in a separate PR and getting this merged in first - tracked in https://github.com/benfred/py-spy/issues/711 .
One other issue is that the f_executable pointer on the FrameObject can be any arbitrary python object in python3.13 - and not just a PyCodeObject like in older versions of python. This PR is currently just skipping frames where we can't read the filename and function name (indicating a f_executable that isn't a PyCodeObject) -but maybe should instead be checking if the f_executable->ob_type == &PyCode_Type like PyCode_Check does in cpython (?). (The downside to checking the type is that we'd have to figure out the address of PyCode_Type in the target process and pass along to the get_stack_traces function - which might be a bit difficult right now)
@zanieb fyi
Cool I'll review this week.