@@ -193,11 +193,8 @@ parse_frame_buffer(
193193 RemoteUnwinderObject * unwinder ,
194194 PyObject * * result ,
195195 const char * frame ,
196- uintptr_t * address_of_code_object ,
197196 uintptr_t * previous_frame
198197) {
199- * address_of_code_object = 0 ;
200-
201198 * previous_frame = GET_MEMBER (uintptr_t , frame , unwinder -> debug_offsets .interpreter_frame .previous );
202199 uintptr_t code_object = GET_MEMBER_NO_TAG (uintptr_t , frame , unwinder -> debug_offsets .interpreter_frame .executable );
203200 int frame_valid = is_frame_valid (unwinder , (uintptr_t )frame , code_object );
@@ -215,8 +212,6 @@ parse_frame_buffer(
215212 }
216213#endif
217214
218- * address_of_code_object = code_object ;
219-
220215 CodeObjectContext code_ctx = {
221216 .code_addr = code_object ,
222217 .instruction_pointer = instruction_pointer ,
@@ -230,7 +225,6 @@ parse_frame_object(
230225 RemoteUnwinderObject * unwinder ,
231226 PyObject * * result ,
232227 uintptr_t address ,
233- uintptr_t * address_of_code_object ,
234228 uintptr_t * previous_frame
235229) {
236230 char frame [SIZEOF_INTERP_FRAME ];
@@ -247,7 +241,7 @@ parse_frame_object(
247241 STATS_INC (unwinder , memory_reads );
248242 STATS_ADD (unwinder , memory_bytes_read , SIZEOF_INTERP_FRAME );
249243
250- return parse_frame_buffer (unwinder , result , frame , address_of_code_object , previous_frame );
244+ return parse_frame_buffer (unwinder , result , frame , previous_frame );
251245}
252246
253247int
@@ -256,41 +250,16 @@ parse_frame_from_chunks(
256250 PyObject * * result ,
257251 uintptr_t address ,
258252 uintptr_t * previous_frame ,
259- uintptr_t * stackpointer ,
260253 StackChunkList * chunks
261254) {
262- void * frame_ptr = find_frame_in_chunks (chunks , address );
263- if (!frame_ptr ) {
255+ const char * frame = find_frame_in_chunks (chunks , address );
256+ if (!frame ) {
264257 PyErr_Format (PyExc_RuntimeError , "Frame at address 0x%lx not found in stack chunks" , address );
265258 set_exception_cause (unwinder , PyExc_RuntimeError , "Frame not found in stack chunks" );
266259 return -1 ;
267260 }
268261
269- char * frame = (char * )frame_ptr ;
270- * previous_frame = GET_MEMBER (uintptr_t , frame , unwinder -> debug_offsets .interpreter_frame .previous );
271- * stackpointer = GET_MEMBER (uintptr_t , frame , unwinder -> debug_offsets .interpreter_frame .stackpointer );
272- uintptr_t code_object = GET_MEMBER_NO_TAG (uintptr_t , frame_ptr , unwinder -> debug_offsets .interpreter_frame .executable );
273- int frame_valid = is_frame_valid (unwinder , (uintptr_t )frame , code_object );
274- if (frame_valid != 1 ) {
275- return frame_valid ;
276- }
277-
278- uintptr_t instruction_pointer = GET_MEMBER (uintptr_t , frame , unwinder -> debug_offsets .interpreter_frame .instr_ptr );
279-
280- // Get tlbc_index for free threading builds
281- int32_t tlbc_index = 0 ;
282- #ifdef Py_GIL_DISABLED
283- if (unwinder -> debug_offsets .interpreter_frame .tlbc_index != 0 ) {
284- tlbc_index = GET_MEMBER (int32_t , frame , unwinder -> debug_offsets .interpreter_frame .tlbc_index );
285- }
286- #endif
287-
288- CodeObjectContext code_ctx = {
289- .code_addr = code_object ,
290- .instruction_pointer = instruction_pointer ,
291- .tlbc_index = tlbc_index ,
292- };
293- return parse_code_object (unwinder , result , & code_ctx );
262+ return parse_frame_buffer (unwinder , result , frame , previous_frame );
294263}
295264
296265/* ============================================================================
@@ -313,7 +282,6 @@ process_frame_chain(
313282 while ((void * )frame_addr != NULL ) {
314283 PyObject * frame = NULL ;
315284 uintptr_t next_frame_addr = 0 ;
316- uintptr_t stackpointer = 0 ;
317285 last_frame_addr = frame_addr ;
318286
319287 if (++ frame_count > MAX_FRAME_CHAIN_DEPTH ) {
@@ -324,28 +292,25 @@ process_frame_chain(
324292 assert (frame_count <= MAX_FRAME_CHAIN_DEPTH );
325293
326294 if (ctx -> chunks && ctx -> chunks -> count > 0 ) {
327- if (parse_frame_from_chunks (unwinder , & frame , frame_addr , & next_frame_addr , & stackpointer , ctx -> chunks ) == 0 ) {
295+ int parse_result = parse_frame_from_chunks (
296+ unwinder , & frame , frame_addr , & next_frame_addr , ctx -> chunks );
297+ if (parse_result == 0 ) {
328298 goto parsed_frame ;
329299 }
330300 PyErr_Clear ();
331301 }
332- {
333- uintptr_t address_of_code_object = 0 ;
334- int parse_result ;
335- if (ctx -> prefetch .frame && ctx -> prefetch .frame_addr == frame_addr ) {
336- parse_result = parse_frame_buffer (
337- unwinder , & frame , ctx -> prefetch .frame ,
338- & address_of_code_object , & next_frame_addr );
339- }
340- else {
341- parse_result = parse_frame_object (
342- unwinder , & frame , frame_addr ,
343- & address_of_code_object , & next_frame_addr );
344- }
345- if (parse_result < 0 ) {
346- set_exception_cause (unwinder , PyExc_RuntimeError , "Failed to parse frame object in chain" );
347- return -1 ;
348- }
302+ int parse_result ;
303+ if (ctx -> prefetch .frame && ctx -> prefetch .frame_addr == frame_addr ) {
304+ parse_result = parse_frame_buffer (
305+ unwinder , & frame , ctx -> prefetch .frame , & next_frame_addr );
306+ }
307+ else {
308+ parse_result = parse_frame_object (
309+ unwinder , & frame , frame_addr , & next_frame_addr );
310+ }
311+ if (parse_result < 0 ) {
312+ set_exception_cause (unwinder , PyExc_RuntimeError , "Failed to parse frame object in chain" );
313+ return -1 ;
349314 }
350315
351316parsed_frame :
@@ -539,17 +504,16 @@ try_full_cache_hit(
539504 }
540505
541506 PyObject * current_frame = NULL ;
542- uintptr_t code_object_addr = 0 ;
543507 uintptr_t previous_frame = 0 ;
544508 int parse_result ;
545509 if (ctx -> prefetch .frame && ctx -> prefetch .frame_addr == ctx -> frame_addr ) {
546510 parse_result = parse_frame_buffer (unwinder , & current_frame ,
547511 ctx -> prefetch .frame ,
548- & code_object_addr , & previous_frame );
512+ & previous_frame );
549513 }
550514 else {
551515 parse_result = parse_frame_object (unwinder , & current_frame , ctx -> frame_addr ,
552- & code_object_addr , & previous_frame );
516+ & previous_frame );
553517 }
554518 if (parse_result < 0 ) {
555519 return -1 ;
0 commit comments