From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25987 invoked by alias); 4 Jun 2004 12:11:12 -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 25923 invoked from network); 4 Jun 2004 12:11:11 -0000 Received: from unknown (HELO aragorn.inter.net.il) (192.114.186.23) by sourceware.org with SMTP; 4 Jun 2004 12:11:11 -0000 Received: from zaretski (pns03-196-13.inter.net.il [80.230.196.13]) by aragorn.inter.net.il (MOS 3.4.6-GR) with ESMTP id DAE43681; Fri, 4 Jun 2004 14:56:01 +0300 (IDT) Date: Fri, 04 Jun 2004 12:11:00 -0000 From: "Eli Zaretskii" To: Jason Luo Message-Id: <6654-Fri04Jun2004145336+0300-eliz@gnu.org> CC: drow@false.org, gdb@sources.redhat.com In-reply-to: <40BFDEC8.3070602@turbolinux.com.cn> (message from Jason Luo on Fri, 04 Jun 2004 10:30:32 +0800) Subject: Re: What make the directive run twice? Reply-to: Eli Zaretskii References: <40BECE4F.7090002@turbolinux.com.cn> <20040603204433.GA22683@nevyn.them.org> <40BFDEC8.3070602@turbolinux.com.cn> X-SW-Source: 2004-06/txt/msg00027.txt.bz2 > Date: Fri, 04 Jun 2004 10:30:32 +0800 > From: Jason Luo > > > It wasn't run twice; it appears in the step output twice. This is > > common when debugging optimized code; part of the function call occurs > > before the previous line and part after. > > I disassemble the call function init_device_map,and the function > check_device,I didn't find that you says. > > init_device_map call check_deivce,then the control jump to the function > check_device,then process continue.The process flow is correct like the > c source file's. That's not the right way to analyze this. When you type "next" in GDB, GDB needs to know how machine instructions to run to land at the next source line. So what you need to do is to use a tool such as objdump to see what is the correspondence between program code addresses and source lines. That is the information used by GDB during stepping. My experience is consistent with what Daniel says: stepping through optimized code quite often jumps between source lines like you saw.