From patchwork Tue Aug 2 14:39:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 107934 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 4DC94B74C6 for ; Wed, 3 Aug 2011 00:39:54 +1000 (EST) Received: (qmail 27184 invoked by alias); 2 Aug 2011 14:39:49 -0000 Received: (qmail 27053 invoked by uid 22791); 2 Aug 2011 14:39:47 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Aug 2011 14:39:33 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 001D52BB161; Tue, 2 Aug 2011 10:39:33 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id azcDUHJWE7lJ; Tue, 2 Aug 2011 10:39:32 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id E1DC12BB165; Tue, 2 Aug 2011 10:39:32 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id E05223FEE8; Tue, 2 Aug 2011 10:39:32 -0400 (EDT) Date: Tue, 2 Aug 2011 10:39:32 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Fix missing debug info for concatenation Message-ID: <20110802143932.GA5791@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 The new concatenation circuitry installed some time ago, results in missing debug information when a constant string is initialized with the result of a concatenation. This is because the resulting generated renaming did not generate required debug information. This patch fixes the problem with concatenation, and is actually a little more general than that, so may fix some other problems with missing debug info. The following is a test program 1. procedure debugconcat is 2. x : string := "hello"; 3. y : string := "goodbye"; 4. z : constant string := x & y; 5. begin 6. null; 7. end; Before the patch, the debugger could not print the string z. With the following script: gnatmake debugconcat -g cp gdbinit2 .gdbinit gdb --quiet debugconcat.exe >log 2>&1 rm .gdbinit grep " = " log where gdbinit2 contains: break debugconcat.adb:6 run print z quit y the output of the grep command should be: $1 = "hellogoodbye" Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-02 Robert Dewar * einfo.ads (Materialize_Entity): Document this is only for renamings * exp_ch3.adb (Expand_N_Object_Declaration): Make sure we generate required debug information in the case where we transform the object declaration into a renaming declaration. * exp_ch4.adb (Expand_Concatenate): Generate debug info for result object * exp_dbug.ads (Debug_Renaming_Declaration): Document setting of Materialize_Entity. Index: einfo.ads =================================================================== --- einfo.ads (revision 177161) +++ einfo.ads (working copy) @@ -2943,11 +2943,10 @@ -- used to reference tasks implementing such interface. -- Materialize_Entity (Flag168) --- Present in all entities. Set only for constant or renamed entities --- which should be materialized for debugging purposes. In the case of --- a constant, a memory location should be allocated containing the --- value. In the case of a renaming, a memory location containing the --- renamed address should be allocated. +-- Present in all entities. Set only for renamed obects which should be +-- materialized for debugging purposes. This means that a memory location +-- containing the renamed address should be allocated. This is needed so +-- that the debugger can find the entity. -- Mechanism (Uint8) (returned as Mechanism_Type) -- Present in functions and non-generic formal parameters. Indicates Index: exp_dbug.ads =================================================================== --- exp_dbug.ads (revision 176998) +++ exp_dbug.ads (working copy) @@ -1082,7 +1082,8 @@ function Debug_Renaming_Declaration (N : Node_Id) return Node_Id; -- The argument N is a renaming declaration. The result is a variable -- declaration as described in the above paragraphs. If N is not a special - -- debug declaration, then Empty is returned. + -- debug declaration, then Empty is returned. This function also takes care + -- of setting Materialize_Entity on the renamed entity where required. --------------------------- -- Packed Array Encoding -- Index: exp_ch4.adb =================================================================== --- exp_ch4.adb (revision 177156) +++ exp_ch4.adb (working copy) @@ -2875,10 +2875,12 @@ -- Now we construct an array object with appropriate bounds. We mark -- the target as internal to prevent useless initialization when - -- Initialize_Scalars is enabled. + -- Initialize_Scalars is enabled. Also since this is the actual result + -- entity, we make sure we have debug information for the result. Ent := Make_Temporary (Loc, 'S'); Set_Is_Internal (Ent); + Set_Needs_Debug_Info (Ent); -- If the bound is statically known to be out of range, we do not want -- to abort, we want a warning and a runtime constraint error. Note that Index: exp_ch3.adb =================================================================== --- exp_ch3.adb (revision 177161) +++ exp_ch3.adb (working copy) @@ -34,6 +34,7 @@ with Exp_Ch7; use Exp_Ch7; with Exp_Ch9; use Exp_Ch9; with Exp_Ch11; use Exp_Ch11; +with Exp_Dbug; use Exp_Dbug; with Exp_Disp; use Exp_Disp; with Exp_Dist; use Exp_Dist; with Exp_Smem; use Exp_Smem; @@ -5215,6 +5216,26 @@ Set_Renamed_Object (Defining_Identifier (N), Expr_Q); Set_Analyzed (N); + + -- We do need to deal with debug issues for this renaming + + -- First, if entity comes from source, then mark it as needing + -- debug information, even though it is defined by a generated + -- renaming that does not come from source. + + if Comes_From_Source (Defining_Identifier (N)) then + Set_Needs_Debug_Info (Defining_Identifier (N)); + end if; + + -- Now call the routine to generate debug info for the renaming + + declare + Decl : constant Node_Id := Debug_Renaming_Declaration (N); + begin + if Present (Decl) then + Insert_Action (N, Decl); + end if; + end; end if; end if;