From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15645 invoked by alias); 24 Jul 2003 14:48:47 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 15637 invoked from network); 24 Jul 2003 14:48:46 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 24 Jul 2003 14:48:46 -0000 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 19fhOS-0000yQ-00; Thu, 24 Jul 2003 10:48:32 -0400 Date: Thu, 24 Jul 2003 14:48:00 -0000 From: Daniel Jacobowitz To: mohanlal jangir Cc: gdb@sources.redhat.com Subject: Re: gdb shows source line multiple times before executing !! Message-ID: <20030724144832.GA326@nevyn.them.org> Mail-Followup-To: mohanlal jangir , gdb@sources.redhat.com References: <3F1FEF06.20507@drexel.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.1i X-SW-Source: 2003-07/txt/msg00298.txt.bz2 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