[02/21] struct symtab split part 2: objfiles.c objfiles.h

Message ID 5464aa42.22c5440a.14f0.ffff8d3f@mx.google.com
State New, archived
Headers

Commit Message

Doug Evans Nov. 13, 2014, 12:54 p.m. UTC
  This patch contains the changes to objfiles.c, objfiles.h.

Full ChangeLog: https://sourceware.org/ml/gdb-patches/2014-11/msg00233.html

2014-11-12  Doug Evans  <xdje42@gmail.com>

	* objfiles.c (objfile_relocate1): Loop over blockvectors in a
	separate loop.
	* objfiles.h (struct objfile) <compunit_symtabs>: Renamed from
	symtabs.  Change type to "struct compunit_symtab *".  All uses updated.
	(ALL_OBJFILE_FILETABS): Renamed from ALL_OBJFILE_SYMTABS.
	All uses updated.
	(ALL_OBJFILE_COMPUNITS): Renamed from ALL_OBJFILE_PRIMARY_SYMTABS.
	All uses updated.
	(ALL_FILETABS): Renamed from ALL_SYMTABS.  All uses updated.
	(ALL_COMPUNITS): Renamed from ALL_PRIMARY_SYMTABS.  All uses updated.
  

Patch

diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index cbe1b8c..5878add 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -740,12 +740,12 @@  objfile_relocate1 (struct objfile *objfile,
 
   /* OK, get all the symtabs.  */
   {
+    struct compunit_symtab *cust;
     struct symtab *s;
 
-    ALL_OBJFILE_SYMTABS (objfile, s)
+    ALL_OBJFILE_FILETABS (objfile, cust, s)
     {
       struct linetable *l;
-      const struct blockvector *bv;
       int i;
 
       /* First the line table.  */
@@ -753,17 +753,20 @@  objfile_relocate1 (struct objfile *objfile,
       if (l)
 	{
 	  for (i = 0; i < l->nitems; ++i)
-	    l->item[i].pc += ANOFFSET (delta, s->block_line_section);
+	    l->item[i].pc += ANOFFSET (delta,
+				       COMPUNIT_BLOCK_LINE_SECTION
+					 (cust));
 	}
+    }
 
-      /* Don't relocate a shared blockvector more than once.  */
-      if (!s->primary)
-	continue;
+    ALL_OBJFILE_COMPUNITS (objfile, cust)
+    {
+      const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+      int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
 
-      bv = SYMTAB_BLOCKVECTOR (s);
       if (BLOCKVECTOR_MAP (bv))
 	addrmap_relocate (BLOCKVECTOR_MAP (bv),
-			  ANOFFSET (delta, s->block_line_section));
+			  ANOFFSET (delta, block_line_section));
 
       for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
 	{
@@ -772,8 +775,8 @@  objfile_relocate1 (struct objfile *objfile,
 	  struct dict_iterator iter;
 
 	  b = BLOCKVECTOR_BLOCK (bv, i);
-	  BLOCK_START (b) += ANOFFSET (delta, s->block_line_section);
-	  BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
+	  BLOCK_START (b) += ANOFFSET (delta, block_line_section);
+	  BLOCK_END (b) += ANOFFSET (delta, block_line_section);
 
 	  /* We only want to iterate over the local symbols, not any
 	     symbols in included symtabs.  */
@@ -939,7 +942,7 @@  objfile_has_partial_symbols (struct objfile *objfile)
 int
 objfile_has_full_symbols (struct objfile *objfile)
 {
-  return objfile->symtabs != NULL;
+  return objfile->compunit_symtabs != NULL;
 }
 
 /* Return non-zero if OBJFILE has full or partial symbols, either directly
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index b14aab0..a888311 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -28,7 +28,6 @@ 
 
 struct bcache;
 struct htab;
-struct symtab;
 struct objfile_data;
 
 /* This structure maintains information on a per-objfile basis about the
@@ -286,11 +285,10 @@  struct objfile
 
     struct program_space *pspace;
 
-    /* Each objfile points to a linked list of symtabs derived from this file,
-       one symtab structure for each compilation unit (source file).  Each link
-       in the symtab list contains a backpointer to this objfile.  */
+    /* List of compunits.
+       These are used to do symbol lookups and file/line-number lookups.  */
 
-    struct symtab *symtabs;
+    struct compunit_symtab *compunit_symtabs;
 
     /* Each objfile points to a linked list of partial symtabs derived from
        this file, one partial symtab structure for each compilation unit
@@ -590,14 +588,14 @@  extern void default_iterate_over_objfiles_in_search_order
 
 /* Traverse all symtabs in one objfile.  */
 
-#define	ALL_OBJFILE_SYMTABS(objfile, s) \
-    for ((s) = (objfile) -> symtabs; (s) != NULL; (s) = (s) -> next)
+#define ALL_OBJFILE_FILETABS(objfile, cu, s) \
+  ALL_OBJFILE_COMPUNITS (objfile, cu) \
+    ALL_COMPUNIT_FILETABS (cu, s)
 
-/* Traverse all primary symtabs in one objfile.  */
+/* Traverse all compunits in one objfile.  */
 
-#define ALL_OBJFILE_PRIMARY_SYMTABS(objfile, s) \
-  ALL_OBJFILE_SYMTABS ((objfile), (s)) \
-    if ((s)->primary)
+#define ALL_OBJFILE_COMPUNITS(objfile, cu) \
+  for ((cu) = (objfile) -> compunit_symtabs; (cu) != NULL; (cu) = (cu) -> next)
 
 /* Traverse all minimal symbols in one objfile.  */
 
@@ -609,17 +607,15 @@  extern void default_iterate_over_objfiles_in_search_order
 /* Traverse all symtabs in all objfiles in the current symbol
    space.  */
 
-#define	ALL_SYMTABS(objfile, s) \
-  ALL_OBJFILES (objfile)	 \
-    ALL_OBJFILE_SYMTABS (objfile, s)
+#define ALL_FILETABS(objfile, ps, s)		\
+  ALL_OBJFILES (objfile)			\
+    ALL_OBJFILE_FILETABS (objfile, ps, s)
 
-/* Traverse all symtabs in all objfiles in the current program space,
-   skipping included files (which share a blockvector with their
-   primary symtab).  */
+/* Traverse all compunits in all objfiles in the current program space.  */
 
-#define ALL_PRIMARY_SYMTABS(objfile, s) \
+#define ALL_COMPUNITS(objfile, cu)	\
   ALL_OBJFILES (objfile)		\
-    ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+    ALL_OBJFILE_COMPUNITS (objfile, cu)
 
 /* Traverse all minimal symbols in all objfiles in the current symbol
    space.  */