mirror of
https://github.com/python/cpython.git
synced 2026-05-03 00:58:30 +00:00
gh-143946: Show JitOptSymbol on abstract stack when set PYTHON_OPT_DEBUG > 4 (GH-143957)
This commit is contained in:
parent
7e28ae550f
commit
61ec66acd5
5 changed files with 123 additions and 22 deletions
|
|
@ -39,6 +39,7 @@
|
|||
#ifdef Py_DEBUG
|
||||
extern const char *_PyUOpName(int index);
|
||||
extern void _PyUOpPrint(const _PyUOpInstruction *uop);
|
||||
extern void _PyUOpSymPrint(JitOptRef ref);
|
||||
static const char *const DEBUG_ENV = "PYTHON_OPT_DEBUG";
|
||||
static inline int get_lltrace(void) {
|
||||
char *uop_debug = Py_GETENV(DEBUG_ENV);
|
||||
|
|
@ -50,6 +51,38 @@
|
|||
}
|
||||
#define DPRINTF(level, ...) \
|
||||
if (get_lltrace() >= (level)) { printf(__VA_ARGS__); }
|
||||
|
||||
|
||||
|
||||
static void
|
||||
dump_abstract_stack(_Py_UOpsAbstractFrame *frame, JitOptRef *stack_pointer)
|
||||
{
|
||||
JitOptRef *stack_base = frame->stack;
|
||||
JitOptRef *locals_base = frame->locals;
|
||||
printf(" locals=[");
|
||||
for (JitOptRef *ptr = locals_base; ptr < stack_base; ptr++) {
|
||||
if (ptr != locals_base) {
|
||||
printf(", ");
|
||||
}
|
||||
_PyUOpSymPrint(*ptr);
|
||||
}
|
||||
printf("]\n");
|
||||
if (stack_pointer < stack_base) {
|
||||
printf(" stack=%d\n", (int)(stack_pointer - stack_base));
|
||||
}
|
||||
else {
|
||||
printf(" stack=[");
|
||||
for (JitOptRef *ptr = stack_base; ptr < stack_pointer; ptr++) {
|
||||
if (ptr != stack_base) {
|
||||
printf(", ");
|
||||
}
|
||||
_PyUOpSymPrint(*ptr);
|
||||
}
|
||||
printf("]\n");
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
#else
|
||||
#define DPRINTF(level, ...)
|
||||
#endif
|
||||
|
|
@ -383,7 +416,10 @@ optimize_uops(
|
|||
if (get_lltrace() >= 3) {
|
||||
printf("%4d abs: ", (int)(this_instr - trace));
|
||||
_PyUOpPrint(this_instr);
|
||||
printf(" ");
|
||||
printf(" \n");
|
||||
if (get_lltrace() >= 5 && !CURRENT_FRAME_IS_INIT_SHIM()) {
|
||||
dump_abstract_stack(ctx->frame, stack_pointer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue