Skip to content

Add some X11 error tracing facilities

Simon Ser requested to merge github/fork/psychon/error_trace into master

Created by: psychon

This PR adds some infrastructure to better pinpoint where an X11 error was caused.

As an example, causing an X11 error on purpose like this:

diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index bb7a4759..0f604f0a 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -168,6 +168,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create(
 	wl_signal_init(&surface->events.ping_timeout);
 	wl_signal_init(&surface->events.set_geometry);
 
+	xcb_change_window_attributes(xwm->xcb_conn, 1234, 0, NULL);
 	xcb_get_geometry_reply_t *geometry_reply =
 		xcb_get_geometry_reply(xwm->xcb_conn, geometry_cookie, NULL);
 	if (geometry_reply != NULL) {

produces the following output:

00:00:02.140 [wlr] [xwayland/xwm.c:1432] xcb error: op 2:0, code 3, sequence 111, value 1234
00:00:02.140 [wlr] [xwayland/trace.c:64] X11 error happened somewhere after xwayland/xwm.c:128
00:00:02.140 [wlr] [xwayland/trace.c:67] X11 error happened somewhere before xwayland/xwm.c:193

Future work on this:

  • Make this a compile time option so that it can be turned off when not needed. Dunno if this is necessary and I didn't want to start the bikeshedding with an own name for the option, so this is up to you.
  • Do something similar for backend/x11. Since this is best done by sharing code between xwayland and the backend, which is not done so far, I did not want to do this just yet. I'd be happy if someone who knows what they are doing does this as a follow-up PR.

Merge request reports