🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #210

gdb enhancement request

#210
From: Steve Murphy
Date: Mon, 24 Jul 1989 19:15
113 lines
3883 bytes
I took my local gdb copy and did this to it:

*** valprint.c.orig	Sun Jul  9 19:26:36 1989
--- valprint.c	Fri Jul 21 17:29:33 1989
***************
*** 68,75 ****
  	  fprintf_filtered (stream, "\"");
  	  for (i = 0; i < n && i < print_max; i++)
  	    {
  	      QUIT;
! 	      printchar (VALUE_CONTENTS (val)[i], stream, '"');
  	    }
  	  if (i < n)
  	    fprintf_filtered (stream, "...");
--- 68,87 ----
  	  fprintf_filtered (stream, "\"");
  	  for (i = 0; i < n && i < print_max; i++)
  	    {
+ 		  int reps, rep1; 
  	      QUIT;
! 		  for(rep1=i+1,reps=1;
! 			  rep1 < n && VALUE_CONTENTS(val)[i] == VALUE_CONTENTS(val)[rep1];
! 			  reps++,rep1++)
! 			  ;
! 		  if( reps > 10 )
! 		  {
! 			  printchar (VALUE_CONTENTS(val)[i], stream, '"');
! 			  fprintf(stream,"<*%d>...",reps);
! 			  i = rep1 -1;
! 		  }
! 		  else
! 			  printchar (VALUE_CONTENTS (val)[i], stream, '"');
  	    }
  	  if (i < n)
  	    fprintf_filtered (stream, "...");
***************
*** 185,192 ****
  	      fprintf_filtered (stream, "\"");
  	      for (i = 0; i < len && i < print_max; i++)
  		{
  		  QUIT;
! 		  printchar (valaddr[i], stream, '"');
  		}
  	      if (i < len)
  		fprintf_filtered (stream, "...");
--- 197,214 ----
  	      fprintf_filtered (stream, "\"");
  	      for (i = 0; i < len && i < print_max; i++)
  		{
+ 		  int reps,rep1;
  		  QUIT;
! 		  for(rep1=i+1,reps=1;rep1 < len && valaddr[i] == valaddr[rep1];reps++,rep1++)
! 			  ;
! 		  if( reps > 5 )
! 		  {
! 			  printchar (valaddr[i], stream, '"');
! 			  fprintf(stream,"<*%d>...",reps);
! 			  i = rep1 -1;
! 		  }
! 		  else
! 			  printchar (valaddr[i], stream, '"');
  		}
  	      if (i < len)
  		fprintf_filtered (stream, "...");
***************
*** 196,205 ****
  	    {
  	      for (i = 0; i < len && i < print_max; i++)
  		{
  		  if (i) fprintf_filtered (stream, ", ");
! 		  val_print (elttype, valaddr + i * eltlen,
! 			     0, stream, format, deref_ref,
! 			     recurse + 1, pretty);
  		}
  	      if (i < len)
  		fprintf_filtered (stream, "...");
--- 218,239 ----
  	    {
  	      for (i = 0; i < len && i < print_max; i++)
  		{
+ 		  int reps,rep1;
  		  if (i) fprintf_filtered (stream, ", ");
! 		  for(rep1=i+1,reps=1;rep1 < len && !bcmp(valaddr+i*eltlen, valaddr+rep1*eltlen,eltlen);reps++,rep1++)
! 			  ;
! 		  if( reps > 5 )
! 		  {
! 			  val_print (elttype, valaddr + i * eltlen,
! 						 0, stream, format, deref_ref,
! 						 recurse + 1, pretty);
! 			  fprintf(stream,"<*%d>...",reps);
! 			  i = rep1 -1;
! 		  }
! 		  else
! 			  val_print (elttype, valaddr + i * eltlen,
! 						 0, stream, format, deref_ref,
! 						 recurse + 1, pretty);
  		}
  	      if (i < len)
  		fprintf_filtered (stream, "...");

=====================================================================
The reason for doing the above, of course, is to annotate repetitive
array info such that redundant info is cut down in size. Now, you implemented
my prettyprint suggestion very nicely, allowing the user to reject/demand it. 
Could the same be done with this? perhaps let the user control the number
(minimum) of successive repetitions in an array before notation is used,
and whether to do compression or not.

I've been running with for a while, and it works. Nice, because I don't have
to do as much counting at times to find which element is what number.

murf
Technical Details
Message-ID: <8907241915.AA12919@dingus.sun.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!CS.UTEXAS.EDU!oakhill!dingus!murf

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!CS.UTEXAS.EDU!oakhill!dingus!murf
From: oakhill!dingus!murf@CS.UTEXAS.EDU (Steve Murphy)
Newsgroups: gnu.gdb.bug
Subject: gdb enhancement request
Message-ID: <8907241915.AA12919@dingus.sun.com>
Date: 24 Jul 89 19:15:55 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 113