This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Add macro structures to symtabs, objfiles



This patch needs revision, too.  Fix typo in Makefile.in changes.

Jim Blandy <jimb@redhat.com> writes:
> This patch should also have no user-visible effect.  It doesn't affect
> the test suite results in the configuration I tested.

2002-05-08  Jim Blandy  <jimb@redhat.com>

	Add macro structures to GDB's symbol tables.  Nobody puts anything
	in them yet.
	* symtab.h (struct symtab): New member: `macro_table'.
	* buildsym.h (pending_macros): New global variable.
	* buildsym.c: #include "macrotab.h".
	(buildsym_init): Initialize `pending_macros'.
	(end_symtab): If we found macro information while reading a CU's
	debugging info, do build a symtab structure for it.  Make the
	symtab point to the macro information, and clear the
	`pending_macros' pointer which held it while we were reading the
	debug info.
	(really_free_pendings): Free any pending macro table.
	* objfiles.h (struct objfile): New member: `macro_cache'.
	* objfiles.c (allocate_objfile): Set allocate and free functions
	for the macro cache's objstack.
	(free_objfile): Empty the macro cache's obstack.
	* symfile.c (reread_symbols): Empty the macro cache's obstack, and
	set new allocate and free functions for it.
	* solib-sunos.c (allocate_rt_common_objfile): Set allocate and
	free functions for the macro cache's objstack.  (Why is this
	function building its own objfile?)
	* symmisc.c (print_objfile_statistics): Print statistics on the
	macro bcache.
	* Makefile.in: Note that buildsym.o depends on macrotab.h.

Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.180.2.1
diff -c -r1.180.2.1 Makefile.in
*** gdb/Makefile.in	8 May 2002 18:26:26 -0000	1.180.2.1
--- gdb/Makefile.in	8 May 2002 19:59:35 -0000
***************
*** 1303,1309 ****
  	$(completer_h) $(gdb_h)
  
  buildsym.o: buildsym.c $(bfd_h) $(buildsym_h) $(complaints_h) $(defs_h) \
! 	$(objfiles_h) $(symfile_h) $(symtab_h) $(gdb_string_h)
  
  builtin-regs.o: builtin-regs.c $(defs.h) $(builtin_regs_h) $(gdbtypes_h) \
  	$(gdb_string_h) $(value_h) $(frame_h)
--- 1303,1310 ----
  	$(completer_h) $(gdb_h)
  
  buildsym.o: buildsym.c $(bfd_h) $(buildsym_h) $(complaints_h) $(defs_h) \
! 	$(objfiles_h) $(symfile_h) $(symtab_h) $(gdb_string_h) \
! 	$(macrotab_h)
  
  builtin-regs.o: builtin-regs.c $(defs.h) $(builtin_regs_h) $(gdbtypes_h) \
  	$(gdb_string_h) $(value_h) $(frame_h)
Index: gdb/buildsym.c
===================================================================
RCS file: /cvs/src/src/gdb/buildsym.c,v
retrieving revision 1.14
diff -c -r1.14 buildsym.c
*** gdb/buildsym.c	20 Jan 2002 19:42:04 -0000	1.14
--- gdb/buildsym.c	8 May 2002 19:59:35 -0000
***************
*** 39,44 ****
--- 39,45 ----
  #include "language.h"		/* For "longest_local_hex_string_custom" */
  #include "bcache.h"
  #include "filenames.h"		/* For DOSish file names */
+ #include "macrotab.h"
  /* Ask buildsym.h to define the vars it normally declares `extern'.  */
  #define	EXTERN
  /**/
***************
*** 192,197 ****
--- 193,201 ----
        xfree ((void *) next);
      }
    global_symbols = NULL;
+ 
+   if (pending_macros)
+     free_macro_table (pending_macros);
  }
  
  /* This function is called to discard any pending blocks. */
***************
*** 883,889 ****
    if (pending_blocks == NULL
        && file_symbols == NULL
        && global_symbols == NULL
!       && have_line_numbers == 0)
      {
        /* Ignore symtabs that have no functions with real debugging
           info.  */
--- 887,894 ----
    if (pending_blocks == NULL
        && file_symbols == NULL
        && global_symbols == NULL
!       && have_line_numbers == 0
!       && pending_macros == NULL)
      {
        /* Ignore symtabs that have no functions with real debugging
           info.  */
***************
*** 944,949 ****
--- 949,955 ----
  
  	  /* Fill in its components.  */
  	  symtab->blockvector = blockvector;
+           symtab->macro_table = pending_macros;
  	  if (subfile->line_vector)
  	    {
  	      /* Reallocate the line table on the symbol obstack */
***************
*** 1022,1027 ****
--- 1028,1034 ----
  
    last_source_file = NULL;
    current_subfile = NULL;
+   pending_macros = NULL;
  
    return symtab;
  }
***************
*** 1112,1117 ****
--- 1119,1125 ----
    file_symbols = NULL;
    global_symbols = NULL;
    pending_blocks = NULL;
+   pending_macros = NULL;
  }
  
  /* Initialize anything that needs initializing when a completely new
Index: gdb/buildsym.h
===================================================================
RCS file: /cvs/src/src/gdb/buildsym.h,v
retrieving revision 1.3
diff -c -r1.3 buildsym.h
*** gdb/buildsym.h	6 Mar 2001 08:21:06 -0000	1.3
--- gdb/buildsym.h	8 May 2002 19:59:36 -0000
***************
*** 296,301 ****
--- 296,305 ----
  extern void merge_symbol_lists (struct pending **srclist,
  				struct pending **targetlist);
  
+ /* The macro table for the compilation unit whose symbols we're
+    currently reading.  All the symtabs for this CU will point to this.  */
+ EXTERN struct macro_table *pending_macros;
+ 
  #undef EXTERN
  
  #endif /* defined (BUILDSYM_H) */
Index: gdb/objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.19
diff -c -r1.19 objfiles.c
*** gdb/objfiles.c	6 Dec 2001 20:59:11 -0000	1.19
--- gdb/objfiles.c	8 May 2002 19:59:36 -0000
***************
*** 190,195 ****
--- 190,197 ----
  	      /* Update pointers to functions to *our* copies */
  	      obstack_chunkfun (&objfile->psymbol_cache.cache, xmmalloc);
  	      obstack_freefun (&objfile->psymbol_cache.cache, xmfree);
+ 	      obstack_chunkfun (&objfile->macro_cache.cache, xmmalloc);
+ 	      obstack_freefun (&objfile->macro_cache.cache, xmfree);
  	      obstack_chunkfun (&objfile->psymbol_obstack, xmmalloc);
  	      obstack_freefun (&objfile->psymbol_obstack, xmfree);
  	      obstack_chunkfun (&objfile->symbol_obstack, xmmalloc);
***************
*** 220,225 ****
--- 222,230 ----
  	      obstack_specify_allocation_with_arg (&objfile->psymbol_cache.cache,
  						   0, 0, xmmalloc, xmfree,
  						   objfile->md);
+ 	      obstack_specify_allocation_with_arg (&objfile->macro_cache.cache,
+ 						   0, 0, xmmalloc, xmfree,
+ 						   objfile->md);
  	      obstack_specify_allocation_with_arg (&objfile->psymbol_obstack,
  						   0, 0, xmmalloc, xmfree,
  						   objfile->md);
***************
*** 266,271 ****
--- 271,278 ----
        objfile->md = NULL;
        obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
  				  xmalloc, xfree);
+       obstack_specify_allocation (&objfile->macro_cache.cache, 0, 0,
+ 				  xmalloc, xfree);
        obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, xmalloc,
  				  xfree);
        obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc,
***************
*** 477,482 ****
--- 484,490 ----
  	xmfree (objfile->md, objfile->static_psymbols.list);
        /* Free the obstacks for non-reusable objfiles */
        free_bcache (&objfile->psymbol_cache);
+       free_bcache (&objfile->macro_cache);
        obstack_free (&objfile->psymbol_obstack, 0);
        obstack_free (&objfile->symbol_obstack, 0);
        obstack_free (&objfile->type_obstack, 0);
Index: gdb/objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.9
diff -c -r1.9 objfiles.h
*** gdb/objfiles.h	12 Oct 2001 19:07:07 -0000	1.9
--- gdb/objfiles.h	8 May 2002 19:59:37 -0000
***************
*** 277,282 ****
--- 277,283 ----
         will not change. */
  
      struct bcache psymbol_cache;	/* Byte cache for partial syms */
+     struct bcache macro_cache;          /* Byte cache for macros */
  
      /* Vectors of all partial symbols read in from file.  The actual data
         is stored in the psymbol_obstack. */
Index: gdb/solib-sunos.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-sunos.c,v
retrieving revision 1.3
diff -c -r1.3 solib-sunos.c
*** gdb/solib-sunos.c	23 Jan 2002 06:24:20 -0000	1.3
--- gdb/solib-sunos.c	8 May 2002 19:59:38 -0000
***************
*** 137,142 ****
--- 137,144 ----
    objfile->md = NULL;
    obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
  			      xmalloc, xfree);
+   obstack_specify_allocation (&objfile->macro_cache.cache, 0, 0,
+ 			      xmalloc, xfree);
    obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, xmalloc,
  			      xfree);
    obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc,
Index: gdb/symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.60
diff -c -r1.60 symfile.c
*** gdb/symfile.c	25 Apr 2002 16:29:27 -0000	1.60
--- gdb/symfile.c	8 May 2002 19:59:39 -0000
***************
*** 1713,1718 ****
--- 1713,1719 ----
  
  	      /* Free the obstacks for non-reusable objfiles */
  	      free_bcache (&objfile->psymbol_cache);
+ 	      free_bcache (&objfile->macro_cache);
  	      obstack_free (&objfile->psymbol_obstack, 0);
  	      obstack_free (&objfile->symbol_obstack, 0);
  	      obstack_free (&objfile->type_obstack, 0);
***************
*** 1737,1742 ****
--- 1738,1745 ----
  	      /* obstack_specify_allocation also initializes the obstack so
  	         it is empty.  */
  	      obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
+ 					  xmalloc, xfree);
+ 	      obstack_specify_allocation (&objfile->macro_cache.cache, 0, 0,
  					  xmalloc, xfree);
  	      obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0,
  					  xmalloc, xfree);
Index: gdb/symmisc.c
===================================================================
RCS file: /cvs/src/src/gdb/symmisc.c,v
retrieving revision 1.8
diff -c -r1.8 symmisc.c
*** gdb/symmisc.c	22 Mar 2002 18:57:08 -0000	1.8
--- gdb/symmisc.c	8 May 2002 19:59:40 -0000
***************
*** 197,202 ****
--- 197,204 ----
  		     obstack_memory_used (&objfile->psymbol_obstack));
      printf_filtered ("  Total memory used for psymbol cache: %d\n",
  		     obstack_memory_used (&objfile->psymbol_cache.cache));
+     printf_filtered ("  Total memory used for macro cache: %d\n",
+ 		     obstack_memory_used (&objfile->macro_cache.cache));
      printf_filtered ("  Total memory used for symbol obstack: %d\n",
  		     obstack_memory_used (&objfile->symbol_obstack));
      printf_filtered ("  Total memory used for type obstack: %d\n",
Index: gdb/symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.31
diff -c -r1.31 symtab.h
*** gdb/symtab.h	24 Apr 2002 08:00:54 -0000	1.31
--- gdb/symtab.h	8 May 2002 19:59:41 -0000
***************
*** 824,829 ****
--- 824,834 ----
  
      int primary;
  
+     /* The macro table for this symtab.  Like the blockvector, this
+        may be shared between different symtabs --- and normally is for
+        all the symtabs in a given compilation unit.  */
+     struct macro_table *macro_table;
+ 
      /* Name of this source file.  */
  
      char *filename;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]