From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23768 invoked by alias); 22 Sep 2008 14:57:06 -0000 Received: (qmail 23736 invoked by uid 22791); 22 Sep 2008 14:57:05 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 22 Sep 2008 14:56:20 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 5022B10C30; Mon, 22 Sep 2008 14:56:18 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 26CD810194; Mon, 22 Sep 2008 14:56:18 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1Khmpl-0000EQ-Ey; Mon, 22 Sep 2008 10:56:17 -0400 Date: Mon, 22 Sep 2008 14:57:00 -0000 From: Daniel Jacobowitz To: Jonathan Larmour Cc: gdb@sourceware.org Subject: Re: Broken prologue skipping with non-returning function Message-ID: <20080922145617.GA521@caradoc.them.org> Mail-Followup-To: Jonathan Larmour , gdb@sourceware.org References: <48D3B81B.3000801@eCosCentric.com> <20080919145937.GA1024@caradoc.them.org> <48D3F6D5.30503@eCosCentric.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48D3F6D5.30503@eCosCentric.com> User-Agent: Mutt/1.5.17 (2008-05-11) 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-09/txt/msg00123.txt.bz2 On Fri, Sep 19, 2008 at 08:00:37PM +0100, Jonathan Larmour wrote: > I can check in your change too. If so, presumably you already have a > ChangeLog entry you'd like me to use to ease your merges? > > Jifl > > 2008-09-19 Jonathan Larmour > > * arm-tdep.c (arm_skip_prologue): Call skip_prologue_using_sal > instead of determining symbol and line info directly. This patch is OK. Here's mine again, with changelog; I committed it. Both patches, in essentially the same form, have been in CodeSourcery's tree for two years. So I'm quite confident in them, as far as GCC goes, and it's clearly an improvement from the ad-hoc line check in arm-tdep.c. skip_prologue_using_sal does have some limitations; it's risky with incorrect debug info, and it's a problem for non-GCC compilers that do not emit the duplicate line note. More on that, some other time. -- Daniel Jacobowitz CodeSourcery 2008-09-22 Daniel Jacobowitz * symtab.c (skip_prologue_using_sal): Treat two consecutive lines at the same address as a prologue marker. Do not skip an entire function. --- symtab.c 2008-09-05 10:11:13.000000000 -0400 +++ symtab.c 2008-09-19 10:46:03.000000000 -0400 @@ -4198,6 +4235,7 @@ skip_prologue_using_sal (CORE_ADDR func_ struct symtab_and_line prologue_sal; CORE_ADDR start_pc; CORE_ADDR end_pc; + struct block *bl; /* Get an initial range for the function. */ find_pc_partial_function (func_addr, NULL, &start_pc, &end_pc); @@ -4206,11 +4244,35 @@ skip_prologue_using_sal (CORE_ADDR func_ prologue_sal = find_pc_line (start_pc, 0); if (prologue_sal.line != 0) { + /* For langauges other than assembly, treat two consecutive line + entries at the same address as a zero-instruction prologue. + The GNU assembler emits separate line notes for each instruction + in a multi-instruction macro, but compilers generally will not + do this. */ + if (prologue_sal.symtab->language != language_asm) + { + struct linetable *linetable = LINETABLE (prologue_sal.symtab); + int exact; + int idx = 0; + + /* Skip any earlier lines, and any end-of-sequence marker + from a previous function. */ + while (linetable->item[idx].pc != prologue_sal.pc + || linetable->item[idx].line == 0) + idx++; + + if (idx+1 < linetable->nitems + && linetable->item[idx+1].line != 0 + && linetable->item[idx+1].pc == start_pc) + return start_pc; + } + /* If there is only one sal that covers the entire function, then it is probably a single line function, like "foo(){}". */ if (prologue_sal.end >= end_pc) return 0; + while (prologue_sal.end < end_pc) { struct symtab_and_line sal; @@ -4232,7 +4313,14 @@ skip_prologue_using_sal (CORE_ADDR func_ prologue_sal = sal; } } - return prologue_sal.end; + + if (prologue_sal.end < end_pc) + /* Return the end of this line, or zero if we could not find a + line. */ + return prologue_sal.end; + else + /* Don't return END_PC, which is past the end of the function. */ + return prologue_sal.pc; } struct symtabs_and_lines