From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11855 invoked by alias); 28 Oct 2011 20:52:23 -0000 Received: (qmail 11828 invoked by uid 22791); 28 Oct 2011 20:52:21 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Oct 2011 20:52:02 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9SKq2Gs023722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Oct 2011 16:52:02 -0400 Received: from host1.jankratochvil.net (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9SKq0uu019999 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 28 Oct 2011 16:52:01 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p9SKpxKg019231; Fri, 28 Oct 2011 22:51:59 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p9SKpwHp019224; Fri, 28 Oct 2011 22:51:58 +0200 Date: Fri, 28 Oct 2011 21:00:00 -0000 From: Jan Kratochvil To: Aleksandar Ristovski Cc: gdb-patches@sources.redhat.com Subject: Re: [patch] Workaround gcc bug 49906 Message-ID: <20111028205157.GA18860@host1.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00784.txt.bz2 Hello Aleksandar, the problem is that for this testcase: /*1*/ static int i; /*2*/ static void /*3*/ f (int q) /*4*/ { /*5*/ for (;; i--) /*6*/ if (i++) /*7*/ break; /*8*/ } /*9*/ int main (void) { f (5); return 0; } Built with: gcc -o f2 f2.c -Wall -g -Werror gcc (GCC) 4.6.3 20111028 (prerelease) -- the version should not matter x86_64 it has a regression gdb ./f2 -ex 'b f' -ex r FSF GDB HEAD: Breakpoint 1, f (q=5) at f2.c:6 ^ 6 if (i++) with your patch: Breakpoint 1, f (q=0) at f2.c:4 ^ 4 { For reader's convenience attaching objdump at the bottom of this mail. After GCC PR/49906 gets fixed the regression would stay there I think as this testcase has already fully correct .debug_line now; unless this work around gets protected by some DW_AT_producer based GCC version check. I do not say how to fix it but I do not find the regression acceptable as is. On Tue, 25 Oct 2011 19:43:14 +0200, Aleksandar Ristovski wrote: > In addition to the patch, I'm attaching new test. As discussed on IRC to make such testcase useful with future fixed GCCs (and to make it meaningful for future GCC debug changes in general) it should be placed into gdb.dwarf2/ and either prepared by gcc -S -dA (FSF GCC preferred) while making it unfortunatelt arch-dependent or best (but not required and very time consuming to prepare) building it by hand such as: gdb.dwarf2/dw2-unresolved-main.c gdb.dwarf2/dw2-unresolved.S > 2011-10-25 Aleksandar Ristovski > > * symtab.c (skip_prologue_sal): Introduced start_sal_orig to keep > entry value. Added check for line after the prologue. If line > information for the next line exists but appears to be before in > the code, discard skip over prologue work and revert original sal. The modified skip_prologue_using_sal function should be in ChangeLog. > gdb/testsuite/ChangeLog: > > 2011-10-25 Aleksandar Ristovski > > * prologue-gccbug49906.exp: New test. > * prologue.c (f_gccbuf49906): New function, call new function. Here should be gdb.base/ prefix. Please give the testfile any name you find but not just the 49906 number. > --- gdb/symtab.c 21 Jul 2011 15:13:29 -0000 1.283 > +++ gdb/symtab.c 25 Oct 2011 17:28:46 -0000 > @@ -2474,6 +2474,7 @@ skip_prologue_sal (struct symtab_and_lin > struct gdbarch *gdbarch; > struct block *b, *function_block; > int force_skip, skip; > + const struct symtab_and_line start_sal_orig = *sal; > > /* Do not change the SAL is PC was specified explicitly. */ > if (sal->explicit_pc) > @@ -2627,6 +2628,29 @@ skip_prologue_sal (struct symtab_and_lin > sal->line = SYMBOL_LINE (BLOCK_FUNCTION (function_block)); > sal->symtab = SYMBOL_SYMTAB (BLOCK_FUNCTION (function_block)); > } > + else > + { > + /* Check if line number of apparent prologue end comes after > + the next line information. If so, do not skip prologue > + as something odd has happened. Probably gcc bug 49906. > + Instead of giving awkward location for the function start, > + give the previous good line (fuction start). */ > + const struct symtab_and_line prologue_sal_next > + = find_pc_line (sal->end, 0); > + > + if ((sym? (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) <= prologue_sal_next.end Code formatting: sym ? (... (I understand it is copy paste.) > + && prologue_sal_next.end < BLOCK_END (SYMBOL_BLOCK_VALUE (sym))) here was incorrect indentation. > + : (lookup_minimal_symbol_by_pc_section (prologue_sal_next.end, > + section) > + == lookup_minimal_symbol_by_pc_section (sal->pc, section))) > + && prologue_sal_next.line != 0 > + && prologue_sal_next.symtab == sal->symtab > + && prologue_sal_next.line >= start_sal_orig.line > + && prologue_sal_next.line < sal->line) Thanks, Jan 0000000000400474 : f(): f2.c:4 400474: 55 push %rbp 400475: 48 89 e5 mov %rsp,%rbp 400478: 89 7d fc mov %edi,-0x4(%rbp) f2.c:6 40047b: 8b 05 2f 04 20 00 mov 0x20042f(%rip),%eax # 6008b0 400481: 85 c0 test %eax,%eax 400483: 0f 95 c2 setne %dl 400486: 83 c0 01 add $0x1,%eax 400489: 89 05 21 04 20 00 mov %eax,0x200421(%rip) # 6008b0 40048f: 84 d2 test %dl,%dl 400491: 75 11 jne 4004a4 f2.c:5 400493: 8b 05 17 04 20 00 mov 0x200417(%rip),%eax # 6008b0 400499: 83 e8 01 sub $0x1,%eax 40049c: 89 05 0e 04 20 00 mov %eax,0x20040e(%rip) # 6008b0 f2.c:8 4004a2: eb d7 jmp 40047b f2.c:7 4004a4: 90 nop f2.c:8 4004a5: 5d pop %rbp 4004a6: c3 retq