1111
1212#include "binary_io.h"
1313#include "_remote_debugging.h"
14+ #include "pycore_opcode_utils.h" // MAX_REAL_OPCODE
1415#include <string.h>
1516
1617#ifdef HAVE_ZSTD
@@ -410,12 +411,13 @@ writer_intern_string(BinaryWriter *writer, PyObject *string, uint32_t *index)
410411}
411412
412413static inline int
413- writer_intern_frame (BinaryWriter * writer , uint32_t filename_idx , uint32_t funcname_idx ,
414- int32_t lineno , int32_t end_lineno , int32_t column , int32_t end_column ,
415- uint8_t opcode , uint32_t * index )
414+ writer_intern_frame (BinaryWriter * writer , const FrameEntry * entry , uint32_t * index )
416415{
417416 FrameKey lookup_key = {
418- filename_idx , funcname_idx , lineno , end_lineno , column , end_column , opcode
417+ entry -> filename_idx , entry -> funcname_idx ,
418+ entry -> lineno , entry -> end_lineno ,
419+ entry -> column , entry -> end_column ,
420+ entry -> opcode
419421 };
420422
421423 void * existing = _Py_hashtable_get (writer -> frame_hash , & lookup_key );
@@ -437,14 +439,7 @@ writer_intern_frame(BinaryWriter *writer, uint32_t filename_idx, uint32_t funcna
437439 * key = lookup_key ;
438440
439441 * index = (uint32_t )writer -> frame_count ;
440- FrameEntry * fe = & writer -> frame_entries [writer -> frame_count ];
441- fe -> filename_idx = filename_idx ;
442- fe -> funcname_idx = funcname_idx ;
443- fe -> lineno = lineno ;
444- fe -> end_lineno = end_lineno ;
445- fe -> column = column ;
446- fe -> end_column = end_column ;
447- fe -> opcode = opcode ;
442+ writer -> frame_entries [writer -> frame_count ] = * entry ;
448443
449444 if (_Py_hashtable_set (writer -> frame_hash , key , (void * )(uintptr_t )(* index + 1 )) < 0 ) {
450445 PyMem_Free (key );
@@ -853,7 +848,7 @@ build_frame_stack(BinaryWriter *writer, PyObject *frame_list,
853848
854849 if (location != Py_None ) {
855850 /* LocationInfo is a struct sequence or tuple with:
856- * (lineno, end_lineno, col_offset, end_col_offset ) */
851+ * (lineno, end_lineno, column, end_column ) */
857852 PyObject * lineno_obj = PyTuple_Check (location ) ?
858853 PyTuple_GET_ITEM (location , 0 ) :
859854 PyStructSequence_GET_ITEM (location , 0 );
@@ -880,7 +875,7 @@ build_frame_stack(BinaryWriter *writer, PyObject *frame_list,
880875 if (UNLIKELY (PyErr_Occurred () != NULL )) {
881876 PyErr_Clear ();
882877 opcode = OPCODE_NONE ;
883- } else if (opcode_long >= 0 && opcode_long <= 254 ) {
878+ } else if (opcode_long >= 0 && opcode_long <= MAX_REAL_OPCODE ) {
884879 opcode = (uint8_t )opcode_long ;
885880 }
886881 }
@@ -898,10 +893,17 @@ build_frame_stack(BinaryWriter *writer, PyObject *frame_list,
898893 }
899894
900895 /* Intern frame with full location info */
896+ FrameEntry frame_entry = {
897+ .filename_idx = filename_idx ,
898+ .funcname_idx = funcname_idx ,
899+ .lineno = lineno ,
900+ .end_lineno = end_lineno ,
901+ .column = column ,
902+ .end_column = end_column ,
903+ .opcode = opcode
904+ };
901905 uint32_t frame_idx ;
902- if (writer_intern_frame (writer , filename_idx , funcname_idx ,
903- lineno , end_lineno , column , end_column ,
904- opcode , & frame_idx ) < 0 ) {
906+ if (writer_intern_frame (writer , & frame_entry , & frame_idx ) < 0 ) {
905907 return -1 ;
906908 }
907909
0 commit comments