Extend RemoteUnwinder to capture precise bytecode locations

Introduces LocationInfo struct sequence with end_lineno, col_offset, and
end_col_offset fields. Adds opcodes parameter to RemoteUnwinder that
extracts the currently executing opcode alongside its source span.

Refactors linetable parsing to correctly accumulate line numbers
separately from output values, fixing edge cases in computed_line.
This commit is contained in:
Pablo Galindo Salgado 2025-12-03 03:43:00 +00:00
parent 8801c6dec7
commit dd27e5e679
5 changed files with 146 additions and 46 deletions

View file

@ -157,6 +157,7 @@ typedef struct {
typedef struct {
PyTypeObject *RemoteDebugging_Type;
PyTypeObject *TaskInfo_Type;
PyTypeObject *LocationInfo_Type;
PyTypeObject *FrameInfo_Type;
PyTypeObject *CoroInfo_Type;
PyTypeObject *ThreadInfo_Type;
@ -195,6 +196,7 @@ typedef struct {
int skip_non_matching_threads;
int native;
int gc;
int opcodes;
RemoteDebuggingState *cached_state;
#ifdef Py_GIL_DISABLED
uint32_t tlbc_generation;
@ -248,6 +250,7 @@ typedef int (*set_entry_processor_func)(
* ============================================================================ */
extern PyStructSequence_Desc TaskInfo_desc;
extern PyStructSequence_Desc LocationInfo_desc;
extern PyStructSequence_Desc FrameInfo_desc;
extern PyStructSequence_Desc CoroInfo_desc;
extern PyStructSequence_Desc ThreadInfo_desc;
@ -298,11 +301,20 @@ extern int parse_code_object(
int32_t tlbc_index
);
extern PyObject *make_location_info(
RemoteUnwinderObject *unwinder,
int lineno,
int end_lineno,
int col_offset,
int end_col_offset
);
extern PyObject *make_frame_info(
RemoteUnwinderObject *unwinder,
PyObject *file,
PyObject *line,
PyObject *func
PyObject *location, // LocationInfo structseq or None for synthetic frames
PyObject *func,
PyObject *opcode
);
/* Line table parsing */