From: Po Lu Date: Mon, 4 Jul 2022 03:32:05 +0000 (+0800) Subject: Display list of traps and handlers when crashing due to an X error X-Git-Tag: emacs-29.0.90~1447^2~1217 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c96cd5e2b71f1de8c5b84c290ec8c9a01ec75bdd;p=emacs.git 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. --- diff --git a/src/xterm.c b/src/xterm.c index 02ea968031e..c5acb450837 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); }