From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30209 invoked by alias); 24 Jul 2003 15:20:14 -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 30190 invoked from network); 24 Jul 2003 15:20:14 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 24 Jul 2003 15:20:14 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h6OFKDH13271 for ; Thu, 24 Jul 2003 11:20:13 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h6OFKDI20375 for ; Thu, 24 Jul 2003 11:20:13 -0400 Received: from localhost.redhat.com (romulus-int.sfbay.redhat.com [172.16.27.46]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h6OFKCv20630 for ; Thu, 24 Jul 2003 11:20:12 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id 6A1E42CB38; Thu, 24 Jul 2003 11:27:25 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16159.64221.73906.128026@localhost.redhat.com> Date: Thu, 24 Jul 2003 15:20:00 -0000 To: "mohanlal jangir" Cc: Subject: Re: gdb shows source line multiple times before executing !! In-Reply-To: References: <3F1FEF06.20507@drexel.edu> <20030724144832.GA326@nevyn.them.org> X-SW-Source: 2003-07/txt/msg00302.txt.bz2 mohanlal jangir writes: > > > 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. > hmm... but sometimes it behaves even worse. For example there are two lines > a = b + c; > d = e + f; > then first gdb shows line a = b + c; then d = e + f and then again a = b + > c. And while showing d = e + f first time if I try to print value of a, it > will be some uninitialised (that indicates that a = b + c has not been > executed). Then on next "next" command I will see line a = b +c again and > then valute of a will be correct one. Yes, only part of the assembly instructions that correspond to the line a = b+c; has been executed at that time, and the result hasn't been transfered into the location of a yet. Try to use stepi. Also compare with the execution on the same program compiled with -O0 or just with -g. elena > > > > 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.