From patchwork Mon Aug 29 13:55:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 112057 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 3CBE5B6F97 for ; Mon, 29 Aug 2011 23:55:39 +1000 (EST) Received: (qmail 30141 invoked by alias); 29 Aug 2011 13:55:35 -0000 Received: (qmail 29866 invoked by uid 22791); 29 Aug 2011 13:55:33 -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; Mon, 29 Aug 2011 13:55:15 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id F19862BAF48; Mon, 29 Aug 2011 09:55:14 -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 oSGWbmdfQkID; Mon, 29 Aug 2011 09:55:14 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id D6F832BB049; Mon, 29 Aug 2011 09:55:14 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id D525292A55; Mon, 29 Aug 2011 09:55:14 -0400 (EDT) Date: Mon, 29 Aug 2011 09:55:14 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Improve debugging facilities Message-ID: <20110829135514.GA21498@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 This patch adds new debugging routines (pp to print a node, node list, name_id, etc., and ppp to print a tree). No change in functionality; no test available. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-29 Bob Duff * treepr.ads: Improve debugging facilities. pn(x) no longer crashes in gdb when x is not a node (it can be a node list, name_id, etc). pp is an alias for pn. ppp is an alias for pt. Index: treepr.adb =================================================================== --- treepr.adb (revision 178155) +++ treepr.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -263,11 +263,40 @@ -- pn -- -------- - procedure pn (N : Node_Id) is + procedure pn (N : Union_Id) is begin - Print_Tree_Node (N); + case N is + when List_Low_Bound .. List_High_Bound - 1 => + pl (Int (N)); + when Node_Range => + Print_Tree_Node (Node_Id (N)); + when Elist_Range => + Print_Tree_Elist (Elist_Id (N)); + when Elmt_Range => + raise Program_Error; + when Names_Range => + Namet.wn (Name_Id (N)); + when Strings_Range => + Write_String_Table_Entry (String_Id (N)); + when Uint_Range => + Uintp.pid (From_Union (N)); + when Ureal_Range => + Urealp.pr (From_Union (N)); + when others => + Write_Str ("Invalid Union_Id: "); + Write_Int (Int (N)); + end case; end pn; + -------- + -- pp -- + -------- + + procedure pp (N : Union_Id) is + begin + pn (N); + end pp; + ---------------- -- Print_Char -- ---------------- @@ -1471,6 +1500,15 @@ Print_Node_Subtree (N); end pt; + --------- + -- ppp -- + --------- + + procedure ppp (N : Node_Id) is + begin + pt (N); + end ppp; + ------------------- -- Serial_Number -- ------------------- Index: treepr.ads =================================================================== --- treepr.ads (revision 178155) +++ treepr.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -57,25 +57,36 @@ -- Prints the subtree consisting of the given element list and all its -- referenced descendants. + -- The following debugging procedures are intended to be called from gdb + + procedure pp (N : Union_Id); + pragma Export (Ada, pp); + -- Prints a node, node list, uint, or anything else that falls under + -- Union_Id. + + procedure ppp (N : Node_Id); + pragma Export (Ada, ppp); + -- Same as Print_Node_Subtree + + -- The following are no longer needed; you can use pp or ppp instead + procedure pe (E : Elist_Id); pragma Export (Ada, pe); - -- Debugging procedure (to be called within gdb), same as Print_Tree_Elist + -- Same as Print_Tree_Elist procedure pl (L : Int); pragma Export (Ada, pl); - -- Debugging procedure (to be called within gdb), same as Print_Tree_List, - -- except that you can use e.g. 66 instead of -99999966. In other words - -- for the positive case we fill out to 8 digits on the left and add a - -- minus sign. This just saves some typing in the debugger. + -- Same as Print_Tree_List, except that you can use e.g. 66 instead of + -- -99999966. In other words for the positive case we fill out to 8 digits + -- on the left and add a minus sign. This just saves some typing in the + -- debugger. - procedure pn (N : Node_Id); + procedure pn (N : Union_Id); pragma Export (Ada, pn); - -- Debugging procedure (to be called within gdb) - -- same as Print_Tree_Node with Label = "" + -- Same as pp procedure pt (N : Node_Id); pragma Export (Ada, pt); - -- Debugging procedure (to be called within gdb) - -- same as Print_Node_Subtree + -- Same as ppp end Treepr;