Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!fernwood!oracle!news From: dtomm@sparcplug.us.oracle.com (Doug Tomm) Newsgroups: comp.windows.x Subject: Re: Debugging Graphics Programs Message-ID: <1990Sep18.165816.21969@oracle.com> Date: 18 Sep 90 16:58:16 GMT Distribution: na Organization: Oracle Corporation Lines: 48 Somebody wrote: > I'd like to debug a program I've written in X that simply opens a window > and draws in it. However, when I use dbx or gdb, the window does not > open nor can I see any graphics being drawn as the program executes. If > I simply execute the program, it opens its window and draws in it just > fine. How can I get the debugger to open the window and draw into it as > the program executes? Try using XSynchronize. You should do something like the following: : : : dpy = XOpenDisplay(displayname); if (!dpy) bail(out); #ifdef DEBUG XSynchronize(dpy, 1); #endif /* DEBUG */ : : : XSynchronize will enable synchronous event reporting (disabled with XSynchronize(dpy, 0)). This will cause the effects of events to appear immediately, so that you can see what happens as you step through a debugger. Bracketing the XSynchronize as above is important because XSynchronize will make your application run much slower. Another way to turn on synchronous mode is to call XSynchronize from within dbx (I don't know how to do this from within GDB). Set a breakpoint before your event handler, and type (dbx) call XSynchronize( mydpy, 1 ) where mydpy is the display pointer returned by XOpenDisplay (make sure it isn't null). The second approach is useful when debugging toolkit applications. Doug Tomm Oracle Corporation dtomm@oracle.com My wife love me. We don't agree all the time. Oracle loves me a lot less. You figure it out.