Re: How do you debug a C++ Standard Tool Application?
Re: How do you debug a C++ Standard Tool Application?
- Subject: Re: How do you debug a C++ Standard Tool Application?
- From: Jim Ingham <email@hidden>
- Date: Thu, 14 Oct 2004 10:39:20 -0700
Xcode uses a tty for the inferior sort of like I described below (it
actually uses a pty and then fakes up a terminal 'cause Terminal.app
doesn't let us embed terminal windows in Xcode), with one extra little
goodie.
It has two windows, the Console Log window, and the Standard I/O Log.
The stdio window is the one that is hooked up to both cin and cout. So
if you want to type input into your program, you need to go to the
Standard I/O window.
The Debugger console is hooked up to gdb, BUT Xcode also copies the
cout contents into the debugger log. This is useful if you have some
diagnostic printf's and you are also putting in breakpoints that print
stuff. Then you can see how they are interleaved.
But this is just a copy operation that Xcode does. The real cin/cout
are hooked up to the Standard I/O Log.
I just tried your little example, and everything worked fine. I broke
at the last cout. I debugged, brought up the Standard I/O log, typed
in Jim and a return, and hit the cout breakpoint.
Jim
On Oct 14, 2004, at 6:51 AM, Richard Dunlap wrote:
Hey Jim.
No, I'm not doing anything "funny" just 'cin' and 'cout'. Note that
'cout' doesn't cause a problem, only 'cin' I'll paste a simple
program that exhibits the problem:
int main() {
cout << "Your Name? "; // break points work here
char name[25];
cin >> name;
cout << "Hello " << name; // break points no longer work!!
return 0;
}
Note that as long as I don't hit a 'cin', everything works fine.
I'm running GDB from within XCode 1.5, so I am not launching it
directly. Is there a way that XCode will allow me the flexibility you
describe below?
Note that when I try to run the above simple program, I see GDB
commands intermixed with my console I/O.
Thanks,
Rick
On Sep 22, 2004, at 11:28 AM, Jim Ingham wrote:
As Wade says, so long as you aren't doing funny things with the
terminal, gdb & the target program should be able to share the same
channels. So long as the target is running, it gets the terminal,
and then when you break into gdb, gdb gets the terminal. I debug gdb
under gdb all the time, and they share the terminal just fine...
It would be interesting to know in what circumstances this isn't
working for you. If you can reduce this to a manageable case, please
do file a bug about it.
However, if you do have special needs (like you are debugging a
curses app, or something similar) one convenient trick is to:
1) Bring up a new terminal, and note the tty for that terminal (it
will show in the Title bar if you haven't monkey'd with the
Titles...)
2) start up gdb from ANOTHER terminal window with:
$ gdb --tty=/dev/ttyp6
or whatever the tty was for your new window.
Now gdb will hook the target app up to the second terminal, and use
the terminal it was launched from for gdb command input.
Hope this helps,
Jim
On Sep 21, 2004, at 8:09 PM, Wade Tregaskis wrote:
Debugging works fine, as long as you don't need stdin. Obviously,
program stdin conflicts with GDB's commands.
Are you sure? GDB does have a lot of bugs regarding stdin/stdout
(particularly with multi-threaded programs, I've noticed, but then
it's terribly buggy with such apps anyway), but it does work in some
(arguably most) cases... if you mean you can't control gdb and the
program at once, then yes, but you can always control-C to get to
gdb's prompt from your program, and then "c" (continue) to resume
your program. Assuming your input isn't time sensitive, and you
don't block the relevant signal for ctrl-C, etc.
Wade Tregaskis (aim & yahoo: wadetregaskis, icq: 40056898, msn &
email: email@hidden, jabber:
email@hidden)
-- Sed quis custodiet ipsos custodes?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40apple.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden