From patchwork Thu Mar 31 14:35:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 89082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 51A8AB6F2B for ; Fri, 1 Apr 2011 01:36:01 +1100 (EST) Received: (qmail 18006 invoked by alias); 31 Mar 2011 14:36:00 -0000 Received: (qmail 17901 invoked by uid 22791); 31 Mar 2011 14:35:59 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD 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; Thu, 31 Mar 2011 14:35:49 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2VEZmmw016212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 31 Mar 2011 10:35:49 -0400 Received: from localhost.seketeli.org (ovpn-113-32.phx2.redhat.com [10.3.113.32]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2VEZjqf024623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 31 Mar 2011 10:35:47 -0400 Received: by localhost.seketeli.org (Postfix, from userid 500) id A77632A0298; Thu, 31 Mar 2011 16:35:44 +0200 (CEST) From: Dodji Seketeli To: Richard Henderson Cc: Jan Kratochvil , GCC Patches Subject: Re: [PATCH] PR debug/47471 (set prologue_end in .debug_line) References: <4D93EE06.6000501@redhat.com> X-URL: http://www.redhat.com Date: Thu, 31 Mar 2011 16:35:44 +0200 In-Reply-To: <4D93EE06.6000501@redhat.com> (Richard Henderson's message of "Wed, 30 Mar 2011 19:59:18 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Richard, Thank you for the crystal clear explanation. Now I understand why we were not using the end_prologue debug hook before :-). From what you say and from what Jan said, I think we could just keep the part (of my earlier patch) that avoids emitting two consecutive redundant .loc directives. It seems to me that in the case of direct output (i.e when we the underlying assembler doesn't support the .loc directive) we already avoid the duplication. And that avoidance fixes the immediate issue GDB is facing, with -g -O0. With -g -O>0, GDB doesn't have the issue as the DW_AT_location attributes of the variable DIEs are locations that are valid in the region of the prologue, so it doesn't need to know where the prologue ends. Just trusting DW_AT_location is enough. I am currently testing the stripped down patch below. Thanks. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 91be9a4..7134315 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -22145,8 +22145,6 @@ static void dwarf2out_source_line (unsigned int line, const char *filename, int discriminator, bool is_stmt) { - static bool last_is_stmt = true; - if (debug_info_level >= DINFO_LEVEL_NORMAL && line != 0) { @@ -22161,19 +22159,34 @@ dwarf2out_source_line (unsigned int line, const char *filename, if (DWARF2_ASM_LINE_DEBUG_INFO) { - /* Emit the .loc directive understood by GNU as. */ - fprintf (asm_out_file, "\t.loc %d %d 0", file_num, line); - if (is_stmt != last_is_stmt) + static bool last_is_stmt = true; + static int last_file_num = -1; + static unsigned last_line = 0; + static int last_discriminator = -1; + + if (last_file_num != file_num + || last_line != line + || last_is_stmt != is_stmt + || last_discriminator != discriminator) { - fprintf (asm_out_file, " is_stmt %d", is_stmt ? 1 : 0); + /* Emit the .loc directive understood by GNU as. */ + fprintf (asm_out_file, "\t.loc %d %d 0", file_num, line); + + if (is_stmt != last_is_stmt) + fprintf (asm_out_file, " is_stmt %d", is_stmt ? 1 : 0); + + if (SUPPORTS_DISCRIMINATOR && discriminator != 0) + fprintf (asm_out_file, " discriminator %d", discriminator); + fputc ('\n', asm_out_file); + + /* Indicate that line number info exists. */ + line_info_table_in_use++; + + last_file_num = file_num; + last_line = line; + last_discriminator = discriminator; last_is_stmt = is_stmt; } - if (SUPPORTS_DISCRIMINATOR && discriminator != 0) - fprintf (asm_out_file, " discriminator %d", discriminator); - fputc ('\n', asm_out_file); - - /* Indicate that line number info exists. */ - line_info_table_in_use++; } else if (function_section (current_function_decl) != text_section) {