Debugging a gdb source

Eli Zaretskii eliz@elta.co.il
Tue Mar 9 06:49:00 GMT 2004


> Date: Tue, 9 Mar 2004 11:23:25 +0530
> From: "Kotian, Deepak" <Deepak.Kotian@patni.com>
> 
> I am trying to debug gdb source on Linux using already installed
> dedugger ddd or gdb.
> The source code text does not seem to be in sync with the 
> execution when we do step. How do I get it in sync, please
> let me know. The -g option seems to be set in the Makefile.

Most probably, this happens because GDB is compiled with
optimizations.  I usually find this not to be much of a nuisance, I
just need to remember stepping a couple of times more until the line
I'm interested in stops being printed by GDB as the current line; then
I know that this line's code finished being executed, and the
variables whose values it modifies can be examined.

If you are annoyed by this, I suggest to rebuild GDB without
optimizations.  Caveat emptor: doing so might cause the problems you
are debugging to go away.  That is why I suggest to get used to
debugging the optimized code.



More information about the Gdb mailing list