From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61612 invoked by alias); 12 Oct 2015 16:56:23 -0000 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 Received: (qmail 61601 invoked by uid 89); 12 Oct 2015 16:56:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f48.google.com Received: from mail-qg0-f48.google.com (HELO mail-qg0-f48.google.com) (209.85.192.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 12 Oct 2015 16:56:21 +0000 Received: by qgt47 with SMTP id 47so123959245qgt.2 for ; Mon, 12 Oct 2015 09:56:19 -0700 (PDT) X-Received: by 10.140.201.78 with SMTP id w75mr33475199qha.86.1444668978933; Mon, 12 Oct 2015 09:56:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.75.85 with HTTP; Mon, 12 Oct 2015 09:55:49 -0700 (PDT) In-Reply-To: <20151012163933.GA4446@vapier.lan> References: <20151012132040.GA28674@vapier.lan> <20151012163933.GA4446@vapier.lan> From: Simon Marchi Date: Mon, 12 Oct 2015 16:56:00 -0000 Message-ID: Subject: Re: Is that a GDB bug? To: Andreas Schwab , Nancy , "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg00058.txt.bz2 On 12 October 2015 at 12:39, Mike Frysinger wrote: > On 12 Oct 2015 15:32, Andreas Schwab wrote: >> Mike Frysinger writes: >> > next operates on statements, not lines. >> >> That's not true. >> >> (gdb) help step >> Step program until it reaches a different source line. > > "next" != "step" Andreas probably pasted the help for "step" because the help for "next" refers to "step": (gdb) help next Step program, proceeding through subroutine calls. Usage: next [N] Unlike "step", if the current source line calls a subroutine, this command does not enter the subroutine, but instead steps over the call, in effect treating it as a single source line. If I understand correctly (and please correct me if I'm wrong), the debug info only maps each instruction to a line of the original source file. The algorithm for step/next when no subroutines are involved is equivalent to "step instructions as long as they belong to the same source line". When the CPU is about to execute an instruction that belongs to an other source line, we stop. So there is no knowledge of statements. You can verify what Pedro said by removing the breakpoint before doing the next: (gdb) b 5 Breakpoint 1 at 0x80483d8: file test.c, line 5. (gdb) r Starting program: /tmp/binutils-gdb/gdb/test Breakpoint 1, main () at test.c:5 5 L1: switch(x) { case 0: x=1; goto L1; case 1: if(x==0) goto L1; else break; } (gdb) delete 1 (gdb) n 6 x=2; (gdb) Here, the next is not interrupted by the breakpoint, so the program stops just before executing the first instruction that belongs to x=2;. Simon