8000 gh-91462: Make lltrace output human-readable. by sweeneyde · Pull Request #91463 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-91462: Make lltrace output human-readable. #91463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 16, 2022
Merged
Prev Previous commit
Next Next commit
blank lines, commas, and fflush
  • Loading branch information
sweeneyde committed Apr 16, 2022
commit c69022c4d5f6b1fc012f627cfd5a153ee8d70be8
13 changes: 9 additions & 4 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,19 @@ dump_stack(_PyInterpreterFrame *frame, PyObject **stack_pointer)
PyObject **stack_base = _PyFrame_Stackbase(frame);
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
printf("stack=[");
printf(" stack=[");
for (PyObject **ptr = stack_base; ptr < stack_pointer; ptr++) {
if (ptr != stack_base) {
printf(", ");
}
if (PyObject_Print(*ptr, stdout, 0) != 0) {
PyErr_Clear();
printf("<%s object at %p>",
Py_TYPE(*ptr)->tp_name, (void *)(*ptr));
}
printf(", ");
}
printf("]\n");
fflush(stdout);
PyErr_Restore(type, value, traceback);
}

Expand All @@ -90,13 +93,14 @@ lltrace_instruction(_PyInterpreterFrame *frame,
else {
printf("%d: %s\n", offset * 2, opname);
}
fflush(stdout);
}
static void
lltrace_resume_frame(_PyInterpreterFrame *frame)
{
PyFunctionObject *f = frame->f_func;
if (f == NULL) {
printf("Resuming frame.");
printf("\nResuming frame.");
return;
}
PyObject *type, *value, *traceback;
Expand All @@ -105,7 +109,7 @@ lltrace_resume_frame(_PyInterpreterFrame *frame)
if (name == NULL) {
name = f->func_name;
}
printf("Resuming frame");
printf("\nResuming frame");
if (name) {
printf(" for ");
if (PyObject_Print(name, stdout, 0) < 0) {
Expand All @@ -119,6 +123,7 @@ lltrace_resume_frame(_PyInterpreterFrame *frame)
}
}
printf("\n");
fflush(stdout);
PyErr_Restore(type, value, traceback);
}
#endif
Expand Down
0