From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18634 invoked by alias); 4 Aug 2012 19:09:09 -0000 Received: (qmail 18626 invoked by uid 22791); 4 Aug 2012 19:09:08 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,SARE_HEAD_8BIT_SPAM,SARE_SUB_ENC_UTF8x2 X-Spam-Check-By: sourceware.org Received: from mail-wg0-f43.google.com (HELO mail-wg0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Aug 2012 19:08:47 +0000 Received: by wgbdr1 with SMTP id dr1so1277897wgb.12 for ; Sat, 04 Aug 2012 12:08:46 -0700 (PDT) Received: by 10.180.76.135 with SMTP id k7mr5981045wiw.7.1344107326158; Sat, 04 Aug 2012 12:08:46 -0700 (PDT) Received: from localhost (89-70-245-0.dynamic.chello.pl. [89.70.245.0]) by mx.google.com with ESMTPS id j6sm7443308wiy.4.2012.08.04.12.08.44 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 04 Aug 2012 12:08:45 -0700 (PDT) Date: Sat, 04 Aug 2012 19:09:00 -0000 From: wempwer@gmail.com To: Joachim Protze Cc: gdb@sourceware.org Subject: Re: Why does gdb stop at a =?utf-8?Q?diffe?= =?utf-8?Q?rent_line_than_=E2=80=9Ci_b?= =?utf-8?B?4oCd?= shows while returning from function? Message-ID: <20120804200150.GA2730@a.lan> References: <20120729185452.GB2732@a.lan> <501B96BE.8050604@tu-dresden.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <501B96BE.8050604@tu-dresden.de> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2012-08/txt/msg00006.txt.bz2 On Fri, Aug 03, 2012 at 11:15:42AM +0200, Joachim Protze wrote: > The behaviour is similar with setting a breakpoint at empty line 7 ("b > 7") or function header line 13 ("b 13"): "i b" shows try5.c:7 resp. > try5.c:13, but the program stops at line 8 resp. 15. > I would understand this because there are no instructions at line 7 and 13 so breakpoints have no effect on these lines and are automatically moved to the nearest next instruction. Is my understanding correct? However, my example is a bit different. I moved from 'display' to 'main' frame and set a breakpoint. I don't understand why gdb put the breakpoint on line 8 instead of 9, because this is the actual next instruction that's going to be executed in 'frame 1' and in fact when you resume the execution it stops at line 9 in 'main'. I think the breakpoint should be set at line 9 or if it must be set at line 8 it should not be triggered at line 9. There are no empty instructions such as '{' anywhere along the way in this situation. > The thing gets even fancier, when you rerun the program after setting > the breakpoints: Now "i b" lists your breakpoint at line 9, while my > breakpoints remain at line 7 resp. 13. > > - Joachim > That's right, I didn't notice that before. Maybe it's a bug? I include the full log: Reading symbols from /home/ja/gdb/learning/try5...done. (gdb) b 7 Breakpoint 1 at 0x4004fb: file try5.c, line 7. (gdb) b 13 Breakpoint 2 at 0x40051e: file try5.c, line 13. (gdb) b display Note: breakpoint 2 also set at pc 0x40051e. Breakpoint 3 at 0x40051e: file try5.c, line 15. (gdb) r Starting program: /home/ja/gdb/learning/try5 Breakpoint 1, main () at try5.c:8 (gdb) c Continuing. Breakpoint 2, display (x=3) at try5.c:15 (gdb) f 1 #1 0x000000000040050c in main () at try5.c:8 (gdb) b Breakpoint 4 at 0x40050c: file try5.c, line 8. (gdb) c Continuing. i is 0. i is 1. i is 2. Breakpoint 4, main () at try5.c:9 (gdb) c Continuing. [Inferior 1 (process 13038) exited normally] (gdb) i b Num Type Disp Enb Address What 1 breakpoint keep y 0x00000000004004fb in main at try5.c:7 breakpoint already hit 1 time 2 breakpoint keep y 0x000000000040051e in display at try5.c:13 breakpoint already hit 1 time 3 breakpoint keep y 0x000000000040051e in display at try5.c:15 breakpoint already hit 1 time 4 breakpoint keep y 0x000000000040050c in main at try5.c:8 breakpoint already hit 1 time (gdb) r Starting program: /home/ja/gdb/learning/try5 Breakpoint 1, main () at try5.c:8 (gdb) i b Num Type Disp Enb Address What 1 breakpoint keep y 0x00000000004004fb in main at try5.c:7 breakpoint already hit 1 time 2 breakpoint keep y 0x000000000040051e in display at try5.c:13 3 breakpoint keep y 0x000000000040051e in display at try5.c:15 4 breakpoint keep y 0x000000000040050c in main at try5.c:9 (gdb)