msg200527 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2013-10-20 00:23 |
I was confused for a while when seeing the thread stacks dumped by the faulthandler module. (See issue 19293.) I propose the following tweaks of the output to make this more obvious. The first chunk changes the header written when called as _Py_DumpTraceback(), the second change the per-thread headers printed by _Py_DumpTracebackThreads(). diff -r 02f6922e6a7e Python/traceback.c --- a/Python/traceback.c Sat Oct 19 17:04:25 2013 -0700 +++ b/Python/traceback.c Sat Oct 19 17:19:29 2013 -0700 @@ -603,7 +603,7 @@ unsigned int depth; if (write_header) - PUTS(fd, "Traceback (most recent call first):\n"); + PUTS(fd, "Stack (most recent call first):\n"); frame = _PyThreadState_GetFrame(tstate); if (frame == NULL) @@ -642,7 +642,7 @@ else PUTS(fd, "Thread 0x"); dump_hexadecimal(sizeof(long)*2, (unsigned long)tstate->thread_id, fd); - PUTS(fd, ":\n"); + PUTS(fd, " (most recent call first):\n"); } const char* |
|
|
msg200537 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2013-10-20 03:26 |
BTW, another oddity in traceback.c: dump_hexadecimal() has the "int fd" argument at the end, while all other dump_*() functions have it at the front -- even its cousin dump_decimal(). Here's a patch that includes a fix. |
|
|
msg200550 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2013-10-20 07:41 |
You must update unit tests in test_faulthandler. |
|
|
msg200655 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2013-10-20 23:41 |
New patch, with fixed test. TBH now I'm getting worried that other programs may exist that parse this format and will get confused. |
|
|
msg200660 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2013-10-21 00:03 |
> TBH now I'm getting worried that other programs may exist that parse this format and will get confused. A program parsing faulthandler output? Seriously? It would be nice, but I don't know any. Anyway, such program would probably use a regex to parse the output, and it's very easy to support Python 3.3 format and patched (future 3.4) format. > New patch, with fixed test. Thanks. The patch looks good to me, you can push it. |
|
|
msg200678 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-10-21 01:21 |
New changeset cc8c37b5b449 by Guido van Rossum in branch 'default': Issue 19306: Add extra hints to faulthandler stack dumps that they are upside down. http://hg.python.org/cpython/rev/cc8c37b5b449 |
|
|
msg200685 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2013-10-21 02:18 |
On Victor's authority, committed. I've also (separately) committed some doc changes. |
|
|
msg200712 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2013-10-21 08:00 |
Thanks. "(most recent call first)" was already present in some cases, but I forgot to mention it in all cases. |
|
|