[comp.windows.x] Debugging while server grabs are present.

argv%turnpike@Sun.COM (Dan Heller) (10/11/89)

You're debugging your program and it's segfaulting somewhere in a routine
in which there is a pointer grab.  It dumps core, so you enter your 
debugger (dbx for me) and you can't read the stack trace because it's
a stack overflow and it can't read the core file correctly.  so, you
want to run the program from within dbx to identify where the problem
lies and to see the values of glabols.  ooops... dbx stopped, but the
pointer grab is still going.  You're hung.  Because the pointer is
grabbed, moving the pointer doesn't reset the input focus for keyboard
input.  In my case, my machine isn't connected to any other machine so
I can't login from somewhere else to free the grab (kill the process).
I have to reboot my machine.

I have several questions as a result of this.  Altho I can't get access
to any other debugger, are there any other debuggers which can execute
certain commands upon the recepit of an interrupt which would stop
execution of the code being debugged?  For example, I'd like to set
it so that if it receives an error in execution of the code, I'd like
it to call a function which releases the grab -- or that resets my tty
settings...  I can supply the routines to do it -- I just want the
ability to get the debugger to automatically call those routines.

And this idea is more X-specific altho I realizes the chances of the
idea being implemented.  I'd like to specify a timeout value for the
-server- so that if the server grab hasn't been released by the timeout,
the server releases the grab automatically.  This can't be a client-side
function because the client may not be running.  Of course, this would
imply a change/addition to the X protocol, which as I understand it,
will not be modified ever.

Does anyone have a workaround for this problem?

dan <island!argv@sun.com>
-----
My postings reflect my opinion only -- not the opinion of any company.

wesommer@athena.mit.edu (William Sommerfeld) (10/11/89)

Way back, in the days of X10, there was a version of the X server
known as "Xnest"; its device driver was implemented on top of Xlib;
the "screen" was a window on some other (real or virtual) display.
You could run it inside itself N levels deep, although it got really
slow..

I don't think that Xnest survived to X11, but if it did, it could be
useful for debugging applications which do server grabs and played
similar games..

I believe that the GNU debugger lets you run an arbitrary sequence of
debugger commands when reaching a breakpoint; it also lets you make
function calls inside the target process (assuming that the target's
address space isn't smashed beyond repair).

					- Bill


--

markc@Solbourne.COM (Mark Connell) (10/11/89)

In article <126096@sun.Eng.Sun.COM>, argv%turnpike@Sun.COM (Dan Heller) writes:
> want to run the program from within dbx to identify where the problem
> lies and to see the values of glabols.  ooops... dbx stopped, but the
> pointer grab is still going.  You're hung.  

> Does anyone have a workaround for this problem?
> 
> dan <island!argv@sun.com>

Well, it is a kludge, but it works for me:

I have one of the function keys mapped to iconify/deiconify windows.  If you
can do this under whatever wm you are using, this may get you around the
problem.  If you iconify the window the pointer is grabbed in, the server
will release the grab.  You can then go to your dbx window, re-open your
client window, ....  A click-to-type wm could also get you around this
problem, depending on how the click-to-type was implemented.

In respones to the same question, wesommer@athena.mit.edu (William Sommerfeld)
writes:

> I believe that the GNU debugger lets you run an arbitrary sequence of
> debugger commands when reaching a breakpoint; it also lets you make
> function calls inside the target process 

You can also run debugger commands at a breakpoint from within dbx, but this
doesn't help the problem.  Dan is not stopping at a breakpoint, his client
is crashing.  dbx will also let you call functions, but this also doesn't
help.  He can't change the keyboard focus to the dbx window.


                                        Mark A. Connell
                                        Solbourne Computer, Inc.
                                        1900 Pike Road
                                        Longmont, Co	80501
                                        (303) 772-3400
                                        markc@Solbourne.COM
                                         ...!uunet!stan!markc

jne@goldhill.COM (10/11/89)

In article <126096@sun.Eng.Sun.COM>, turnpike!argv@sun.com writes:
>  And this idea is more X-specific altho I realizes the chances of the
>  idea being implemented.  I'd like to specify a timeout value for the
>  -server- so that if the server grab hasn't been released by the timeout,
>  the server releases the grab automatically.  This can't be a client-side
>  function because the client may not be running.  Of course, this would
>  imply a change/addition to the X protocol, which as I understand it,
>  will not be modified ever.

Rather than a timeout value, I'd rather have a "magical" keystroke that
releases server/pointer grabs.  If my client hangs and I am running
standalone (so I can't rlogin to kill X), then I have to reboot the
machine (a Sun/3 I'm talking about) in order to get keyboard/mouse
contol back.  This does not go over very well in front of potential
customers.

Jeff Eisen
Gold Hill Computers
617-621-3404
jne@goldhill.com

ben@hpcvlx.cv.hp.com (Benjamin Ellsworth) (10/12/89)

> ...[debugging a program that grabs the server is nigh impossible]...
> Does anyone have a workaround for this problem?

The only solution that we were able to come up with was to run a "dumb"
ascii terminal beside our high zoot graphics display.  We'd start the
debugger in the terminal and point the program at the display.  It may
not be flashy but it was cheap (ascii terminals are a dime a dozen
anymore) and it worked.

-----------------------------------------------------------------------
Benjamin Ellsworth      | ben@cv.hp.com                | INTERNET
Hewlett-Packard Company | {backbone}!hplabs!hp-pcd!ben | UUCP
1000 N.E. Circle        | (USA) (503) 750-4980         | FAX
Corvallis, OR 97330     | (USA) (503) 757-2000         | VOICE
-----------------------------------------------------------------------
                     All relevant disclaimers apply.
-----------------------------------------------------------------------

ptm@xact.UUCP (Paul Mahoney) (10/14/89)

Yes, it's very anoying trying to debug when the application grabs the
pointer or the keyboard.

If, however,  you  are fortunate enough to be on a network
you might send the output to another (nearby machine) while running
dbx on your local machine.


Paul Mahoney
X-Act Solutions Ltd
Tel: (+44) 4243 6386
uknet: ptm@xact.uucp

darren2@bigsur.UUCP (Darren Toop) (10/22/89)

This is a fairly well known problem to me, since I do alot of dbx
of x applications.  I also use Saber-C debugger and it has the same 
problem.  I use a brute force work around as follows:

You may not be able to type, but you can still cut and paste.
cat the following file in scratch pad window:

s
n
c
quit
p x
p *x
dump
display
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
!@#$%^&*()-_=+\|`~[{}];:'",<.>/?  

Then when I get stuck, I can still cut+paste the command I want
into the dbx input buffer and it will do the command.  Hey, nobody
said it was elegant.  If you've got a better way, let me know.

With Saber-C the problems are a bit more nasty, since, if you
mistype a command sometimes Saber will echo it back on the command
line.  This is great if you can use the keyboard, but it's hard to
paste a backspace character.  :-)  (Anybody from Saber listening out there.)

regrads .. Darren Toop

meo@stiatl.UUCP (Miles O'Neal) (10/23/89)

In article <427@bigsur.UUCP> darren2@bigsur.UUCP (Darren Toop) writes:
|You may not be able to type, but you can still cut and paste.
|cat the following file in scratch pad window:
|
|...
|
|Then when I get stuck, I can still cut+paste the command I want
|into the dbx input buffer and it will do the command.  Hey, nobody
|said it was elegant.  If you've got a better way, let me know.

That is 1 of the things we do.

The other is our app now has an extra #define test
throughout the source, that lets us turn off grabs for
debugging, and turn them back on for release.

Finally, as an emergency measure regarding keyboard focus, I added
a kill icon button next to the iconify icon button in the twm
title bars...


-Miles O'Neal
{yr fave backbone here}!{emory|gatech}!stiatl!meo