Skip to content

Commit 1956e66

Browse files
kylewanginchinarvql
authored andcommitted
feat: add Python 3.11/3.12/3.13 support to shared structs
- Add none_struct_addr field to PythonUnwindInfo for Python 3.13+ _Py_NoneStruct sentinel frame detection - Add py_version and py_none_struct_addr fields to unwind_state_t for version-conditional BPF logic
1 parent 317bfb6 commit 1956e66

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

agent/crates/trace-utils/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub struct PythonUnwindInfo {
148148
pub tsd_info: TsdInfo,
149149
pub offsets_id: u8,
150150
pub _padding: [u8; 5],
151+
pub none_struct_addr: u64, // _Py_NoneStruct address for Python 3.13+, 0 otherwise
151152
}
152153

153154
#[cfg(feature = "enterprise")]

agent/crates/trace-utils/src/trace_utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ typedef struct {
195195
uint16_t version;
196196
tsd_info_t tsd_info;
197197
uint8_t offsets_id;
198-
uint8_t padding[5];
198+
uint8_t _padding[5];
199+
uint64_t none_struct_addr;
199200
} python_unwind_info_t;
200201
#endif
201202

agent/src/ebpf/kernel/perf_profiler.bpf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ typedef struct {
160160

161161
void *py_frame_ptr;
162162
__u8 py_offsets_id;
163+
__u16 py_version; // Python version encoded as 0xMMmm (e.g. 3.11 -> 0x030B)
164+
__u64 py_none_struct_addr; // _Py_NoneStruct address (0 if < 3.13)
163165

164166
void *lua_L_ptr;
165167
__u8 lua_is_jit; // 0: Lua 5.x, 1: LuaJIT
@@ -206,6 +208,8 @@ void reset_unwind_state(unwind_state_t * state)
206208

207209
state->py_frame_ptr = NULL;
208210
state->py_offsets_id = 0;
211+
state->py_version = 0;
212+
state->py_none_struct_addr = 0;
209213
state->luajit_frame = NULL;
210214
state->luajit_bot = NULL;
211215
state->luajit_skip_depth = 0;

0 commit comments

Comments
 (0)