emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c96cd5e2b7: Display list of traps and handlers when crashing due


From: Po Lu
Subject: master c96cd5e2b7: Display list of traps and handlers when crashing due to an X error
Date: Sun, 3 Jul 2022 23:32:23 -0400 (EDT)

branch: master
commit c96cd5e2b71f1de8c5b84c290ec8c9a01ec75bdd
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Display list of traps and handlers when crashing due to an X error
    
    * src/xterm.c (x_connection_closed): Print list of installed
    error handlers if not crashing due to an IO error.
    (NO_INLINE): Include error serial in error message.
---
 src/xterm.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 02ea968031..c5acb45083 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -23342,6 +23342,8 @@ x_connection_closed (Display *dpy, const char 
*error_message, bool ioerror)
   xm_drop_start_message dmsg;
   struct frame *f;
   Lisp_Object minibuf_frame, tmp;
+  struct x_failable_request *failable;
+  struct x_error_message_stack *stack;
 
   dpyinfo = x_display_info_for_display (dpy);
   error_msg = alloca (strlen (error_message) + 1);
@@ -23508,6 +23510,31 @@ For details, see etc/PROBLEMS.\n",
   if (terminal_list == 0)
     {
       fprintf (stderr, "%s\n", error_msg);
+
+      if (!ioerror)
+       {
+         /* Dump the list of error handlers for debugging
+            purposes.  */
+
+         fprintf (stderr, "X error handlers currently installed:\n");
+
+         for (failable = dpyinfo->failable_requests;
+              failable < dpyinfo->next_failable_request;
+              ++failable)
+           {
+             if (failable->end)
+               fprintf (stderr, "Ignoring errors between %lu to %lu\n",
+                        failable->start, failable->end);
+             else
+               fprintf (stderr, "Ignoring errors from %lu onwards\n",
+                        failable->start);
+           }
+
+         for (stack = x_error_message; stack; stack = stack->prev)
+           fprintf (stderr, "Trapping errors from %lu\n",
+                    stack->first_request);
+       }
+
       Fkill_emacs (make_fixnum (70), Qnil);
     }
 
@@ -23599,7 +23626,8 @@ x_error_handler (Display *display, XErrorEvent *event)
 static void NO_INLINE
 x_error_quitter (Display *display, XErrorEvent *event)
 {
-  char buf[256], buf1[356];
+  char buf[256], buf1[400 + INT_STRLEN_BOUND (int)
+                     + INT_STRLEN_BOUND (unsigned long)];
 
   /* Ignore BadName errors.  They can happen because of fonts
      or colors that are not defined.  */
@@ -23611,8 +23639,9 @@ x_error_quitter (Display *display, XErrorEvent *event)
      original error handler.  */
 
   XGetErrorText (display, event->error_code, buf, sizeof (buf));
-  sprintf (buf1, "X protocol error: %s on protocol request %d",
-          buf, event->request_code);
+  sprintf (buf1, "X protocol error: %s on protocol request %d\n"
+          "Serial no: %lu\n", buf, event->request_code,
+          event->serial);
   x_connection_closed (display, buf1, false);
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]