This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb shows source line multiple times before executing !!


Because GCC splits the code for the line into multiple parts.  Part of
the line has executed when you step over it, but it may not be
immediately obvious how.  For instance, given:
  a = b + c;
the first time you step over it may load b and c from memory; the
second time may add them; and only the third will store the result into
a.

On Thu, Jul 24, 2003 at 08:08:24PM +0530, mohanlal jangir wrote:
> Actully yes. I will try to figure out if this is only reason, but can you
> explain why this happens if executable is optimized.
> 
> > the executable is probably optimized (gcc/g++ -O2 ...)
> >
> > mohanlal jangir wrote:
> >
> > >While single stepping with gdb, quite frequently I see sorce lines
> appearing
> > >multiple times i.e. gdb shows some line that will be executed on command
> > >"next", but that is actully not. After next "next" command, I see same
> line
> > >appearing. This happens two or three times and then finally that line is
> > >executed.
> 
> 

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]