🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2558

bug(s) in print-tree.c (with patches)

#2558
From: Ron Guilmette
Date: Mon, 24 Apr 1989 19:25
94 lines
3617 bytes
I have been making calls to debug_dump_tree() from within the
debugger (i.e. on the fly) to see what is happening to various
trees.  While doing this, I noticed two things:

	1)  I got segfaults sometimes because the dump() routine
	    (also in the print-tree.c file) tries to call print_rtl()
	    for operand[2] of CALL_EXPR's.  Sometimes, operand[2] is
	    null (for c++ at least) so when print_rtl() tries to
	    dereference its second argument... WACKO!  SEGFAULT!

	    The last patch below seems to fix the problem nicely.

	2)  the dump_tree() routine will *not* dump out all of the
	    information about a sub-tree which you may want to see.
	    This is apparently due to the fact that the "walk()"
	    routine tries to avoid visiting certain kinds of nodes
	    which it thinks may have already been printed out (even
	    though they have not been!).

	    Most of the patches given below are meant to provide a
	    alternative to debug_dump_tree() called debug_dump_whole_tree()
	    which will give you the *whole* story.  The patches are
	    quite trivial.

P.S. the following patches were made for the G++ 1.35.0- (pre-release)
but they will probably work fine also for G++ 1.34.x and/or GCC 1.34/1.35.

*** print-tree.c-	Mon Feb 27 19:40:59 1989
--- print-tree.c	Mon Apr 24 14:24:03 1989
***************
*** 59,63 ****
--- 59,74 ----
  }
  
+ static int interactive_tree_dumping = 0;
+ 
  void
+ debug_dump_whole_tree (root)
+      tree root;
+ {
+   interactive_tree_dumping = -1;
+   dump_tree (stderr, root);
+   interactive_tree_dumping = 0;
+ }
+ 
+ void
  dump_tree (outf, root)
       FILE *outf;
***************
*** 126,130 ****
       int indent;
  {
!   if (node != NULL
        /* Don't walk any global nodes reached from local nodes!
  	 The global nodes will be dumped at the end, all together.
--- 137,141 ----
       int indent;
  {
!   if (node != NULL && (interactive_tree_dumping ||
        /* Don't walk any global nodes reached from local nodes!
  	 The global nodes will be dumped at the end, all together.
***************
*** 131,137 ****
  	 Also don't mention a FUNCTION_DECL node that is marked local
  	 since it was fully described when it was dumped locally.  */
!       && (TREE_CODE (node) != FUNCTION_DECL
  	  || TREE_PERMANENT (node))
!       && (TREE_PERMANENT (leaf) == TREE_PERMANENT (node)))
      dump (node, indent+1);
  }
--- 142,148 ----
  	 Also don't mention a FUNCTION_DECL node that is marked local
  	 since it was fully described when it was dumped locally.  */
!       ((TREE_CODE (node) != FUNCTION_DECL
  	  || TREE_PERMANENT (node))
!       && (TREE_PERMANENT (leaf) == TREE_PERMANENT (node)))))
      dump (node, indent+1);
  }
***************
*** 435,438 ****
--- 446,451 ----
  	case CALL_EXPR:
  	  first_rtl = 2;
+ 	  if (!TREE_OPERAND (node, first_rtl))
+ 	    len--;			/* operand[2] may be null */
  	  break;
  	case METHOD_CALL_EXPR:


// Ron Guilmette  -  MCC  -  Experimental Systems Kit Project
// 3500 West Balcones Center Drive,  Austin, TX  78759  -  (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg
Technical Details
Message-ID: <8904241925.AA26368@riunite.aca.mcc.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfg
From: rfg@MCC.COM (Ron Guilmette)
Newsgroups: gnu.gcc.bug
Subject: bug(s) in print-tree.c (with patches)
Message-ID: <8904241925.AA26368@riunite.aca.mcc.com>
Date: 24 Apr 89 19:25:39 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 94