First, run your program with the --sync option. This invokes XSynchronize() to turn off event
buffering; it slows down the application, but causes
errors to be reported as soon as they occur.
Alternatively, some Xlib implementations let you turn
on synchronization by setting the global variable _Xdebug to TRUE in a debugger.
Once errors are being reported synchronously, just run
your app in a debugger and wait for abort() to be called. For warnings, set
a breakpoint at g_logv()
which is the function called by the g_warning() macro.