From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9421 invoked by alias); 19 May 2008 20:19:12 -0000 Received: (qmail 9393 invoked by uid 22791); 19 May 2008 20:19:10 -0000 X-Spam-Check-By: sourceware.org Received: from smtp1.cybercity.dk (HELO smtp1.cybercity.dk) (212.242.43.251) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 19 May 2008 20:18:40 +0000 Received: from user5.cybercity.dk (user5.cybercity.dk [212.242.41.51]) by smtp1.cybercity.dk (Postfix) with ESMTP id D05AB5868A8 for ; Mon, 19 May 2008 22:18:36 +0200 (CEST) Received: from petertoft.dk (0x5552f3de.adsl.cybercity.dk [85.82.243.222]) by user5.cybercity.dk (Postfix) with ESMTP id 72D3B628C8 for ; Mon, 19 May 2008 22:18:36 +0200 (CEST) Date: Mon, 19 May 2008 20:19:00 -0000 From: Peter Toft To: gdb@sourceware.org Subject: Single stepping a simple C-program, but... Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Content-ID: X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00141.txt.bz2 Hi guys I was a bit surprised today with GDB, and I hope one of you can explain it to me. Take a look at http://pastebin.org/37117 Press download and save as my_program.c $ gcc -g my_program.c $ gdb ./a.out (gdb) br 7 Breakpoint 1 at 0x804838c: file my_program.c, line 7. (gdb) r Starting program: /home/pto/c/a.out Breakpoint 1, main () at my_program.c:7 7 if ((ii>3) || (ii<1)) (gdb) s 8 printf("hej A\n"); (gdb) s hej A 7 if ((ii>3) || (ii<1)) <----------- WHY!!!!?? (gdb) s 12 return 0; ------- Why does the second "step" i.e. "s" take me BACK to line 7 after I have been in line 8???? Best -- Peter Toft, Ph.D. [pto@linuxbog.dk] http://petertoft.dk