Skip to content

Commit 69ed0ff

Browse files
committed
More debugging
1 parent fce1ca4 commit 69ed0ff

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Modules/_remote_debugging_module.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,51 @@ parse_frame_object(
21172117
}
21182118
#endif
21192119

2120+
// struct _PyInterpreterFrame {
2121+
// _PyStackRef f_executable; /* Deferred or strong reference (code object or None) */
2122+
// struct _PyInterpreterFrame *previous;
2123+
// _PyStackRef f_funcobj; /* Deferred or strong reference. Only valid if not on C stack */
2124+
// PyObject *f_globals; /* Borrowed reference. Only valid if not on C stack */
2125+
// PyObject *f_builtins; /* Borrowed reference. Only valid if not on C stack */
2126+
// PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */
2127+
// PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */
2128+
// _Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to begin) */
2129+
// _PyStackRef *stackpointer;
2130+
// #ifdef Py_GIL_DISABLED
2131+
// /* Index of thread-local bytecode containing instr_ptr. */
2132+
// int32_t tlbc_index;
2133+
// #endif
2134+
// uint16_t return_offset; /* Only relevant during a function call */
2135+
// char owner;
2136+
// #ifdef Py_DEBUG
2137+
// uint8_t visited:1;
2138+
// uint8_t lltrace:7;
2139+
// #else
2140+
// uint8_t visited;
2141+
// #endif
2142+
// /* Locals and stack */
2143+
// _PyStackRef localsplus[1];
2144+
// };
2145+
_PyInterpreterFrame *frame_ptr = (_PyInterpreterFrame *)frame;
2146+
// Print all fields for debugging purposes
2147+
printf("Frame at %p:\n", (void*)address);
2148+
printf(" f_executable: %p\n", (void*)frame_ptr->f_executable.bits);
2149+
printf(" previous: %p\n", (void*)frame_ptr->previous);
2150+
printf(" f_funcobj: %p\n", (void*)frame_ptr->f_funcobj.bits);
2151+
printf(" f_globals: %p\n", (void*)frame_ptr->f_globals);
2152+
printf(" f_builtins: %p\n", (void*)frame_ptr->f_builtins);
2153+
printf(" f_locals: %p\n", (void*)frame_ptr->f_locals);
2154+
printf(" frame_obj: %p\n", (void*)frame_ptr->frame_obj);
2155+
printf(" instr_ptr: %p\n", (void*)frame_ptr->instr_ptr);
2156+
printf(" stackpointer: %p\n", (void*)frame_ptr->stackpointer);
2157+
#ifdef Py_GIL_DISABLED
2158+
printf(" tlbc_index: %d\n", frame_ptr->tlbc_index);
2159+
#endif
2160+
printf(" return_offset: %d\n", frame_ptr->return_offset);
2161+
printf(" owner: %d\n", frame_ptr->owner);
2162+
printf(" visited: %d\n", frame_ptr->visited);
2163+
printf(" localsplus: %p\n", (void*)frame_ptr->localsplus);
2164+
21202165
return parse_code_object(
21212166
unwinder, result, GET_MEMBER(uintptr_t, frame, unwinder->debug_offsets.interpreter_frame.executable),
21222167
instruction_pointer, previous_frame, tlbc_index);

0 commit comments

Comments
 (0)