xscreensaver/xscreensaver-5.35-0101-XIO-print-C-backtrace-on-error.patch
leeffo da2c103ffc init package
(cherry picked from commit 0d6959e75f62c101fcf97124de3b7efe7493029e)
2023-08-18 15:25:01 +08:00

85 lines
1.8 KiB
Diff
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 735cc1af7595890d9cd567f36dabaf41fae4210e Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Mon, 11 Jul 2016 16:53:14 +0900
Subject: [PATCH] XIO: print C backtrace on error
For debugging purpose, show C backtrace with XIO
error happens.
---
driver/xscreensaver.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/driver/xscreensaver.c b/driver/xscreensaver.c
index 76969f2..04c2669 100644
--- a/driver/xscreensaver.c
+++ b/driver/xscreensaver.c
@@ -148,10 +148,15 @@
# include "config.h"
#endif
+#include <features.h>
#include <stdio.h>
#include <ctype.h>
#include <X11/Xlib.h>
+#ifdef __GNU_LIBRARY__
+#include <execinfo.h>
+#endif
+
#ifdef ENABLE_NLS
# include <locale.h>
# include <libintl.h>
@@ -504,6 +509,41 @@ startup_ehandler (String name, String type, String class,
exit (1);
}
+static void
+show_cstyle_backtrace(void)
+{
+#ifdef __GNU_LIBRARY__
+ void *bt_array[128];
+ size_t bt_size;
+
+ bt_size = backtrace(bt_array, countof(bt_array));
+ fprintf(stderr, "C backtrace:\n");
+ backtrace_symbols_fd(bt_array, bt_size, STDERR_FILENO);
+#endif
+}
+
+static int (*default_xio_ehandler)(Display *dpy) = 0;
+
+static int
+show_debug_info_xio_ehandler(Display *dpy)
+{
+ show_cstyle_backtrace();
+ if (default_xio_ehandler){
+ (*default_xio_ehandler)(dpy);
+ }
+ return 0;
+}
+
+static void
+hack_IOErrorHandler(void)
+{
+#ifdef __GNU_LIBRARY__
+ XIOErrorHandler old_handler;
+ old_handler = XSetIOErrorHandler(show_debug_info_xio_ehandler);
+ default_xio_ehandler = old_handler;
+#endif
+}
+
/* The zillions of initializations.
*/
@@ -1570,6 +1610,7 @@ main (int argc, char **argv)
initialize_stderr (si);
handle_signals (si);
+ hack_IOErrorHandler();
make_splash_dialog (si);
--
2.7.4