diff Python/traceback.c @ 86532:cc8c37b5b449

Issue 19306: Add extra hints to faulthandler stack dumps that they are upside down.
author Guido van Rossum <guido@dropbox.com>
date Sun, 20 Oct 2013 18:21:02 -0700
parents e82472e4fd97
children 954167ce92a3
line wrap: on
line diff
--- a/Python/traceback.c	Mon Oct 21 03:05:46 2013 +0300
+++ b/Python/traceback.c	Sun Oct 20 18:21:02 2013 -0700
@@ -471,13 +471,13 @@
     write(fd, buffer, len);
 }
 
-/* Format an integer in range [0; 0xffffffff] to hexdecimal of 'width' digits,
+/* Format an integer in range [0; 0xffffffff] to hexadecimal of 'width' digits,
    and write it into the file fd.
 
    This function is signal safe. */
 
 static void
-dump_hexadecimal(int width, unsigned long value, int fd)
+dump_hexadecimal(int fd, unsigned long value, int width)
 {
     int len;
     char buffer[sizeof(unsigned long) * 2 + 1];
@@ -544,15 +544,15 @@
         }
         else if (ch < 0xff) {
             PUTS(fd, "\\x");
-            dump_hexadecimal(2, ch, fd);
+            dump_hexadecimal(fd, ch, 2);
         }
         else if (ch < 0xffff) {
             PUTS(fd, "\\u");
-            dump_hexadecimal(4, ch, fd);
+            dump_hexadecimal(fd, ch, 4);
         }
         else {
             PUTS(fd, "\\U");
-            dump_hexadecimal(8, ch, fd);
+            dump_hexadecimal(fd, ch, 8);
         }
     }
     if (truncated)
@@ -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)
@@ -641,8 +641,8 @@
         PUTS(fd, "Current thread 0x");
     else
         PUTS(fd, "Thread 0x");
-    dump_hexadecimal(sizeof(long)*2, (unsigned long)tstate->thread_id, fd);
-    PUTS(fd, ":\n");
+    dump_hexadecimal(fd, (unsigned long)tstate->thread_id, sizeof(long)*2);
+    PUTS(fd, " (most recent call first):\n");
 }
 
 const char*