🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #10169

Speed of reading in additional symbols.

#10169
From: Jim Kingdon
Date: Fri, 06 Apr 1990 09:47
158 lines
5560 bytes
Summary: Here is a patch which I think helps GDB performance.  Please
         let me know if it significantly hurts performance for you.

Various people have reported annoying pauses when GDB reads in
additional symbols ("Reading in symbols for foo.c...").  The
time-consuming part of this is reading the string table for the entire
symbol file.  The patch below keeps the string table always resident
in memory, thus speeding things up.

The only disadvantage is that this potentially uses more memory.
However, even without this patch GDB needs the memory for the entire
string table at *some* point.  The memory it uses there is not re-used
by the system unless it's smart enough to re-use malloc'd or alloca'd
memory.  The memory is only re-used by GDB to the extent that it has
stuff to put there that is gone by the next time that GDB needs to
read the string table.  

The reason that this isn't in the GDB 3.5 distribution is that I want
to be careful not to break things that are working in GDB version 3.
Thus I was going to just include the change in version 4, so people
could complain if it turns out to make things worse.  But now you have
the chance to complain now if that is that case!

*** dbxread.c.~1~	Tue Jan 23 23:43:45 1990
--- dbxread.c	Wed Jan 24 06:32:25 1990
***************
*** 1568,1573 ****
--- 1568,1575 ----
  /* The entry point.  */
  static CORE_ADDR entry_point;
  
+ static char *symfile_string_table;
+ 
  /* This is the symbol-file command.  Read the file, analyze its symbols,
     and add a struct symtab to symtab_list.  */
  
***************
*** 1656,1661 ****
--- 1658,1671 ----
    READ_STRING_TABLE_SIZE (buffer);
    if (buffer >= 0 && buffer < statbuf.st_size)
      {
+       /* This should speed things up without consuming much
+ 	 extra memory (because probably little of the space is going
+ 	 to be reused anyway, whether in data or stack space).
+ 
+ 	 A quick test (running GDB on itself and setting 9 breakpoints
+ 	 in different files) showed that memory usage was almost
+ 	 identical for the two cases.  */
+ #if 0
  #ifdef BROKEN_LARGE_ALLOCA
        stringtab = (char *) xmalloc (buffer);
        make_cleanup (free, stringtab);
***************
*** 1662,1667 ****
--- 1672,1680 ----
  #else
        stringtab = (char *) alloca (buffer);
  #endif
+ #endif
+       stringtab = (char *) xmalloc (buffer);
+       symfile_string_table = stringtab;
      }
    else
      stringtab = NULL;
***************
*** 2910,2915 ****
--- 2923,2929 ----
        READ_STRING_TABLE_SIZE (stsize);
        if (stsize >= 0 && stsize < statbuf.st_size)
  	{
+ #if 0
  #ifdef BROKEN_LARGE_ALLOCA
  	  stringtab = (char *) xmalloc (stsize);
  	  make_cleanup (free, stringtab);
***************
*** 2916,2921 ****
--- 2930,2937 ----
  #else
  	  stringtab = (char *) alloca (stsize);
  #endif
+ #endif
+ 	  stringtab = symfile_string_table;
  	}
        else
  	stringtab = NULL;
*** dbxread.c.~20~	Wed Apr  4 15:43:46 1990
--- dbxread.c	Fri Apr  6 04:20:12 1990
***************
*** 1512,1517 ****
--- 1512,1518 ----
  static CORE_ADDR entry_point;
  
  static char *symfile_string_table;
+ static int symfile_string_table_size;
  
  /* This is the symbol-file command.  Read the file, analyze its symbols,
     and add a struct symtab to symtab_list.  */
***************
*** 1622,1627 ****
--- 1622,1628 ----
  #endif
        stringtab = (char *) xmalloc (buffer);
        symfile_string_table = stringtab;
+       symfile_string_table_size = stsize;
      }
    else
      stringtab = NULL;
***************
*** 2909,2920 ****
  
        READ_FILE_HEADERS (desc, name);
  
        /* Read in the string table */
        lseek (desc, STRING_TABLE_OFFSET, L_SET);
        READ_STRING_TABLE_SIZE (stsize);
        if (stsize >= 0 && stsize < statbuf.st_size)
  	{
- #if 0
  #ifdef BROKEN_LARGE_ALLOCA
  	  stringtab = (char *) xmalloc (stsize);
  	  make_cleanup (free, stringtab);
--- 2911,2922 ----
  
        READ_FILE_HEADERS (desc, name);
  
+ #if 0
        /* Read in the string table */
        lseek (desc, STRING_TABLE_OFFSET, L_SET);
        READ_STRING_TABLE_SIZE (stsize);
        if (stsize >= 0 && stsize < statbuf.st_size)
  	{
  #ifdef BROKEN_LARGE_ALLOCA
  	  stringtab = (char *) xmalloc (stsize);
  	  make_cleanup (free, stringtab);
***************
*** 2921,2928 ****
  #else
  	  stringtab = (char *) alloca (stsize);
  #endif
- #endif
- 	  stringtab = symfile_string_table;
  	}
        else
  	stringtab = NULL;
--- 2923,2928 ----
***************
*** 2937,2942 ****
--- 2937,2945 ----
        val = myread (desc, stringtab, stsize);
        if (val < 0)
  	perror_with_name (name);
+ #endif /* 0 */
+       stringtab = symfile_string_table;
+       stsize = symfile_string_table_size;
  
        psymtab_to_symtab_1 (pst, desc, stringtab, stsize,
  			   SYMBOL_TABLE_OFFSET);
Technical Details
Message-ID: <9004060947.AA10950@pogo>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!AI.MIT.EDU!kingdon

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,d3d6517979890a47,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1990-04-06 11:18:00 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!AI.MIT.EDU!kingdon
From: kingdon@AI.MIT.EDU (Jim Kingdon)
Newsgroups: gnu.gdb.bug
Subject: Speed of reading in additional symbols.
Message-ID: <9004060947.AA10950@pogo>
Date: 6 Apr 90 09:47:23 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 158
Posted: Fri Apr  6 10:47:23 1990