Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!apple!uokmax!servalan!rmtodd From: rmtodd@servalan.uucp (Richard Todd) Newsgroups: comp.windows.x Subject: Re: How do you use an Xterm with a debugger Message-ID: <1991Mar15.074424.857@servalan.uucp> Date: 15 Mar 91 07:44:24 GMT References: <1991Mar13.011536.17184@motcad.portal.com> <1991Mar14.072808.20247@Think.COM> Organization: Ministry of Silly Walks Lines: 32 barmar@think.com (Barry Margolin) writes: >In article <1991Mar13.011536.17184@motcad.portal.com> jtc@motcad.portal.com (J.T. Conklin) writes: >>I would like to be able to open an Xterm so I can redirect terminal output >>to it from within gdb. >Why don't you just run gdb from the xterm window? Uh, I think you've misinterpreted slightly what the original poster's after. You see, gdb has a command that allows the target program to do all its I/O on a different tty (or pseudo-tty) than the one that gdb is running on. This is very useful if you're debugging curses applications, where otherwise the gdb output would mess up your fancy display and make it hard to figure out what's going on. So what the guy wants is to run gdb in one xterm window and have the target program's I/O go thru *another* xterm window. But, by default xterm puts a shell on its pseudo-tty, and when both your target program and the shell try to read from the same tty, Bad Things happen. There are a couple of ways to work around this. The cheap and sleazy way (the one I used :-) was to simply type "sleep 10000" in the target xterm window and let gdb attatch the target program to that tty. Obviously, this will run into problems if your program expects to receive signals from the keyboard (i.e. the default signal-causing behaviour of ^C etc isn't disabled)--the ^C will kill the sleep and the shell will return to try and grab your input. (It also runs into problems if it takes more than 10000 seconds==2.7 hours to debug your program...) The more elegant solution is to write a special purpose program to just sit there, turn off all keyboard signals, and do nothing. It's a fairly straighforward exercise in C coding. -- Richard Todd rmtodd@uokmax.ecn.uoknor.edu rmtodd@chinet.chi.il.us rmtodd@servalan.uucp "Try looking in the Yellow Pages under 'Psychotics'." -- Michael Santana