@@ -110,40 +110,80 @@ int print_extra_pkt_info(bool datadump_enable, const char *pkt_data, int len,
110110 char * buf , int buf_len , u8 direction );
111111
112112/**
113- * @brief **extended_resolve_frame()** Resolve a custom/interpreter frame
114- * @param pid Process ID
115- * @param addr Frame address/ID
116- * @param frame_type Frame type identifier
117- * @param extra_a Extra data A from stack map
118- * @param extra_b Extra data B from stack map
119- * @return Resolved symbol string (must be freed) or NULL
113+ * @brief Structured interpreter symbol info for per-frame extraction.
114+ * Matches the Rust CSymbolInfo layout (#[repr(C)]).
120115 */
121- char * extended_resolve_frame (int pid , u64 addr , u8 frame_type , u64 extra_a , u64 extra_b );
116+ #ifndef INTERP_SYMBOL_INFO_DEFINED
117+ #define INTERP_SYMBOL_INFO_DEFINED
118+ typedef struct {
119+ u32 frame_type ; // FRAME_TYPE_PHP/V8/LUA/PYTHON
120+ char * function_name ; // allocated via clib_mem_alloc
121+ char * class_name ; // allocated via clib_mem_alloc (or NULL)
122+ u32 lineno ;
123+ char * file_name ; // allocated via clib_mem_alloc (or NULL)
124+ u32 sub_type ; // language-specific sub-type
125+ u8 is_jit ; // 1 = JIT-compiled frame
126+ u64 raw_addr ; // original address
127+ u8 resolve_failed ; // 1 = resolution failed
128+ } interp_symbol_info_t ;
129+ #endif
122130
123131/**
124- * @brief **extended_merge_stacks()** Merge interpreter and user stacks
125- * @param dst Destination buffer
126- * @param len Buffer length
127- * @param i_trace Interpreter stack string
128- * @param u_trace User stack string
132+ * @brief **extended_extract_interpreter_frames()** Extract structured interpreter frames
129133 * @param pid Process ID
130- * @return Bytes written
134+ * @param frame_types Array of frame types from BPF map
135+ * @param addrs Array of frame addresses
136+ * @param extra_data_a Array of extra data A values
137+ * @param extra_data_b Array of extra data B values
138+ * @param frame_count Number of frames in arrays
139+ * @param tracer BPF tracer handle (for Lua)
140+ * @param new_cache Whether this is a new cache entry (for Lua)
141+ * @param info_p Process info pointer (for Lua)
142+ * @param out_frames Output array of interp_symbol_info_t (caller-allocated)
143+ * @param max_out Maximum output frames
144+ * @return Number of frames written to out_frames
145+ */
146+ int extended_extract_interpreter_frames (int pid ,
147+ const u8 * frame_types ,
148+ const u64 * addrs ,
149+ const u64 * extra_data_a ,
150+ const u64 * extra_data_b ,
151+ int frame_count ,
152+ void * tracer ,
153+ bool new_cache ,
154+ void * info_p ,
155+ interp_symbol_info_t * out_frames ,
156+ int max_out );
157+
158+ /**
159+ * @brief **extended_free_interp_frames()** Free memory owned by interp_symbol_info_t array
160+ * @param frames Array of interp_symbol_info_t
161+ * @param count Number of entries
131162 */
132- int extended_merge_stacks ( char * dst , int len , const char * i_trace , const char * u_trace , int pid );
163+ void extended_free_interp_frames ( interp_symbol_info_t * frames , int count );
133164
134165/**
135- * @brief **extended_format_lua_stack()** Format Lua interpreter stack frames
166+ * @brief **extended_extract_structured_frames()** High-level extraction for a stack trace
167+ *
168+ * Reads user and interpreter BPF stack maps, extracts structured interpreter
169+ * frame symbols via per-symbol cache + extract functions.
170+ *
136171 * @param tracer BPF tracer handle
137- * @param pid Process ID
138- * @param stack_id Interpreter stack ID from BPF map
139- * @param stack_map_name Name of the stack map
140- * @param h Stack string hash table
141- * @param new_cache Whether to create new cache entry
172+ * @param tgid Process ID (for cache lookup and process type detection)
173+ * @param user_stack_id User stack ID from BPF map (-1 if none)
174+ * @param interp_stack_id Interpreter stack ID from BPF map (-1 if none)
175+ * @param custom_stack_map_name Name of the custom stack map
176+ * @param new_cache Whether cache entry is new
142177 * @param info_p Process info pointer
143- * @return Formatted stack string (caller must free) or NULL
178+ * @param out_frames Caller-allocated output array
179+ * @param max_out Maximum output frame count
180+ * @return Number of frames written to out_frames
144181 */
145- char * extended_format_lua_stack (void * tracer , int pid , int stack_id ,
146- const char * stack_map_name , void * h ,
147- bool new_cache , void * info_p );
182+ int extended_extract_structured_frames (void * tracer , int tgid ,
183+ int user_stack_id , int interp_stack_id ,
184+ const char * custom_stack_map_name ,
185+ bool new_cache , void * info_p ,
186+ interp_symbol_info_t * out_frames ,
187+ int max_out );
148188
149189#endif /* DF_EXTENDED_H */
0 commit comments