public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA 29/42] Move the symbol lists to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (7 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 13/42] Remove buildsym_new_init Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-06 18:35   ` Keith Seitz
  2018-07-10  3:38   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 05/42] Move pending_macros " Tom Tromey
                   ` (34 subsequent siblings)
  43 siblings, 2 replies; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the global symbol lists into buildsym_compunit, adds
accessors, and updates all the users.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab, process_xcoff_symbol): Update.
	* stabsread.c (patch_block_stabs, define_symbol, read_type)
	(read_enum_type, common_block_start, common_block_end)
	(cleanup_undefined_types_1, finish_global_stabs): Update.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* dwarf2read.c (fixup_go_packaging, read_func_scope)
	(read_lexical_block_scope, new_symbol): Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read, process_coff_symbol)
	(coff_read_enum_type): Update.
	* buildsym.h (file_symbols, global_symbols, local_symbols): Don't
	declare.
	(get_local_symbols, get_file_symbols, get_global_symbols): New
	functions.
	* buildsym.c (~buildsym_compunit): Clean up m_file_symbols and
	m_global_symbols.
	<m_file_symbols, m_local_symbols, m_global_symbols>: New members.
	(~scoped_free_pendings): Update.
	(finish_block, prepare_for_building, reset_symtab_globals)
	(end_symtab_get_static_block, end_symtab_with_blockvector)
	(augment_type_symtab, push_context): Update.
	(get_local_symbols, get_file_symbols, get_global_symbols): New
	functions.
	(buildsym_init): Update.
---
 gdb/ChangeLog    |  27 ++++++++++++++
 gdb/buildsym.c   | 112 ++++++++++++++++++++++++++++++++++---------------------
 gdb/buildsym.h   |  26 ++++++-------
 gdb/coffread.c   |  30 +++++++--------
 gdb/dbxread.c    |   6 +--
 gdb/dwarf2read.c |  38 +++++++++----------
 gdb/mdebugread.c |   2 +-
 gdb/stabsread.c  |  65 ++++++++++++++++----------------
 gdb/xcoffread.c  |   8 ++--
 9 files changed, 184 insertions(+), 130 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 40176298a2..0e21cfd83a 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -131,6 +131,20 @@ struct buildsym_compunit
 	xfree (subfile->line_vector);
 	xfree (subfile);
       }
+
+    struct pending *next, *next1;
+
+    for (next = m_file_symbols; next != NULL; next = next1)
+      {
+	next1 = next->next;
+	xfree ((void *) next);
+      }
+
+    for (next = m_global_symbols; next != NULL; next = next1)
+      {
+	next1 = next->next;
+	xfree ((void *) next);
+      }
   }
 
   void set_last_source_file (const char *name)
@@ -251,6 +265,20 @@ struct buildsym_compunit
      are just waiting to be built into a blockvector when finalizing the
      associated symtab.  */
   struct pending_block *m_pending_blocks = nullptr;
+
+  /* Here are the three lists that symbols are put on.  */
+
+  /* static at top level, and types */
+
+  struct pending *m_file_symbols = nullptr;
+
+  /* global functions and variables */
+
+  struct pending *m_global_symbols = nullptr;
+
+  /* everything local to lexical context */
+
+  struct pending *m_local_symbols = nullptr;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -345,22 +373,6 @@ scoped_free_pendings::scoped_free_pendings ()
 
 scoped_free_pendings::~scoped_free_pendings ()
 {
-  struct pending *next, *next1;
-
-  for (next = file_symbols; next != NULL; next = next1)
-    {
-      next1 = next->next;
-      xfree ((void *) next);
-    }
-  file_symbols = NULL;
-
-  for (next = global_symbols; next != NULL; next = next1)
-    {
-      next1 = next->next;
-      xfree ((void *) next);
-    }
-  global_symbols = NULL;
-
   free_buildsym_compunit ();
 }
 
@@ -569,7 +581,8 @@ finish_block (struct symbol *symbol,
 	      const struct dynamic_prop *static_link,
 	      CORE_ADDR start, CORE_ADDR end)
 {
-  return finish_block_internal (symbol, &local_symbols, old_blocks, static_link,
+  return finish_block_internal (symbol, &buildsym_compunit->m_local_symbols,
+				old_blocks, static_link,
 				start, end, 0, 0);
 }
 
@@ -995,12 +1008,8 @@ get_macro_table (void)
 static void
 prepare_for_building ()
 {
-  local_symbols = NULL;
-
   /* These should have been reset either by successful completion of building
      a symtab, or by the scoped_free_pendings destructor.  */
-  gdb_assert (file_symbols == NULL);
-  gdb_assert (global_symbols == NULL);
   gdb_assert (buildsym_compunit == nullptr);
 }
 
@@ -1150,10 +1159,6 @@ watch_main_source_file_lossage (void)
 static void
 reset_symtab_globals (void)
 {
-  local_symbols = NULL;
-  file_symbols = NULL;
-  global_symbols = NULL;
-
   free_buildsym_compunit ();
 }
 
@@ -1241,8 +1246,8 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
 
   if (!required
       && buildsym_compunit->m_pending_blocks == NULL
-      && file_symbols == NULL
-      && global_symbols == NULL
+      && buildsym_compunit->m_file_symbols == NULL
+      && buildsym_compunit->m_global_symbols == NULL
       && buildsym_compunit->m_have_line_numbers == 0
       && buildsym_compunit->m_pending_macros == NULL
       && buildsym_compunit->m_global_using_directives == NULL)
@@ -1253,7 +1258,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
   else
     {
       /* Define the STATIC_BLOCK.  */
-      return finish_block_internal (NULL, &file_symbols, NULL, NULL,
+      return finish_block_internal (NULL, get_file_symbols (), NULL, NULL,
 				    buildsym_compunit->m_last_source_start_addr,
 				    end_addr, 0, expandable);
     }
@@ -1281,7 +1286,7 @@ end_symtab_with_blockvector (struct block *static_block,
   end_addr = BLOCK_END (static_block);
 
   /* Create the GLOBAL_BLOCK and build the blockvector.  */
-  finish_block_internal (NULL, &global_symbols, NULL, NULL,
+  finish_block_internal (NULL, get_global_symbols (), NULL, NULL,
 			 buildsym_compunit->m_last_source_start_addr, end_addr,
 			 1, expandable);
   blockvector = make_blockvector ();
@@ -1551,26 +1556,27 @@ augment_type_symtab (void)
     complaint (&symfile_complaints,
 	       _("Line numbers recorded in a type symtab"));
 
-  if (file_symbols != NULL)
+  if (*get_file_symbols () != NULL)
     {
       struct block *block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
 
       /* First mark any symbols without a specified symtab as belonging
 	 to the primary symtab.  */
-      set_missing_symtab (file_symbols, cust);
+      set_missing_symtab (buildsym_compunit->m_file_symbols, cust);
 
-      dict_add_pending (BLOCK_DICT (block), file_symbols);
+      dict_add_pending (BLOCK_DICT (block), buildsym_compunit->m_file_symbols);
     }
 
-  if (global_symbols != NULL)
+  if (*get_global_symbols () != NULL)
     {
       struct block *block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
 
       /* First mark any symbols without a specified symtab as belonging
 	 to the primary symtab.  */
-      set_missing_symtab (global_symbols, cust);
+      set_missing_symtab (buildsym_compunit->m_global_symbols, cust);
 
-      dict_add_pending (BLOCK_DICT (block), global_symbols);
+      dict_add_pending (BLOCK_DICT (block),
+			buildsym_compunit->m_global_symbols);
     }
 
   reset_symtab_globals ();
@@ -1589,14 +1595,14 @@ push_context (int desc, CORE_ADDR valu)
   struct context_stack *newobj = &buildsym_compunit->m_context_stack.back ();
 
   newobj->depth = desc;
-  newobj->locals = local_symbols;
+  newobj->locals = buildsym_compunit->m_local_symbols;
   newobj->old_blocks = buildsym_compunit->m_pending_blocks;
   newobj->start_addr = valu;
   newobj->local_using_directives
     = buildsym_compunit->m_local_using_directives;
   newobj->name = NULL;
 
-  local_symbols = NULL;
+  buildsym_compunit->m_local_symbols = NULL;
   buildsym_compunit->m_local_using_directives = NULL;
 
   return newobj;
@@ -1735,6 +1741,33 @@ get_current_subfile ()
   return buildsym_compunit->m_current_subfile;
 }
 
+/* See buildsym.h.  */
+
+struct pending **
+get_local_symbols ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return &buildsym_compunit->m_local_symbols;
+}
+
+/* See buildsym.h.  */
+
+struct pending **
+get_file_symbols ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return &buildsym_compunit->m_file_symbols;
+}
+
+/* See buildsym.h.  */
+
+struct pending **
+get_global_symbols ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return &buildsym_compunit->m_global_symbols;
+}
+
 \f
 
 /* Initialize anything that needs initializing when starting to read a
@@ -1744,9 +1777,4 @@ get_current_subfile ()
 void
 buildsym_init ()
 {
-  /* Ensure the scoped_free_pendings destructor was called after
-     the last time.  */
-  gdb_assert (file_symbols == NULL);
-  gdb_assert (global_symbols == NULL);
-  gdb_assert (buildsym_compunit == NULL);
 }
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 969afbc828..71d133e6ad 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -77,20 +77,6 @@ struct pending
     struct symbol *symbol[PENDINGSIZE];
   };
 
-/* Here are the three lists that symbols are put on.  */
-
-/* static at top level, and types */
-
-EXTERN struct pending *file_symbols;
-
-/* global functions and variables */
-
-EXTERN struct pending *global_symbols;
-
-/* everything local to lexical context */
-
-EXTERN struct pending *local_symbols;
-
 /* Stack representing unclosed lexical contexts (that will become
    blocks, eventually).  */
 
@@ -275,6 +261,18 @@ extern int get_context_stack_depth ();
 
 extern struct subfile *get_current_subfile ();
 
+/* Return the local symbol list.  */
+
+extern struct pending **get_local_symbols ();
+
+/* Return the file symbol list.  */
+
+extern struct pending **get_file_symbols ();
+
+/* Return the global symbol list.  */
+
+extern struct pending **get_global_symbols ();
+
 #undef EXTERN
 
 #endif /* defined (BUILDSYM_H) */
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 71b6ed9995..3bb6639914 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1177,7 +1177,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 			     symnum);
 		  break;
 		}
-	      if (local_symbols && !outermost_context_p ())
+	      if (*get_local_symbols () && !outermost_context_p ())
 		{
 		  tmpaddr =
 		    cs->c_value + ANOFFSET (objfile->section_offsets,
@@ -1187,7 +1187,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 				newobj->start_addr, tmpaddr);
 		}
 	      /* Now pop locals of block just finished.  */
-	      local_symbols = newobj->locals;
+	      *get_local_symbols () = newobj->locals;
 	    }
 	  break;
 
@@ -1654,10 +1654,10 @@ process_coff_symbol (struct coff_symbol *cs,
       SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
       if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
 	  || cs->c_sclass == C_THUMBSTATFUNC)
-	add_symbol_to_list (sym, &file_symbols);
+	add_symbol_to_list (sym, get_file_symbols ());
       else if (cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT
 	       || cs->c_sclass == C_THUMBEXTFUNC)
-	add_symbol_to_list (sym, &global_symbols);
+	add_symbol_to_list (sym, get_global_symbols ());
     }
   else
     {
@@ -1669,7 +1669,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
 	case C_AUTO:
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
-	  add_symbol_to_list (sym, &local_symbols);
+	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
 
 	case C_THUMBEXT:
@@ -1679,7 +1679,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	  SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value;
 	  SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets,
 						  SECT_OFF_TEXT (objfile));
-	  add_symbol_to_list (sym, &global_symbols);
+	  add_symbol_to_list (sym, get_global_symbols ());
 	  break;
 
 	case C_THUMBSTAT:
@@ -1692,12 +1692,12 @@ process_coff_symbol (struct coff_symbol *cs,
 	  if (within_function)
 	    {
 	      /* Static symbol of local scope.  */
-	      add_symbol_to_list (sym, &local_symbols);
+	      add_symbol_to_list (sym, get_local_symbols ());
 	    }
 	  else
 	    {
 	      /* Static symbol at top level of file.  */
-	      add_symbol_to_list (sym, &file_symbols);
+	      add_symbol_to_list (sym, get_file_symbols ());
 	    }
 	  break;
 
@@ -1707,7 +1707,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	case C_REG:
 	  SYMBOL_ACLASS_INDEX (sym) = coff_register_index;
 	  SYMBOL_VALUE (sym) = cs->c_value;
-	  add_symbol_to_list (sym, &local_symbols);
+	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
 
 	case C_THUMBLABEL:
@@ -1717,14 +1717,14 @@ process_coff_symbol (struct coff_symbol *cs,
 	case C_ARG:
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_ARG;
 	  SYMBOL_IS_ARGUMENT (sym) = 1;
-	  add_symbol_to_list (sym, &local_symbols);
+	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
 
 	case C_REGPARM:
 	  SYMBOL_ACLASS_INDEX (sym) = coff_register_index;
 	  SYMBOL_IS_ARGUMENT (sym) = 1;
 	  SYMBOL_VALUE (sym) = cs->c_value;
-	  add_symbol_to_list (sym, &local_symbols);
+	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
 
 	case C_TPDEF:
@@ -1778,7 +1778,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	      SYMBOL_VALUE_CHAIN (sym) = opaque_type_chain[i];
 	      opaque_type_chain[i] = sym;
 	    }
-	  add_symbol_to_list (sym, &file_symbols);
+	  add_symbol_to_list (sym, get_file_symbols ());
 	  break;
 
 	case C_STRTAG:
@@ -1797,7 +1797,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	      TYPE_TAG_NAME (SYMBOL_TYPE (sym)) =
 		concat (SYMBOL_LINKAGE_NAME (sym), (char *)NULL);
 
-	  add_symbol_to_list (sym, &file_symbols);
+	  add_symbol_to_list (sym, get_file_symbols ());
 	  break;
 
 	default:
@@ -2175,9 +2175,9 @@ coff_read_enum_type (int index, int length, int lastsym,
 
   type = coff_alloc_type (index);
   if (within_function)
-    symlist = &local_symbols;
+    symlist = get_local_symbols ();
   else
-    symlist = &file_symbols;
+    symlist = get_file_symbols ();
   osyms = *symlist;
   o_nsyms = osyms ? osyms->nsyms : 0;
 
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index b6a44e245e..989ce77be2 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2636,7 +2636,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
       if (desc != newobj->depth)
 	lbrac_mismatch_complaint (symnum);
 
-      if (local_symbols != NULL)
+      if (*get_local_symbols () != NULL)
 	{
 	  /* GCC development snapshots from March to December of
 	     2000 would output N_LSYM entries after N_LBRAC
@@ -2646,7 +2646,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 		     _("misplaced N_LBRAC entry; discarding local "
 		       "symbols which have no enclosing block"));
 	}
-      local_symbols = newobj->locals;
+      *get_local_symbols () = newobj->locals;
 
       if (get_context_stack_depth () > 1)
 	{
@@ -2656,7 +2656,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	     for them (but don't bother if the block contains no
 	     symbols.  Should we complain on blocks without symbols?
 	     I can't think of any useful purpose for them).  */
-	  if (local_symbols != NULL)
+	  if (*get_local_symbols () != NULL)
 	    {
 	      /* Muzzle a compiler bug that makes end < start.
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f7cca01445..b73f13bb19 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9739,7 +9739,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
   struct pending *list;
   int i;
 
-  for (list = global_symbols; list != NULL; list = list->next)
+  for (list = *get_global_symbols (); list != NULL; list = list->next)
     {
       for (i = 0; i < list->nsyms; ++i)
 	{
@@ -9795,7 +9795,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
       SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
       SYMBOL_TYPE (sym) = type;
 
-      add_symbol_to_list (sym, &global_symbols);
+      add_symbol_to_list (sym, get_global_symbols ());
 
       xfree (package_name);
     }
@@ -13677,7 +13677,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
       attr_to_dynamic_prop (attr, die, cu, newobj->static_link);
     }
 
-  cu->list_in_scope = &local_symbols;
+  cu->list_in_scope = get_local_symbols ();
 
   if (die->child != NULL)
     {
@@ -13762,13 +13762,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
      a function declares a class that has methods).  This means that
      when we finish processing a function scope, we may need to go
      back to building a containing block's symbol lists.  */
-  local_symbols = newobj->locals;
+  *get_local_symbols () = newobj->locals;
   set_local_using_directives (newobj->local_using_directives);
 
   /* If we've finished processing a top-level function, subsequent
      symbols go in the file symbol list.  */
   if (outermost_context_p ())
-    cu->list_in_scope = &file_symbols;
+    cu->list_in_scope = get_file_symbols ();
 }
 
 /* Process all the DIES contained within a lexical block scope.  Start
@@ -13821,7 +13821,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
   inherit_abstract_dies (die, cu);
   newobj = pop_context ();
 
-  if (local_symbols != NULL || (*get_local_using_directives ()) != NULL)
+  if (*get_local_symbols () != NULL || (*get_local_using_directives ()) != NULL)
     {
       struct block *block
         = finish_block (0, newobj->old_blocks, NULL,
@@ -13839,7 +13839,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
          to do.  */
       dwarf2_record_block_ranges (die, block, baseaddr, cu);
     }
-  local_symbols = newobj->locals;
+  *get_local_symbols () = newobj->locals;
   set_local_using_directives (newobj->local_using_directives);
 }
 
@@ -21328,7 +21328,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
                  access them globally.  For instance, we want to be able
                  to break on a nested subprogram without having to
                  specify the context.  */
-	      list_to_add = &global_symbols;
+	      list_to_add = get_global_symbols ();
 	    }
 	  else
 	    {
@@ -21371,7 +21371,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	      if (!suppress_add)
 		{
 		  if (attr2 && (DW_UNSND (attr2) != 0))
-		    list_to_add = &global_symbols;
+		    list_to_add = get_global_symbols ();
 		  else
 		    list_to_add = cu->list_in_scope;
 		}
@@ -21416,8 +21416,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 
 		  /* A variable with DW_AT_external is never static,
 		     but it may be block-scoped.  */
-		  list_to_add = (cu->list_in_scope == &file_symbols
-				 ? &global_symbols : cu->list_in_scope);
+		  list_to_add = (cu->list_in_scope == get_file_symbols ()
+				 ? get_global_symbols () : cu->list_in_scope);
 		}
 	      else
 		list_to_add = cu->list_in_scope;
@@ -21447,8 +21447,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 		{
 		  /* A variable with DW_AT_external is never static, but it
 		     may be block-scoped.  */
-		  list_to_add = (cu->list_in_scope == &file_symbols
-				 ? &global_symbols : cu->list_in_scope);
+		  list_to_add = (cu->list_in_scope == get_file_symbols ()
+				 ? get_global_symbols () : cu->list_in_scope);
 
 		  SYMBOL_ACLASS_INDEX (sym) = LOC_UNRESOLVED;
 		}
@@ -21513,9 +21513,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 
 	    if (!suppress_add)
 	      {
-		list_to_add = (cu->list_in_scope == &file_symbols
+		list_to_add = (cu->list_in_scope == get_file_symbols ()
 			       && cu->language == language_cplus
-			       ? &global_symbols : cu->list_in_scope);
+			       ? get_global_symbols () : cu->list_in_scope);
 
 		/* The semantics of C++ state that "struct foo {
 		   ... }" also defines a typedef for "foo".  */
@@ -21554,20 +21554,20 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	    /* NOTE: carlton/2003-11-10: See comment above in the
 	       DW_TAG_class_type, etc. block.  */
 
-	    list_to_add = (cu->list_in_scope == &file_symbols
+	    list_to_add = (cu->list_in_scope == get_file_symbols ()
 			   && cu->language == language_cplus
-			   ? &global_symbols : cu->list_in_scope);
+			   ? get_global_symbols () : cu->list_in_scope);
 	  }
 	  break;
 	case DW_TAG_imported_declaration:
 	case DW_TAG_namespace:
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
-	  list_to_add = &global_symbols;
+	  list_to_add = get_global_symbols ();
 	  break;
 	case DW_TAG_module:
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
 	  SYMBOL_DOMAIN (sym) = MODULE_DOMAIN;
-	  list_to_add = &global_symbols;
+	  list_to_add = get_global_symbols ();
 	  break;
 	case DW_TAG_common_block:
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_COMMON_BLOCK;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 704c064fd8..1045426c67 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4059,7 +4059,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
 		  SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_void;
 		  SYMBOL_VALUE_BYTES (s) = (gdb_byte *) e;
 		  e->pdr.framereg = -1;
-		  add_symbol_to_list (s, &local_symbols);
+		  add_symbol_to_list (s, get_local_symbols ());
 		}
 	    }
 	  else if (sh.st == stLabel)
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 8c90241165..ebb844d2c5 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -434,7 +434,7 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
 		{
 		  SYMBOL_TYPE (sym) = read_type (&pp, objfile);
 		}
-	      add_symbol_to_list (sym, &global_symbols);
+	      add_symbol_to_list (sym, get_global_symbols ());
 	    }
 	  else
 	    {
@@ -791,7 +791,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
 	  SYMBOL_TYPE (sym) = error_type (&p, objfile);
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-	  add_symbol_to_list (sym, &file_symbols);
+	  add_symbol_to_list (sym, get_file_symbols ());
 	  return sym;
 	}
       ++p;
@@ -850,7 +850,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 		SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
 		SYMBOL_TYPE (sym) = error_type (&p, objfile);
 		SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-		add_symbol_to_list (sym, &file_symbols);
+		add_symbol_to_list (sym, get_file_symbols ());
 		return sym;
 	      }
 
@@ -875,7 +875,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 		SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
 		SYMBOL_TYPE (sym) = error_type (&p, objfile);
 		SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-		add_symbol_to_list (sym, &file_symbols);
+		add_symbol_to_list (sym, get_file_symbols ());
 		return sym;
 	      }
 
@@ -930,7 +930,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  }
 	}
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &file_symbols);
+      add_symbol_to_list (sym, get_file_symbols ());
       return sym;
 
     case 'C':
@@ -939,7 +939,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_VALUE_ADDRESS (sym) = valu;
-      add_symbol_to_list (sym, &local_symbols);
+      add_symbol_to_list (sym, get_local_symbols ());
       break;
 
     case 'f':
@@ -947,7 +947,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &file_symbols);
+      add_symbol_to_list (sym, get_file_symbols ());
       /* fall into process_function_types.  */
 
     process_function_types:
@@ -1018,7 +1018,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &global_symbols);
+      add_symbol_to_list (sym, get_global_symbols ());
       goto process_function_types;
 
     case 'G':
@@ -1039,7 +1039,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
 	  global_sym_chain[i] = sym;
 	}
-      add_symbol_to_list (sym, &global_symbols);
+      add_symbol_to_list (sym, get_global_symbols ());
       break;
 
       /* This case is faked by a conditional above,
@@ -1051,7 +1051,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &local_symbols);
+      add_symbol_to_list (sym, get_local_symbols ());
       break;
 
     case 'p':
@@ -1072,7 +1072,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_IS_ARGUMENT (sym) = 1;
-      add_symbol_to_list (sym, &local_symbols);
+      add_symbol_to_list (sym, get_local_symbols ());
 
       if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_BIG)
 	{
@@ -1121,7 +1121,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &local_symbols);
+      add_symbol_to_list (sym, get_local_symbols ());
       break;
 
     case 'r':
@@ -1152,6 +1152,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	     but this case is considered pathological and causes a warning
 	     from a decent compiler.  */
 
+	  struct pending *local_symbols = *get_local_symbols ();
 	  if (local_symbols
 	      && local_symbols->nsyms > 0
 	      && gdbarch_stabs_argument_has_addr (gdbarch, SYMBOL_TYPE (sym)))
@@ -1173,10 +1174,10 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 		  break;
 		}
 	    }
-	  add_symbol_to_list (sym, &local_symbols);
+	  add_symbol_to_list (sym, get_local_symbols ());
 	}
       else
-	add_symbol_to_list (sym, &file_symbols);
+	add_symbol_to_list (sym, get_file_symbols ());
       break;
 
     case 'S':
@@ -1203,7 +1204,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	    }
 	}
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &file_symbols);
+      add_symbol_to_list (sym, get_file_symbols ());
       break;
 
     case 't':
@@ -1307,7 +1308,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	    TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_LINKAGE_NAME (sym);
 	}
 
-      add_symbol_to_list (sym, &file_symbols);
+      add_symbol_to_list (sym, get_file_symbols ());
 
       if (synonym)
         {
@@ -1323,7 +1324,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	      = obconcat (&objfile->objfile_obstack,
 			  SYMBOL_LINKAGE_NAME (sym),
 			  (char *) NULL);
-          add_symbol_to_list (struct_sym, &file_symbols);
+          add_symbol_to_list (struct_sym, get_file_symbols ());
         }
       
       break;
@@ -1351,7 +1352,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  = obconcat (&objfile->objfile_obstack,
 		      SYMBOL_LINKAGE_NAME (sym),
 		      (char *) NULL);
-      add_symbol_to_list (sym, &file_symbols);
+      add_symbol_to_list (sym, get_file_symbols ());
 
       if (synonym)
 	{
@@ -1367,7 +1368,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	      = obconcat (&objfile->objfile_obstack,
 			  SYMBOL_LINKAGE_NAME (sym),
 			  (char *) NULL);
-	  add_symbol_to_list (typedef_sym, &file_symbols);
+	  add_symbol_to_list (typedef_sym, get_file_symbols ());
 	}
       break;
 
@@ -1395,7 +1396,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	    }
 	}
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-	add_symbol_to_list (sym, &local_symbols);
+	add_symbol_to_list (sym, get_local_symbols ());
       break;
 
     case 'v':
@@ -1405,7 +1406,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &local_symbols);
+      add_symbol_to_list (sym, get_local_symbols ());
       break;
 
     case 'a':
@@ -1415,7 +1416,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &local_symbols);
+      add_symbol_to_list (sym, get_local_symbols ());
       break;
 
     case 'X':
@@ -1427,7 +1428,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &local_symbols);
+      add_symbol_to_list (sym, get_local_symbols ());
       break;
 
     default:
@@ -1435,7 +1436,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
       SYMBOL_VALUE (sym) = 0;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      add_symbol_to_list (sym, &file_symbols);
+      add_symbol_to_list (sym, get_file_symbols ());
       break;
     }
 
@@ -1679,7 +1680,7 @@ again:
            type, rather than allocating a new one.  This saves some
            memory.  */
 
-	for (ppt = file_symbols; ppt; ppt = ppt->next)
+	for (ppt = *get_file_symbols (); ppt; ppt = ppt->next)
 	  for (i = 0; i < ppt->nsyms; i++)
 	    {
 	      struct symbol *sym = ppt->symbol[i];
@@ -3663,10 +3664,10 @@ read_enum_type (const char **pp, struct type *type,
      to be file-scope, between N_FN entries, using N_LSYM.  What's a mother
      to do?  For now, force all enum values to file scope.  */
   if (within_function)
-    symlist = &local_symbols;
+    symlist = get_local_symbols ();
   else
 #endif
-    symlist = &file_symbols;
+    symlist = get_file_symbols ();
   osyms = *symlist;
   o_nsyms = osyms ? osyms->nsyms : 0;
 
@@ -4339,8 +4340,8 @@ common_block_start (const char *name, struct objfile *objfile)
       complaint (&symfile_complaints,
 		 _("Invalid symbol data: common block within common block"));
     }
-  common_block = local_symbols;
-  common_block_i = local_symbols ? local_symbols->nsyms : 0;
+  common_block = *get_local_symbols ();
+  common_block_i = common_block ? common_block->nsyms : 0;
   common_block_name = (char *) obstack_copy0 (&objfile->objfile_obstack, name,
 					      strlen (name));
 }
@@ -4375,7 +4376,7 @@ common_block_end (struct objfile *objfile)
   /* Now we copy all the symbols which have been defined since the BCOMM.  */
 
   /* Copy all the struct pendings before common_block.  */
-  for (next = local_symbols;
+  for (next = *get_local_symbols ();
        next != NULL && next != common_block;
        next = next->next)
     {
@@ -4568,7 +4569,7 @@ cleanup_undefined_types_1 (void)
 		    complaint (&symfile_complaints, _("need a type name"));
 		    break;
 		  }
-		for (ppt = file_symbols; ppt; ppt = ppt->next)
+		for (ppt = *get_file_symbols (); ppt; ppt = ppt->next)
 		  {
 		    for (i = 0; i < ppt->nsyms; i++)
 		      {
@@ -4808,7 +4809,7 @@ finish_global_stabs (struct objfile *objfile)
 {
   if (global_stabs)
     {
-      patch_block_stabs (global_symbols, global_stabs, objfile);
+      patch_block_stabs (*get_global_symbols (), global_stabs, objfile);
       xfree (global_stabs);
       global_stabs = NULL;
     }
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 73e0638412..4ccc5bf7fc 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1501,7 +1501,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 		  eb_complaint (cs->c_symnum);
 		  break;
 		}
-	      if (local_symbols && !outermost_context_p ())
+	      if (*get_local_symbols () && !outermost_context_p ())
 		{
 		  /* Make a block for the local symbols within.  */
 		  finish_block (newobj->name,
@@ -1511,7 +1511,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 				 + ANOFFSET (objfile->section_offsets,
 					     SECT_OFF_TEXT (objfile))));
 		}
-	      local_symbols = newobj->locals;
+	      *get_local_symbols () = newobj->locals;
 	    }
 	  break;
 
@@ -1599,9 +1599,9 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
       SYMBOL_DUP (sym, sym2);
 
       if (cs->c_sclass == C_EXT || C_WEAKEXT)
-	add_symbol_to_list (sym2, &global_symbols);
+	add_symbol_to_list (sym2, get_global_symbols ());
       else if (cs->c_sclass == C_HIDEXT || cs->c_sclass == C_STAT)
-	add_symbol_to_list (sym2, &file_symbols);
+	add_symbol_to_list (sym2, get_file_symbols ());
     }
   else
     {
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 02/42] Change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
  2018-05-23  4:59 ` [RFA 17/42] Move the subfile stack to buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-07  2:34   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 04/42] Move last_source file to buildsym_compunit Tom Tromey
                   ` (41 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr.
This is just a small cleanup to remove some manual memory management.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (~buildsym_compunit): Update.
	(struct buildsym_compunit) <comp_unit>: Now a unique_xmalloc_ptr.
	(start_subfile, patch_subfile_names)
	(end_symtab_with_blockvector): Update.
---
 gdb/ChangeLog  |  7 +++++++
 gdb/buildsym.c | 11 +++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 9863e4ea1e..b747a082b5 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -126,7 +126,6 @@ struct buildsym_compunit
 	xfree (subfile->line_vector);
 	xfree (subfile);
       }
-    xfree (comp_dir);
   }
 
   /* The objfile we're reading debug info from.  */
@@ -142,7 +141,7 @@ struct buildsym_compunit
   struct subfile *main_subfile = nullptr;
 
   /* E.g., DW_AT_comp_dir if DWARF.  Space for this is malloc'd.  */
-  char *comp_dir;
+  gdb::unique_xmalloc_ptr<char> comp_dir;
 
   /* Space for this is not malloc'd, and is assumed to have at least
      the same lifetime as objfile.  */
@@ -703,7 +702,7 @@ start_subfile (const char *name)
 
   gdb_assert (buildsym_compunit != NULL);
 
-  subfile_dirname = buildsym_compunit->comp_dir;
+  subfile_dirname = buildsym_compunit->comp_dir.get ();
 
   /* See if this subfile is already registered.  */
 
@@ -824,7 +823,7 @@ patch_subfile_names (struct subfile *subfile, const char *name)
       && subfile->name != NULL
       && IS_DIR_SEPARATOR (subfile->name[strlen (subfile->name) - 1]))
     {
-      buildsym_compunit->comp_dir = subfile->name;
+      buildsym_compunit->comp_dir.reset (subfile->name);
       subfile->name = xstrdup (name);
       set_last_source_file (name);
 
@@ -1410,10 +1409,10 @@ end_symtab_with_blockvector (struct block *static_block,
   if (buildsym_compunit->comp_dir != NULL)
     {
       /* Reallocate the dirname on the symbol obstack.  */
+      const char *comp_dir = buildsym_compunit->comp_dir.get ();
       COMPUNIT_DIRNAME (cu)
 	= (const char *) obstack_copy0 (&objfile->objfile_obstack,
-					buildsym_compunit->comp_dir,
-					strlen (buildsym_compunit->comp_dir));
+					comp_dir, strlen (comp_dir));
     }
 
   /* Save the debug format string (if any) in the symtab.  */
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 00/42] Remove globals from buildsym
@ 2018-05-23  4:59 Tom Tromey
  2018-05-23  4:59 ` [RFA 17/42] Move the subfile stack to buildsym_compunit Tom Tromey
                   ` (43 more replies)
  0 siblings, 44 replies; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches

I've long wanted to remove the globals from buildsym and generally
clean it up.  I've finally tackled this project, and this series is
the result.

I'm afraid it is a bit on the long side.  However, I tried to make
each patch relativey small.  Most of them should be easy to review --
and a few are trivial.

Also, I simultaneously wrote this series and learned about some the
workings of buildsym.  So, there are some cases where something is
done -- say, an assertion added or a variable made static -- only to
be un-done later in the series.  Reordering seemed generally painful
so I have left it as is.

The general idea behind the patches is to move each global variable
(or related set of global variables) into the existing
buildsym_compunit structure.  Along the way, some minor cleanups are
done, for example moving stabs-specific things to stabsread.

Once all of the state is in buildsym_compunit, it is put into
buildsym.h for use by symbol readers.  Here, I've converted the DWARF
reader to use the new-style API, leaving the other readers alone.
(The other readers continue to rely on a global, but now only one.)

I haven't tried much to clean up buildsym itself.  The API is just as
unwieldy as ever -- it just no longer has global state.  I have,
however, replaced some data structures with self-managing ones.

There are some holes with the series that you may wish to consider.

* Perhaps some more comments could be added.

* There are still some stabs-specific hacks in buildsym.c that I have
  not attempted to remove.

* There are some remaining calls to set_last_source_file (NULL) that
  could perhaps be removed as unnecessary.  I did not check.

Regression tested by the buildbot.  I also did a reasonable, but not
exhaustive, amount of testing here.  I've at least smoke-tested the
stabs reader by running some tests with --target_board=stabs.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 16/42] Use gdb_assert in two places in buildsym.c
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (16 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 09/42] Make context_stack_size static in buildsym.c Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:55   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 19/42] Move the using directives to buildsym_compunit Tom Tromey
                   ` (25 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes buildsym.c to use gdb_assert rather than internal_error
in a couple of spots.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (push_subfile): Use gdb_assert.
	(pop_subfile): Use gdb_assert.
---
 gdb/ChangeLog  |  5 +++++
 gdb/buildsym.c | 12 ++----------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 4744d510c3..4823fb383d 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -896,11 +896,7 @@ push_subfile (void)
 
   tem->next = subfile_stack;
   subfile_stack = tem;
-  if (current_subfile == NULL || current_subfile->name == NULL)
-    {
-      internal_error (__FILE__, __LINE__, 
-		      _("failed internal consistency check"));
-    }
+  gdb_assert (! (current_subfile == NULL || current_subfile->name == NULL));
   tem->name = current_subfile->name;
 }
 
@@ -910,11 +906,7 @@ pop_subfile (void)
   char *name;
   struct subfile_stack *link = subfile_stack;
 
-  if (link == NULL)
-    {
-      internal_error (__FILE__, __LINE__,
-		      _("failed internal consistency check"));
-    }
+  gdb_assert (link != NULL);
   name = link->name;
   subfile_stack = link->next;
   xfree ((void *) link);
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 28/42] Set list_in_scope later in DWARF reader
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (20 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 10/42] Move some code from buildsym to stabsread Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-06 18:11   ` Keith Seitz
  2018-05-23  4:59 ` [RFA 07/42] Move last_source_start_addr to buildsym_compunit Tom Tromey
                   ` (21 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Currently the DWARF reader sets the list_in_scope member of the CU
when first starting to process symbols.  Future changes will make this
assert -- code will not be able to refer to these lists until after
start_symtab has been called.  This patch prepares for the problem by
arranging to initialize list_in_scope in dwarf2_start_symtab.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (process_full_comp_unit): Do not set list_in_scope.
	(process_full_type_unit): Likewise.
	(dwarf2_start_symtab): Set list_in_scope.
---
 gdb/ChangeLog    | 6 ++++++
 gdb/dwarf2read.c | 6 ++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 3cc15ab645..f7cca01445 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10281,8 +10281,6 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
   /* Clear the list here in case something was left over.  */
   cu->method_list.clear ();
 
-  cu->list_in_scope = &file_symbols;
-
   cu->language = pretend_language;
   cu->language_defn = language_def (cu->language);
 
@@ -10386,8 +10384,6 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
   /* Clear the list here in case something was left over.  */
   cu->method_list.clear ();
 
-  cu->list_in_scope = &file_symbols;
-
   cu->language = pretend_language;
   cu->language_defn = language_def (cu->language);
 
@@ -21138,6 +21134,8 @@ dwarf2_start_symtab (struct dwarf2_cu *cu,
     = start_symtab (cu->per_cu->dwarf2_per_objfile->objfile, name, comp_dir,
 		    low_pc, cu->language);
 
+  cu->list_in_scope = get_file_symbols ();
+
   record_debugformat ("DWARF 2");
   record_producer (cu->producer);
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 27/42] Do not look at file symbols when reading psymtabs
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (4 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 22/42] Move current_subfile to buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-10  3:19   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 25/42] Remove the "listhead" argument from finish_block Tom Tromey
                   ` (37 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The DWARF reader was setting the list_in_scope member when reading
partial symbols.  however, this member is only useful when reading
full symbols.  Future patches will make this assert, so remove these
unneeded initializations.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (process_psymtab_comp_unit_reader)
	(build_type_psymtabs_reader): Do not set list_in_scope.
---
 gdb/ChangeLog    | 5 +++++
 gdb/dwarf2read.c | 3 ---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index ffea27c064..3cc15ab645 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7929,8 +7929,6 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
 
   prepare_one_comp_unit (cu, comp_unit_die, info->pretend_language);
 
-  cu->list_in_scope = &file_symbols;
-
   /* Allocate a new partial symbol table structure.  */
   filename = dwarf2_string_attr (comp_unit_die, DW_AT_name, cu);
   if (filename == NULL)
@@ -8098,7 +8096,6 @@ build_type_psymtabs_reader (const struct die_reader_specs *reader,
   VEC_safe_push (sig_type_ptr, tu_group->tus, sig_type);
 
   prepare_one_comp_unit (cu, type_unit_die, language_minimal);
-  cu->list_in_scope = &file_symbols;
   pst = create_partial_symtab (per_cu, "");
   pst->anonymous = 1;
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 05/42] Move pending_macros to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (8 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 29/42] Move the symbol lists to buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-07 15:41   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 26/42] Remove free_pendings Tom Tromey
                   ` (33 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the pending_macros global into buildsym_compunit.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (~buildsym_compunit): Free the macro table.
	(struct buildsym_compunit) <get_macro_table, release_macros>: New
	methods.
	<m_pending_macros>: New member.
	(pending_macros): Remove.
	(~scoped_free_pendings, get_macro_table, prepare_for_building)
	(reset_symtab_globals, end_symtab_get_static_block)
	(end_symtab_with_blockvector, augment_type_symtab)
	(buildsym_init): Update.
---
 gdb/ChangeLog  | 12 ++++++++++++
 gdb/buildsym.c | 55 +++++++++++++++++++++++++++----------------------------
 2 files changed, 39 insertions(+), 28 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 5dd6f7e343..c3961254da 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -118,6 +118,9 @@ struct buildsym_compunit
   {
     struct subfile *subfile, *nextsub;
 
+    if (m_pending_macros != nullptr)
+      free_macro_table (m_pending_macros);
+
     for (subfile = subfiles;
 	 subfile != NULL;
 	 subfile = nextsub)
@@ -135,6 +138,22 @@ struct buildsym_compunit
     m_last_source_file.reset (new_name);
   }
 
+  struct macro_table *get_macro_table ()
+  {
+    if (m_pending_macros == nullptr)
+      m_pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
+					  objfile->per_bfd->macro_cache,
+					  compunit_symtab);
+    return m_pending_macros;
+  }
+
+  struct macro_table *release_macros ()
+  {
+    struct macro_table *result = m_pending_macros;
+    m_pending_macros = nullptr;
+    return result;
+  }
+
   /* The objfile we're reading debug info from.  */
   struct objfile *objfile;
 
@@ -169,6 +188,10 @@ struct buildsym_compunit
 
   /* Language of this compunit_symtab.  */
   enum language language;
+
+  /* The macro table for the compilation unit whose symbols we're
+     currently reading.  */
+  struct macro_table *m_pending_macros = nullptr;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -229,10 +252,6 @@ struct subfile_stack
 
 static struct subfile_stack *subfile_stack;
 
-/* The macro table for the compilation unit whose symbols we're
-   currently reading.  */
-static struct macro_table *pending_macros;
-
 static void free_buildsym_compunit (void);
 
 static int compare_line_numbers (const void *ln1p, const void *ln2p);
@@ -342,10 +361,6 @@ scoped_free_pendings::~scoped_free_pendings ()
     }
   global_symbols = NULL;
 
-  if (pending_macros)
-    free_macro_table (pending_macros);
-  pending_macros = NULL;
-
   if (pending_addrmap)
     obstack_free (&pending_addrmap_obstack, NULL);
   pending_addrmap = NULL;
@@ -999,17 +1014,7 @@ get_macro_table (void)
   struct objfile *objfile;
 
   gdb_assert (buildsym_compunit != NULL);
-
-  objfile = buildsym_compunit->objfile;
-
-  if (! pending_macros)
-    {
-      pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
-					objfile->per_bfd->macro_cache,
-					buildsym_compunit->compunit_symtab);
-    }
-
-  return pending_macros;
+  return buildsym_compunit->get_macro_table ();
 }
 \f
 /* Init state to prepare for building a symtab.
@@ -1034,7 +1039,6 @@ prepare_for_building (CORE_ADDR start_addr)
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
   gdb_assert (global_using_directives == NULL);
-  gdb_assert (pending_macros == NULL);
   gdb_assert (pending_addrmap == NULL);
   gdb_assert (current_subfile == NULL);
   gdb_assert (buildsym_compunit == nullptr);
@@ -1191,10 +1195,6 @@ reset_symtab_globals (void)
   global_symbols = NULL;
   global_using_directives = NULL;
 
-  /* We don't free pending_macros here because if the symtab was successfully
-     built then ownership was transferred to the symtab.  */
-  pending_macros = NULL;
-
   if (pending_addrmap)
     obstack_free (&pending_addrmap_obstack, NULL);
   pending_addrmap = NULL;
@@ -1289,7 +1289,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
       && file_symbols == NULL
       && global_symbols == NULL
       && have_line_numbers == 0
-      && pending_macros == NULL
+      && buildsym_compunit->m_pending_macros == NULL
       && global_using_directives == NULL)
     {
       /* Ignore symtabs that have no functions with real debugging info.  */
@@ -1442,7 +1442,7 @@ end_symtab_with_blockvector (struct block *static_block,
 
   COMPUNIT_BLOCK_LINE_SECTION (cu) = section;
 
-  COMPUNIT_MACRO_TABLE (cu) = pending_macros;
+  COMPUNIT_MACRO_TABLE (cu) = buildsym_compunit->release_macros ();
 
   /* Default any symbols without a specified symtab to the primary symtab.  */
   {
@@ -1593,7 +1593,7 @@ augment_type_symtab (void)
     }
   if (pending_blocks != NULL)
     complaint (&symfile_complaints, _("Blocks in a type symtab"));
-  if (pending_macros != NULL)
+  if (buildsym_compunit->m_pending_macros != NULL)
     complaint (&symfile_complaints, _("Macro in a type symtab"));
   if (have_line_numbers)
     complaint (&symfile_complaints,
@@ -1765,7 +1765,6 @@ buildsym_init (void)
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
   gdb_assert (global_using_directives == NULL);
-  gdb_assert (pending_macros == NULL);
   gdb_assert (pending_addrmap == NULL);
   gdb_assert (buildsym_compunit == NULL);
 }
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 19/42] Move the using directives to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (17 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 16/42] Use gdb_assert in two places " Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-05 20:14   ` Keith Seitz
  2018-05-23  4:59 ` [RFA 20/42] Use outermost_context_p in more places Tom Tromey
                   ` (24 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the globals local_using_directives and
global_using_directives to be members of buildsym_compunit, and adds
the necessary accessors.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (using_directives, read_func_scope)
	(read_lexical_block_scope): Update.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
	* buildsym.h (local_using_directives, global_using_directives):
	Don't declare.
	(get_local_using_directives, set_local_using_directives)
	(get_global_using_directives): Declare.
	* buildsym.c (struct buildsym_compunit) <m_local_using_directives,
	m_global_using_directives>: New members.
	(finish_block_internal, prepare_for_building)
	(reset_symtab_globals, end_symtab_get_static_block)
	(push_context): Update.
	(get_local_using_directives, set_local_using_directives)
	(get_global_using_directives): New functions.
	(buildsym_init): Update.
---
 gdb/ChangeLog      | 18 ++++++++++++++++++
 gdb/buildsym.c     | 55 ++++++++++++++++++++++++++++++++++++++++++------------
 gdb/buildsym.h     | 20 ++++++++++++--------
 gdb/cp-namespace.c |  2 +-
 gdb/dwarf2read.c   | 10 +++++-----
 5 files changed, 79 insertions(+), 26 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 5d3d1f2942..4e3ca5e4b1 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -205,6 +205,14 @@ struct buildsym_compunit
 
   /* Stack of subfile names.  */
   std::vector<const char *> m_subfile_stack;
+
+  /* "using" directives local to lexical context.  */
+
+  struct using_direct *m_local_using_directives = nullptr;
+
+  /* global "using" directives.  */
+
+  struct using_direct *m_global_using_directives = nullptr;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -578,13 +586,13 @@ finish_block_internal (struct symbol *symbol,
 
   block_set_using (block,
 		   (is_global
-		    ? global_using_directives
-		    : local_using_directives),
+		    ? buildsym_compunit->m_global_using_directives
+		    : buildsym_compunit->m_local_using_directives),
 		   &objfile->objfile_obstack);
   if (is_global)
-    global_using_directives = NULL;
+    buildsym_compunit->m_global_using_directives = NULL;
   else
-    local_using_directives = NULL;
+    buildsym_compunit->m_local_using_directives = NULL;
 
   record_pending_block (objfile, block, opblock);
 
@@ -1023,7 +1031,6 @@ static void
 prepare_for_building ()
 {
   local_symbols = NULL;
-  local_using_directives = NULL;
 
   context_stack_depth = 0;
 
@@ -1031,7 +1038,6 @@ prepare_for_building ()
      a symtab, or by the scoped_free_pendings destructor.  */
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
-  gdb_assert (global_using_directives == NULL);
   gdb_assert (pending_addrmap == NULL);
   gdb_assert (current_subfile == NULL);
   gdb_assert (buildsym_compunit == nullptr);
@@ -1184,10 +1190,8 @@ static void
 reset_symtab_globals (void)
 {
   local_symbols = NULL;
-  local_using_directives = NULL;
   file_symbols = NULL;
   global_symbols = NULL;
-  global_using_directives = NULL;
 
   if (pending_addrmap)
     obstack_free (&pending_addrmap_obstack, NULL);
@@ -1284,7 +1288,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
       && global_symbols == NULL
       && buildsym_compunit->m_have_line_numbers == 0
       && buildsym_compunit->m_pending_macros == NULL
-      && global_using_directives == NULL)
+      && buildsym_compunit->m_global_using_directives == NULL)
     {
       /* Ignore symtabs that have no functions with real debugging info.  */
       return NULL;
@@ -1640,11 +1644,12 @@ push_context (int desc, CORE_ADDR valu)
   newobj->locals = local_symbols;
   newobj->old_blocks = pending_blocks;
   newobj->start_addr = valu;
-  newobj->local_using_directives = local_using_directives;
+  newobj->local_using_directives
+    = buildsym_compunit->m_local_using_directives;
   newobj->name = NULL;
 
   local_symbols = NULL;
-  local_using_directives = NULL;
+  buildsym_compunit->m_local_using_directives = NULL;
 
   return newobj;
 }
@@ -1713,6 +1718,33 @@ get_last_source_start_addr ()
   return buildsym_compunit->m_last_source_start_addr;
 }
 
+/* See buildsym.h.  */
+
+struct using_direct **
+get_local_using_directives ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return &buildsym_compunit->m_local_using_directives;
+}
+
+/* See buildsym.h.  */
+
+void
+set_local_using_directives (struct using_direct *new_local)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  buildsym_compunit->m_local_using_directives = new_local;
+}
+
+/* See buildsym.h.  */
+
+struct using_direct **
+get_global_using_directives ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return &buildsym_compunit->m_global_using_directives;
+}
+
 \f
 
 /* Initialize anything that needs initializing when starting to read a
@@ -1738,7 +1770,6 @@ buildsym_init ()
   gdb_assert (pending_blocks == NULL);
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
-  gdb_assert (global_using_directives == NULL);
   gdb_assert (pending_addrmap == NULL);
   gdb_assert (buildsym_compunit == NULL);
 }
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 512d926dcb..efb35c907b 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -93,14 +93,6 @@ EXTERN struct pending *global_symbols;
 
 EXTERN struct pending *local_symbols;
 
-/* "using" directives local to lexical context.  */
-
-EXTERN struct using_direct *local_using_directives;
-
-/* global "using" directives.  */
-
-EXTERN struct using_direct *global_using_directives;
-
 /* Stack representing unclosed lexical contexts (that will become
    blocks, eventually).  */
 
@@ -266,6 +258,18 @@ extern void set_last_source_start_addr (CORE_ADDR addr);
 
 extern CORE_ADDR get_last_source_start_addr ();
 
+/* Return the local using directives.  */
+
+extern struct using_direct **get_local_using_directives ();
+
+/* Set the list of local using directives.  */
+
+extern void set_local_using_directives (struct using_direct *new_local);
+
+/* Return the global using directives.  */
+
+extern struct using_direct **get_global_using_directives ();
+
 #undef EXTERN
 
 #endif /* defined (BUILDSYM_H) */
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 185607e4eb..22b7af00d6 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -94,7 +94,7 @@ cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
 		 namespace given by the previous component if there is
 		 one, or to the global namespace if there isn't.  */
 	      std::vector<const char *> excludes;
-	      add_using_directive (&local_using_directives,
+	      add_using_directive (get_local_using_directives (),
 				   dest, src, NULL, NULL, excludes, 1,
 				   &objfile->objfile_obstack);
 	    }
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 4871787583..ec62a23091 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11141,9 +11141,9 @@ static struct using_direct **
 using_directives (enum language language)
 {
   if (language == language_ada && context_stack_depth == 0)
-    return &global_using_directives;
+    return get_global_using_directives ();
   else
-    return &local_using_directives;
+    return get_local_using_directives ();
 }
 
 /* Read the import statement specified by the given die and record it.  */
@@ -13770,7 +13770,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
      when we finish processing a function scope, we may need to go
      back to building a containing block's symbol lists.  */
   local_symbols = newobj->locals;
-  local_using_directives = newobj->local_using_directives;
+  set_local_using_directives (newobj->local_using_directives);
 
   /* If we've finished processing a top-level function, subsequent
      symbols go in the file symbol list.  */
@@ -13828,7 +13828,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
   inherit_abstract_dies (die, cu);
   newobj = pop_context ();
 
-  if (local_symbols != NULL || local_using_directives != NULL)
+  if (local_symbols != NULL || (*get_local_using_directives ()) != NULL)
     {
       struct block *block
         = finish_block (0, &local_symbols, newobj->old_blocks, NULL,
@@ -13847,7 +13847,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
       dwarf2_record_block_ranges (die, block, baseaddr, cu);
     }
   local_symbols = newobj->locals;
-  local_using_directives = newobj->local_using_directives;
+  set_local_using_directives (newobj->local_using_directives);
 }
 
 /* Read in DW_TAG_call_site and insert it to CU->call_site_htab.  */
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 13/42] Remove buildsym_new_init
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (6 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 25/42] Remove the "listhead" argument from finish_block Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:51   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 29/42] Move the symbol lists to buildsym_compunit Tom Tromey
                   ` (35 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

buildsym_new_init is just an alias for buildsym_init.  This removes
it.  In the long run buildsym_init will also go away; this patch just
helps make things a bit clearer in the meantime.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_new_init): Update.
	* mipsread.c (mipscoff_new_init): Update.
	* mdebugread.c (mdebug_build_psymtabs): Update.
	* elfread.c (elf_new_init): Update.
	* dbxread.c (dbx_new_init, coffstab_build_psymtabs)
	(elfstab_build_psymtabs, stabsect_build_psymtabs): Update.
	* buildsym.h (buildsym_new_init): Don't declare.
	* buildsym.c (buildsym_new_init): Remove.
---
 gdb/ChangeLog    | 11 +++++++++++
 gdb/buildsym.c   | 12 +-----------
 gdb/buildsym.h   |  4 +---
 gdb/dbxread.c    |  8 ++++----
 gdb/elfread.c    |  2 +-
 gdb/mdebugread.c |  2 +-
 gdb/mipsread.c   |  2 +-
 gdb/xcoffread.c  |  2 +-
 8 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 10c816efb3..6fe413be8a 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1759,7 +1759,7 @@ get_last_source_start_addr ()
    corresponding to a psymtab.  */
 
 void
-buildsym_init (void)
+buildsym_init ()
 {
   subfile_stack = NULL;
 
@@ -1783,13 +1783,3 @@ buildsym_init (void)
   gdb_assert (pending_addrmap == NULL);
   gdb_assert (buildsym_compunit == NULL);
 }
-
-/* Initialize anything that needs initializing when a completely new
-   symbol file is specified (not just adding some symbols from another
-   file, e.g. a shared library).  */
-
-void
-buildsym_new_init (void)
-{
-  buildsym_init ();
-}
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index a6bed3c611..77fc5bdd3c 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -209,9 +209,7 @@ extern void augment_type_symtab (void);
 
 extern void scan_file_globals (struct objfile *objfile);
 
-extern void buildsym_new_init (void);
-
-extern void buildsym_init (void);
+extern void buildsym_init ();
 
 extern struct context_stack *push_context (int desc, CORE_ADDR valu);
 
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index eed4a28b90..52241f620d 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -569,7 +569,7 @@ static void
 dbx_new_init (struct objfile *ignore)
 {
   stabsread_new_init ();
-  buildsym_new_init ();
+  buildsym_init ();
   init_header_files ();
 }
 
@@ -3104,7 +3104,7 @@ coffstab_build_psymtabs (struct objfile *objfile,
     perror_with_name (name);
 
   stabsread_new_init ();
-  buildsym_new_init ();
+  buildsym_init ();
   free_header_files ();
   init_header_files ();
 
@@ -3193,7 +3193,7 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
     perror_with_name (name);
 
   stabsread_new_init ();
-  buildsym_new_init ();
+  buildsym_init ();
   free_header_files ();
   init_header_files ();
 
@@ -3293,7 +3293,7 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
     perror_with_name (name);
 
   stabsread_new_init ();
-  buildsym_new_init ();
+  buildsym_init ();
   free_header_files ();
   init_header_files ();
 
diff --git a/gdb/elfread.c b/gdb/elfread.c
index b4b4a1b24c..8978f15e88 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1325,7 +1325,7 @@ static void
 elf_new_init (struct objfile *ignore)
 {
   stabsread_new_init ();
-  buildsym_new_init ();
+  buildsym_init ();
 }
 
 /* Perform any local cleanups required when we are done with a particular
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 3f0cdc74aa..e56e009589 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -345,7 +345,7 @@ mdebug_build_psymtabs (minimal_symbol_reader &reader,
   debug_info = info;
 
   stabsread_new_init ();
-  buildsym_new_init ();
+  buildsym_init ();
   free_header_files ();
   init_header_files ();
         
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 7b6ec2e48d..3bdc50733d 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -54,7 +54,7 @@ static void
 mipscoff_new_init (struct objfile *ignore)
 {
   stabsread_new_init ();
-  buildsym_new_init ();
+  buildsym_init ();
 }
 
 /* Initialize to read a symbol file (nothing to do).  */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 8bb244618c..e9bb79c87a 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1925,7 +1925,7 @@ static void
 xcoff_new_init (struct objfile *objfile)
 {
   stabsread_new_init ();
-  buildsym_new_init ();
+  buildsym_init ();
 }
 
 /* Do initialization in preparation for reading symbols from OBJFILE.
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 04/42] Move last_source file to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
  2018-05-23  4:59 ` [RFA 17/42] Move the subfile stack to buildsym_compunit Tom Tromey
  2018-05-23  4:59 ` [RFA 02/42] Change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-07  3:51   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 15/42] Remove merge_symbol_lists Tom Tromey
                   ` (40 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the global last_source_file into buildsym_compunit.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (buildsym_compunit::buildsym_compunit): Add name
	parameter.
	(buildsym_compunit::set_last_source_file): New method.
	<m_last_source_file>: New member.
	(prepare_for_building): Remove "name" parameter.
	(start_symtab, restart_symtab, reset_symtab_globals): Update.
	(last_source_file): Remove.
	(set_last_source_file, get_last_source_file): Update.
---
 gdb/ChangeLog  | 11 +++++++++++
 gdb/buildsym.c | 44 ++++++++++++++++++++++++++------------------
 2 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 9e0c39a4a4..5dd6f7e343 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -105,9 +105,10 @@ struct buildsym_compunit
      COMP_DIR is the directory in which the compilation unit was compiled
      (or NULL if not known).  */
 
-  buildsym_compunit (struct objfile *objfile_, const char *comp_dir_,
-		     enum language language_)
+  buildsym_compunit (struct objfile *objfile_, const char *name,
+		     const char *comp_dir_, enum language language_)
     : objfile (objfile_),
+      m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
       comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
       language (language_)
   {
@@ -128,6 +129,12 @@ struct buildsym_compunit
       }
   }
 
+  void set_last_source_file (const char *name)
+  {
+    char *new_name = name == NULL ? NULL : xstrdup (name);
+    m_last_source_file.reset (new_name);
+  }
+
   /* The objfile we're reading debug info from.  */
   struct objfile *objfile;
 
@@ -140,6 +147,12 @@ struct buildsym_compunit
   /* The subfile of the main source file.  */
   struct subfile *main_subfile = nullptr;
 
+  /* Name of source file whose symbol data we are now processing.  This
+     comes from a symbol of type N_SO for stabs.  For Dwarf it comes
+     from the DW_AT_name attribute of a DW_TAG_compile_unit DIE.  */
+
+  gdb::unique_xmalloc_ptr<char> m_last_source_file;
+
   /* E.g., DW_AT_comp_dir if DWARF.  Space for this is malloc'd.  */
   gdb::unique_xmalloc_ptr<char> comp_dir;
 
@@ -1005,9 +1018,8 @@ get_macro_table (void)
    buildsym_init.  */
 
 static void
-prepare_for_building (const char *name, CORE_ADDR start_addr)
+prepare_for_building (CORE_ADDR start_addr)
 {
-  set_last_source_file (name);
   last_source_start_addr = start_addr;
 
   local_symbols = NULL;
@@ -1044,9 +1056,9 @@ struct compunit_symtab *
 start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
 	      CORE_ADDR start_addr, enum language language)
 {
-  prepare_for_building (name, start_addr);
+  prepare_for_building (start_addr);
 
-  buildsym_compunit = new struct buildsym_compunit (objfile, comp_dir,
+  buildsym_compunit = new struct buildsym_compunit (objfile, name, comp_dir,
 						    language);
 
   /* Allocate the compunit symtab now.  The caller needs it to allocate
@@ -1081,10 +1093,11 @@ void
 restart_symtab (struct compunit_symtab *cust,
 		const char *name, CORE_ADDR start_addr)
 {
-  prepare_for_building (name, start_addr);
+  prepare_for_building (start_addr);
 
   buildsym_compunit
     = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust),
+				    name,
 				    COMPUNIT_DIRNAME (cust),
 				    compunit_language (cust));
   buildsym_compunit->compunit_symtab = cust;
@@ -1172,8 +1185,6 @@ watch_main_source_file_lossage (void)
 static void
 reset_symtab_globals (void)
 {
-  set_last_source_file (NULL);
-
   local_symbols = NULL;
   local_using_directives = NULL;
   file_symbols = NULL;
@@ -1706,19 +1717,14 @@ merge_symbol_lists (struct pending **srclist, struct pending **targetlist)
 }
 \f
 
-/* Name of source file whose symbol data we are now processing.  This
-   comes from a symbol of type N_SO for stabs.  For Dwarf it comes
-   from the DW_AT_name attribute of a DW_TAG_compile_unit DIE.  */
-
-static char *last_source_file;
-
 /* See buildsym.h.  */
 
 void
 set_last_source_file (const char *name)
 {
-  xfree (last_source_file);
-  last_source_file = name == NULL ? NULL : xstrdup (name);
+  gdb_assert (buildsym_compunit != nullptr || name == nullptr);
+  if (buildsym_compunit != nullptr)
+    buildsym_compunit->set_last_source_file (name);
 }
 
 /* See buildsym.h.  */
@@ -1726,7 +1732,9 @@ set_last_source_file (const char *name)
 const char *
 get_last_source_file (void)
 {
-  return last_source_file;
+  if (buildsym_compunit == nullptr)
+    return nullptr;
+  return buildsym_compunit->m_last_source_file.get ();
 }
 
 \f
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 08/42] Move processing_acc_compilation to dbxread.c
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (14 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 03/42] Add assert in prepare_for_building Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:15   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 09/42] Make context_stack_size static in buildsym.c Tom Tromey
                   ` (27 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

processing_acc_compilation is only used in dbxread.c, so move it
there.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* dbxread.c (processing_acc_compilation): New global.
	* buildsym.h (processing_acc_compilation): Don't declare.
---
 gdb/ChangeLog  | 5 +++++
 gdb/buildsym.h | 8 --------
 gdb/dbxread.c  | 8 ++++++++
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 61ffc0fd89..088c1d790e 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -74,14 +74,6 @@ EXTERN struct subfile *current_subfile;
 
 EXTERN unsigned char processing_gcc_compilation;
 
-/* When set, we are processing a .o file compiled by sun acc.  This is
-   misnamed; it refers to all stabs-in-elf implementations which use
-   N_UNDF the way Sun does, including Solaris gcc.  Hopefully all
-   stabs-in-elf implementations ever invented will choose to be
-   compatible.  */
-
-EXTERN unsigned char processing_acc_compilation;
-
 /* Count symbols as they are processed, for error messages.  */
 
 EXTERN unsigned int symnum;
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 31de714cc7..eed4a28b90 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -145,6 +145,14 @@ static unsigned int next_file_string_table_offset;
 
 static int symfile_relocatable = 0;
 
+/* When set, we are processing a .o file compiled by sun acc.  This is
+   misnamed; it refers to all stabs-in-elf implementations which use
+   N_UNDF the way Sun does, including Solaris gcc.  Hopefully all
+   stabs-in-elf implementations ever invented will choose to be
+   compatible.  */
+
+static unsigned char processing_acc_compilation;
+
 \f
 /* The lowest text address we have yet encountered.  This is needed
    because in an a.out file, there is no header field which tells us
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 07/42] Move last_source_start_addr to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (21 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 28/42] Set list_in_scope later in DWARF reader Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:10   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 14/42] Move scan_file_globals declaration to stabsread.h Tom Tromey
                   ` (20 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the global last_source_start_addr into buildsym_compunit,
adding some accessors as well.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (aix_process_linenos, complete_symtab): Update.
	* dbxread.c (read_ofile_symtab): Update.
	* coffread.c (coff_start_symtab, coff_end_symtab): Update.
	* buildsym.h (last_source_start_addr): Remove.
	(set_last_source_start_addr, get_last_source_start_addr):
	Declare.
	* buildsym.c (buildsym_compunit::buildsym_compunit): Add last_addr
	parameter.
	(struct buildsym_compunit) <m_last_source_start_addr>: New
	member.
	(prepare_for_building): Remove start_addr parameter.
	(start_symtab, restart_symtab, end_symtab_get_static_block)
	(end_symtab_with_blockvector): Update.
	(set_last_source_start_addr, get_last_source_start_addr): New
	functions.
---
 gdb/ChangeLog   | 18 ++++++++++++++++++
 gdb/buildsym.c  | 48 ++++++++++++++++++++++++++++++++++++------------
 gdb/buildsym.h  | 16 ++++++++++------
 gdb/coffread.c  |  6 +++---
 gdb/dbxread.c   |  8 ++++----
 gdb/xcoffread.c |  4 ++--
 6 files changed, 73 insertions(+), 27 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index d0dfa4cd02..583c294790 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -106,11 +106,13 @@ struct buildsym_compunit
      (or NULL if not known).  */
 
   buildsym_compunit (struct objfile *objfile_, const char *name,
-		     const char *comp_dir_, enum language language_)
+		     const char *comp_dir_, enum language language_,
+		     CORE_ADDR last_addr)
     : objfile (objfile_),
       m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
       comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
-      language (language_)
+      language (language_),
+      m_last_source_start_addr (last_addr)
   {
   }
 
@@ -196,6 +198,11 @@ struct buildsym_compunit
   /* True if symtab has line number info.  This prevents an otherwise
      empty symtab from being tossed.  */
   bool m_have_line_numbers = false;
+
+  /* Core address of start of text of current source file.  This too
+     comes from the N_SO symbol.  For Dwarf it typically comes from the
+     DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE.  */
+  CORE_ADDR m_last_source_start_addr;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -1022,10 +1029,8 @@ get_macro_table (void)
    buildsym_init.  */
 
 static void
-prepare_for_building (CORE_ADDR start_addr)
+prepare_for_building ()
 {
-  last_source_start_addr = start_addr;
-
   local_symbols = NULL;
   local_using_directives = NULL;
   within_function = 0;
@@ -1058,10 +1063,10 @@ struct compunit_symtab *
 start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
 	      CORE_ADDR start_addr, enum language language)
 {
-  prepare_for_building (start_addr);
+  prepare_for_building ();
 
   buildsym_compunit = new struct buildsym_compunit (objfile, name, comp_dir,
-						    language);
+						    language, start_addr);
 
   /* Allocate the compunit symtab now.  The caller needs it to allocate
      non-primary symtabs.  It is also needed by get_macro_table.  */
@@ -1095,13 +1100,14 @@ void
 restart_symtab (struct compunit_symtab *cust,
 		const char *name, CORE_ADDR start_addr)
 {
-  prepare_for_building (start_addr);
+  prepare_for_building ();
 
   buildsym_compunit
     = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust),
 				    name,
 				    COMPUNIT_DIRNAME (cust),
-				    compunit_language (cust));
+				    compunit_language (cust),
+				    start_addr);
   buildsym_compunit->compunit_symtab = cust;
 }
 
@@ -1297,8 +1303,8 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
     {
       /* Define the STATIC_BLOCK.  */
       return finish_block_internal (NULL, &file_symbols, NULL, NULL,
-				    last_source_start_addr, end_addr,
-				    0, expandable);
+				    buildsym_compunit->m_last_source_start_addr,
+				    end_addr, 0, expandable);
     }
 }
 
@@ -1325,7 +1331,7 @@ end_symtab_with_blockvector (struct block *static_block,
 
   /* Create the GLOBAL_BLOCK and build the blockvector.  */
   finish_block_internal (NULL, &global_symbols, NULL, NULL,
-			 last_source_start_addr, end_addr,
+			 buildsym_compunit->m_last_source_start_addr, end_addr,
 			 1, expandable);
   blockvector = make_blockvector ();
 
@@ -1735,6 +1741,24 @@ get_last_source_file (void)
   return buildsym_compunit->m_last_source_file.get ();
 }
 
+/* See buildsym.h.  */
+
+void
+set_last_source_start_addr (CORE_ADDR addr)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  buildsym_compunit->m_last_source_start_addr = addr;
+}
+
+/* See buildsym.h.  */
+
+CORE_ADDR
+get_last_source_start_addr ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->m_last_source_start_addr;
+}
+
 \f
 
 /* Initialize anything that needs initializing when starting to read a
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 536d50a58e..61ffc0fd89 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -49,12 +49,6 @@ struct dynamic_prop;
 #define HASHSIZE 127		/* Size of things hashed via
 				   hashname().  */
 
-/* Core address of start of text of current source file.  This too
-   comes from the N_SO symbol.  For Dwarf it typically comes from the
-   DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE.  */
-
-EXTERN CORE_ADDR last_source_start_addr;
-
 /* The list of sub-source-files within the current individual
    compilation.  Each file gets its own symtab with its own linetable
    and associated info, but they all share one blockvector.  */
@@ -310,6 +304,16 @@ extern struct compunit_symtab *buildsym_compunit_symtab (void);
 
 extern struct macro_table *get_macro_table (void);
 
+/* Set the last source start address.  Can only be used between
+   start_symtab and end_symtab* calls.  */
+
+extern void set_last_source_start_addr (CORE_ADDR addr);
+
+/* Get the last source start address.  Can only be used between
+   start_symtab and end_symtab* calls.  */
+
+extern CORE_ADDR get_last_source_start_addr ();
+
 #undef EXTERN
 
 #endif /* defined (BUILDSYM_H) */
diff --git a/gdb/coffread.c b/gdb/coffread.c
index f24ec0713a..5c97e7b949 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -390,8 +390,8 @@ coff_start_symtab (struct objfile *objfile, const char *name)
 		 xstrdup (name),
   /* We never know the directory name for COFF.  */
 		 NULL,
-  /* The start address is irrelevant, since we set
-     last_source_start_addr in coff_end_symtab.  */
+  /* The start address is irrelevant, since we call
+     set_last_source_start_addr in coff_end_symtab.  */
 		 0,
   /* Let buildsym.c deduce the language for this symtab.  */
 		 language_unknown);
@@ -420,7 +420,7 @@ complete_symtab (const char *name, CORE_ADDR start_addr, unsigned int size)
 static void
 coff_end_symtab (struct objfile *objfile)
 {
-  last_source_start_addr = current_source_start_addr;
+  set_last_source_start_addr (current_source_start_addr);
 
   end_symtab (current_source_end_addr, SECT_OFF_TEXT (objfile));
 
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index d0926896e2..31de714cc7 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2435,14 +2435,14 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
   /* In a Solaris elf file, this variable, which comes from the
      value of the N_SO symbol, will still be 0.  Luckily, text_offset,
      which comes from pst->textlow is correct.  */
-  if (last_source_start_addr == 0)
-    last_source_start_addr = text_offset;
+  if (get_last_source_start_addr () == 0)
+    set_last_source_start_addr (text_offset);
 
   /* In reordered executables last_source_start_addr may not be the
      lower bound for this symtab, instead use text_offset which comes
      from pst->textlow which is correct.  */
-  if (last_source_start_addr > text_offset)
-    last_source_start_addr = text_offset;
+  if (get_last_source_start_addr () > text_offset)
+    set_last_source_start_addr (text_offset);
 
   pst->compunit_symtab = end_symtab (text_offset + text_size,
 				     SECT_OFF_TEXT (objfile));
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 7cf5e259d9..8bb244618c 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -817,7 +817,7 @@ aix_process_linenos (struct objfile *objfile)
     return;
 
   /* Process line numbers and enter them into line vector.  */
-  process_linenos (last_source_start_addr, cur_src_end_addr);
+  process_linenos (get_last_source_start_addr (), cur_src_end_addr);
 }
 
 
@@ -904,7 +904,7 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset,
 
 #define complete_symtab(name, start_addr) {	\
   set_last_source_file (name);			\
-  last_source_start_addr = start_addr;		\
+  set_last_source_start_addr (start_addr);	\
 }
 
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 17/42] Move the subfile stack to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:59   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 02/42] Change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr Tom Tromey
                   ` (42 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the global subfile_stack to be a member of
buildsym_compunit.  It also change this to be a std::vector, which
simplifies the code.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.h (push_subfile, pop_subfile): Update declarations.
	* buildsym.c (struct buildsym_compunit) <m_subfile_stack>: New
	member.
	(struct subfile_stack): Remove.
	(subfile_stack): Remove.
	(push_subfile, pop_subfile, buildsym_init): Update.
---
 gdb/ChangeLog  |  9 +++++++++
 gdb/buildsym.c | 39 +++++++++++++--------------------------
 gdb/buildsym.h |  4 ++--
 3 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 4823fb383d..f828fceb72 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -202,6 +202,9 @@ struct buildsym_compunit
      comes from the N_SO symbol.  For Dwarf it typically comes from the
      DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE.  */
   CORE_ADDR m_last_source_start_addr;
+
+  /* Stack of subfile names.  */
+  std::vector<const char *> m_subfile_stack;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -249,14 +252,6 @@ struct pending_block
 
 static struct pending_block *pending_blocks;
 
-struct subfile_stack
-  {
-    struct subfile_stack *next;
-    char *name;
-  };
-
-static struct subfile_stack *subfile_stack;
-
 /* Currently allocated size of context stack.  */
 
 static int context_stack_size;
@@ -890,27 +885,21 @@ patch_subfile_names (struct subfile *subfile, const char *name)
    order.  */
 
 void
-push_subfile (void)
+push_subfile ()
 {
-  struct subfile_stack *tem = XNEW (struct subfile_stack);
-
-  tem->next = subfile_stack;
-  subfile_stack = tem;
+  gdb_assert (buildsym_compunit != nullptr);
   gdb_assert (! (current_subfile == NULL || current_subfile->name == NULL));
-  tem->name = current_subfile->name;
+  buildsym_compunit->m_subfile_stack.push_back (current_subfile->name);
 }
 
-char *
-pop_subfile (void)
+const char *
+pop_subfile ()
 {
-  char *name;
-  struct subfile_stack *link = subfile_stack;
-
-  gdb_assert (link != NULL);
-  name = link->name;
-  subfile_stack = link->next;
-  xfree ((void *) link);
-  return (name);
+  gdb_assert (buildsym_compunit != nullptr);
+  gdb_assert (!buildsym_compunit->m_subfile_stack.empty ());
+  const char *name = buildsym_compunit->m_subfile_stack.back ();
+  buildsym_compunit->m_subfile_stack.pop_back ();
+  return name;
 }
 \f
 /* Add a linetable entry for line number LINE and address PC to the
@@ -1726,8 +1715,6 @@ get_last_source_start_addr ()
 void
 buildsym_init ()
 {
-  subfile_stack = NULL;
-
   pending_addrmap_interesting = 0;
 
   /* Context stack is initially empty.  Allocate first one with room
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index d0943456cd..b5ea63d3f4 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -186,9 +186,9 @@ extern void start_subfile (const char *name);
 
 extern void patch_subfile_names (struct subfile *subfile, const char *name);
 
-extern void push_subfile (void);
+extern void push_subfile ();
 
-extern char *pop_subfile (void);
+extern const char *pop_subfile ();
 
 extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
 						  int expandable,
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 14/42] Move scan_file_globals declaration to stabsread.h
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (22 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 07/42] Move last_source_start_addr to buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:52   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 21/42] Move the context stack to buildsym_compunit Tom Tromey
                   ` (19 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

scan_file_globals is defined in stabsread.c, so move its declaration
to stabsread.h.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* stabsread.h (scan_file_globals): Move from buildsym.h.
	* buildsym.h (scan_file_globals): Move to stabsread.h.
---
 gdb/ChangeLog   | 5 +++++
 gdb/buildsym.h  | 4 ----
 gdb/stabsread.h | 2 ++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 77fc5bdd3c..f70777946a 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -205,10 +205,6 @@ extern struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
 
 extern void augment_type_symtab (void);
 
-/* Defined in stabsread.c.  */
-
-extern void scan_file_globals (struct objfile *objfile);
-
 extern void buildsym_init ();
 
 extern struct context_stack *push_context (int desc, CORE_ADDR valu);
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index ce254e65d0..a5f327012d 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -221,4 +221,6 @@ extern void free_header_files (void);
 
 extern void init_header_files (void);
 
+extern void scan_file_globals (struct objfile *objfile);
+
 #undef EXTERN
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 20/42] Use outermost_context_p in more places
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (18 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 19/42] Move the using directives to buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 17:13   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 10/42] Move some code from buildsym to stabsread Tom Tromey
                   ` (23 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes a few explicit checks of context_stack_depth to use
outermost_context_p instead.  This simplifies some future work.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab): Use outermost_context_p.
	* dwarf2read.c (using_directives, new_symbol): Use
	outermost_context_p.
	* dbxread.c (process_one_symbol): Use outermost_context_p.
	* coffread.c (coff_symtab_read): Use outermost_context_p.
---
 gdb/ChangeLog    | 8 ++++++++
 gdb/coffread.c   | 8 ++++----
 gdb/dbxread.c    | 6 +++---
 gdb/dwarf2read.c | 4 ++--
 gdb/xcoffread.c  | 8 ++++----
 5 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index 2e5bf9bcab..85718b252a 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1092,7 +1092,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 	      /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
 	         contains number of lines to '}' */
 
-	      if (context_stack_depth <= 0)
+	      if (outermost_context_p ())
 		{	/* We attempted to pop an empty context stack.  */
 		  complaint (&symfile_complaints,
 			     _("`.ef' symbol without matching `.bf' "
@@ -1104,7 +1104,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 
 	      newobj = pop_context ();
 	      /* Stack must be empty now.  */
-	      if (context_stack_depth > 0 || newobj == NULL)
+	      if (!outermost_context_p () || newobj == NULL)
 		{
 		  complaint (&symfile_complaints,
 			     _("Unmatched .ef symbol(s) ignored "
@@ -1159,7 +1159,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 	    }
 	  else if (strcmp (cs->c_name, ".eb") == 0)
 	    {
-	      if (context_stack_depth <= 0)
+	      if (outermost_context_p ())
 		{	/* We attempted to pop an empty context stack.  */
 		  complaint (&symfile_complaints,
 			     _("`.eb' symbol without matching `.bb' "
@@ -1177,7 +1177,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 			     symnum);
 		  break;
 		}
-	      if (local_symbols && context_stack_depth > 0)
+	      if (local_symbols && !outermost_context_p ())
 		{
 		  tmpaddr =
 		    cs->c_value + ANOFFSET (objfile->section_offsets,
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 127ae5bdf8..ed6e6be458 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2557,7 +2557,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	     the current block.  */
 	  struct block *block;
 
- 	  if (context_stack_depth <= 0)
+	  if (outermost_context_p ())
  	    {
 	      lbrac_mismatch_complaint (symnum);
  	      break;
@@ -2626,7 +2626,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 
       valu += function_start_offset;
 
-      if (context_stack_depth <= 0)
+      if (outermost_context_p ())
 	{
 	  lbrac_mismatch_complaint (symnum);
 	  break;
@@ -2950,7 +2950,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 		  break;
 		}
 
-	      if (context_stack_depth > 0)
+	      if (!outermost_context_p ())
 		{
 		  struct block *block;
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index ec62a23091..b39c14365a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11140,7 +11140,7 @@ read_namespace_alias (struct die_info *die, struct dwarf2_cu *cu)
 static struct using_direct **
 using_directives (enum language language)
 {
-  if (language == language_ada && context_stack_depth == 0)
+  if (language == language_ada && outermost_context_p ())
     return get_global_using_directives ();
   else
     return get_local_using_directives ();
@@ -21472,7 +21472,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	     when we do not have enough information to show inlined frames;
 	     pretend it's a local variable in that case so that the user can
 	     still see it.  */
-	  if (context_stack_depth > 0
+	  if (!outermost_context_p ()
 	      && context_stack[context_stack_depth - 1].name != NULL)
 	    SYMBOL_IS_ARGUMENT (sym) = 1;
 	  attr = dwarf2_attr (die, DW_AT_location, cu);
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 21d107f78d..89896baded 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1395,7 +1395,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 	      /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
 	         contains number of lines to '}' */
 
-	      if (context_stack_depth <= 0)
+	      if (outermost_context_p ())
 		{	/* We attempted to pop an empty context stack.  */
 		  ef_complaint (cs->c_symnum);
 		  within_function = 0;
@@ -1403,7 +1403,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 		}
 	      newobj = pop_context ();
 	      /* Stack must be empty now.  */
-	      if (context_stack_depth > 0 || newobj == NULL)
+	      if (!outermost_context_p () || newobj == NULL)
 		{
 		  ef_complaint (cs->c_symnum);
 		  within_function = 0;
@@ -1488,7 +1488,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 	    }
 	  else if (strcmp (cs->c_name, ".eb") == 0)
 	    {
-	      if (context_stack_depth <= 0)
+	      if (outermost_context_p ())
 		{	/* We attempted to pop an empty context stack.  */
 		  eb_complaint (cs->c_symnum);
 		  break;
@@ -1499,7 +1499,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 		  eb_complaint (cs->c_symnum);
 		  break;
 		}
-	      if (local_symbols && context_stack_depth > 0)
+	      if (local_symbols && !outermost_context_p ())
 		{
 		  /* Make a block for the local symbols within.  */
 		  finish_block (newobj->name, &local_symbols,
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 06/42] Move have_line_numbers to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (11 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 18/42] Make free_pending_blocks static Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-05 19:01   ` Keith Seitz
  2018-05-23  4:59 ` [RFA 23/42] Move pending addrmap globals " Tom Tromey
                   ` (30 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the global have_line_numbers into buildsym_compunit.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (struct buildsym_compunit) <m_have_line_numbers>: New
	member.
	(have_line_numbers): Remove.
	(record_line, prepare_for_building, end_symtab_get_static_block)
	(augment_type_symtab): Update.
---
 gdb/ChangeLog  |  8 ++++++++
 gdb/buildsym.c | 16 +++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index c3961254da..d0dfa4cd02 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -192,6 +192,10 @@ struct buildsym_compunit
   /* The macro table for the compilation unit whose symbols we're
      currently reading.  */
   struct macro_table *m_pending_macros = nullptr;
+
+  /* True if symtab has line number info.  This prevents an otherwise
+     empty symtab from being tossed.  */
+  bool m_have_line_numbers = false;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -203,11 +207,6 @@ static struct buildsym_compunit *buildsym_compunit;
 
 static struct pending *free_pendings;
 
-/* Non-zero if symtab has line number info.  This prevents an
-   otherwise empty symtab from being tossed.  */
-
-static int have_line_numbers;
-
 /* The mutable address map for the compilation unit whose symbols
    we're currently reading.  The symtabs' shared blockvector will
    point to a fixed copy of this.  */
@@ -934,7 +933,7 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc)
 	xmalloc (sizeof (struct linetable)
 	   + subfile->line_vector_length * sizeof (struct linetable_entry));
       subfile->line_vector->nitems = 0;
-      have_line_numbers = 1;
+      buildsym_compunit->m_have_line_numbers = true;
     }
 
   if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length)
@@ -1030,7 +1029,6 @@ prepare_for_building (CORE_ADDR start_addr)
   local_symbols = NULL;
   local_using_directives = NULL;
   within_function = 0;
-  have_line_numbers = 0;
 
   context_stack_depth = 0;
 
@@ -1288,7 +1286,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
       && pending_blocks == NULL
       && file_symbols == NULL
       && global_symbols == NULL
-      && have_line_numbers == 0
+      && buildsym_compunit->m_have_line_numbers == 0
       && buildsym_compunit->m_pending_macros == NULL
       && global_using_directives == NULL)
     {
@@ -1595,7 +1593,7 @@ augment_type_symtab (void)
     complaint (&symfile_complaints, _("Blocks in a type symtab"));
   if (buildsym_compunit->m_pending_macros != NULL)
     complaint (&symfile_complaints, _("Macro in a type symtab"));
-  if (have_line_numbers)
+  if (buildsym_compunit->m_have_line_numbers)
     complaint (&symfile_complaints,
 	       _("Line numbers recorded in a type symtab"));
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 26/42] Remove free_pendings
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (9 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 05/42] Move pending_macros " Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-10  2:55   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 18/42] Make free_pending_blocks static Tom Tromey
                   ` (32 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

buildsym.c currently keeps a free list of "struct pending"s.  However,
this didn't seem necessary to me, and so this patch removes the free
list.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (free_pendings): Remove.
	(add_symbol_to_list, scoped_free_pendings)
	(finish_block_internal, buildsym_init): Update.
---
 gdb/ChangeLog  |  6 ++++++
 gdb/buildsym.c | 28 +++-------------------------
 2 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 516dac6b7e..40176298a2 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -258,10 +258,6 @@ struct buildsym_compunit
 
 static struct buildsym_compunit *buildsym_compunit;
 
-/* List of free `struct pending' structures for reuse.  */
-
-static struct pending *free_pendings;
-
 /* List of blocks already made (lexical contexts already closed).
    This is used at the end to make the blockvector.  */
 
@@ -303,16 +299,7 @@ add_symbol_to_list (struct symbol *symbol, struct pending **listhead)
      don't have a link with room in it, add a new link.  */
   if (*listhead == NULL || (*listhead)->nsyms == PENDINGSIZE)
     {
-      if (free_pendings)
-	{
-	  link = free_pendings;
-	  free_pendings = link->next;
-	}
-      else
-	{
-	  link = XNEW (struct pending);
-	}
-
+      link = XNEW (struct pending);
       link->next = *listhead;
       *listhead = link;
       link->nsyms = 0;
@@ -360,13 +347,6 @@ scoped_free_pendings::~scoped_free_pendings ()
 {
   struct pending *next, *next1;
 
-  for (next = free_pendings; next; next = next1)
-    {
-      next1 = next->next;
-      xfree ((void *) next);
-    }
-  free_pendings = NULL;
-
   for (next = file_symbols; next != NULL; next = next1)
     {
       next1 = next->next;
@@ -488,13 +468,12 @@ finish_block_internal (struct symbol *symbol,
   if (static_link != NULL)
     objfile_register_static_link (objfile, block, static_link);
 
-  /* Now "free" the links of the list, and empty the list.  */
+  /* Now free the links of the list, and empty the list.  */
 
   for (next = *listhead; next; next = next1)
     {
       next1 = next->next;
-      next->next = free_pendings;
-      free_pendings = next;
+      xfree (next);
     }
   *listhead = NULL;
 
@@ -1767,7 +1746,6 @@ buildsym_init ()
 {
   /* Ensure the scoped_free_pendings destructor was called after
      the last time.  */
-  gdb_assert (free_pendings == NULL);
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
   gdb_assert (buildsym_compunit == NULL);
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 12/42] Move within_function to stabsread
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (25 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 01/42] Use new and delete for buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:49   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 34/42] Add many methods to buildsym_compunit Tom Tromey
                   ` (16 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The global within_function is only used by a few symbol readers.  This
patch moves the global out of buildsym and into stabsread, which
seemed like a better fit.  It also arranges for the existing readers
to clear the global at the appropriate time.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* stabsread.h (within_function): Move from buildsym.h.
	* stabsread.c (start_stabs): Clear within_function.
	* coffread.c (coff_start_symtab): Clear within_function.
	* buildsym.h (within_function): Move to stabsread.h.
	* buildsym.c (prepare_for_building): Update.
---
 gdb/ChangeLog   | 8 ++++++++
 gdb/buildsym.c  | 1 -
 gdb/buildsym.h  | 5 -----
 gdb/coffread.c  | 1 +
 gdb/stabsread.c | 1 +
 gdb/stabsread.h | 5 +++++
 6 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 0e69865886..10c816efb3 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1036,7 +1036,6 @@ prepare_for_building ()
 {
   local_symbols = NULL;
   local_using_directives = NULL;
-  within_function = 0;
 
   context_stack_depth = 0;
 
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 01d9acc2c9..a6bed3c611 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -150,11 +150,6 @@ EXTERN int context_stack_depth;
 /* Non-zero if the context stack is empty.  */
 #define outermost_context_p() (context_stack_depth == 0)
 
-/* Nonzero if within a function (so symbols should be local, if
-   nothing says specifically).  */
-
-EXTERN int within_function;
-
 /* The type of the record_line function.  */
 typedef void (record_line_ftype) (struct subfile *subfile, int line,
 				  CORE_ADDR pc);
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 5c97e7b949..2e5bf9bcab 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -383,6 +383,7 @@ coff_alloc_type (int index)
 static void
 coff_start_symtab (struct objfile *objfile, const char *name)
 {
+  within_function = 0;
   start_symtab (objfile,
   /* We fill in the filename later.  start_symtab puts this pointer
      into last_source_file and we put it in subfiles->name, which
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 13663106dc..bb50a16829 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -4783,6 +4783,7 @@ start_stabs (void)
   n_this_object_header_files = 1;
   type_vector_length = 0;
   type_vector = (struct type **) 0;
+  within_function = 0;
 
   /* FIXME: If common_block_name is not already NULL, we should complain().  */
   common_block_name = NULL;
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index fdb404a25d..ce254e65d0 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -51,6 +51,11 @@ EXTERN const char *(*next_symbol_text_func) (struct objfile *);
 
 EXTERN unsigned char processing_gcc_compilation;
 
+/* Nonzero if within a function (so symbols should be local, if
+   nothing says specifically).  */
+
+EXTERN int within_function;
+
 /* Hash table of global symbols whose values are not known yet.
    They are chained thru the SYMBOL_VALUE_CHAIN, since we don't
    have the correct data for that slot yet.
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 15/42] Remove merge_symbol_lists
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (2 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 04/42] Move last_source file to buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:54   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 22/42] Move current_subfile to buildsym_compunit Tom Tromey
                   ` (39 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I discovered that merge_symbol_lists is unused, so this removes it.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.h (merge_symbol_lists): Remove.
	* buildsym.c (merge_symbol_lists): Remove.
---
 gdb/ChangeLog  |  5 +++++
 gdb/buildsym.c | 27 ---------------------------
 gdb/buildsym.h |  3 ---
 3 files changed, 5 insertions(+), 30 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 6fe413be8a..4744d510c3 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1685,33 +1685,6 @@ record_producer (const char *producer)
   buildsym_compunit->producer = producer;
 }
 
-/* Merge the first symbol list SRCLIST into the second symbol list
-   TARGETLIST by repeated calls to add_symbol_to_list().  This
-   procedure "frees" each link of SRCLIST by adding it to the
-   free_pendings list.  Caller must set SRCLIST to a null list after
-   calling this function.
-
-   Void return.  */
-
-void
-merge_symbol_lists (struct pending **srclist, struct pending **targetlist)
-{
-  int i;
-
-  if (!srclist || !*srclist)
-    return;
-
-  /* Merge in elements from current link.  */
-  for (i = 0; i < (*srclist)->nsyms; i++)
-    add_symbol_to_list ((*srclist)->symbol[i], targetlist);
-
-  /* Recurse on next.  */
-  merge_symbol_lists (&(*srclist)->next, targetlist);
-
-  /* "Free" the current link.  */
-  (*srclist)->next = free_pendings;
-  free_pendings = (*srclist);
-}
 \f
 
 /* See buildsym.h.  */
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index f70777946a..d0943456cd 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -236,9 +236,6 @@ extern void record_debugformat (const char *format);
 
 extern void record_producer (const char *producer);
 
-extern void merge_symbol_lists (struct pending **srclist,
-				struct pending **targetlist);
-
 /* Set the name of the last source file.  NAME is copied by this
    function.  */
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 25/42] Remove the "listhead" argument from finish_block
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (5 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 27/42] Do not look at file symbols when reading psymtabs Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-10  2:07   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 13/42] Remove buildsym_new_init Tom Tromey
                   ` (36 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

finish_block is only ever called with "&local_symbols" as the
"listhead" argument.  So, remove this argument.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab): Update.
	* dwarf2read.c (read_func_scope, read_lexical_block_scope):
	Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read): Update.
	* buildsym.h (finish_block): Update.
	* buildsym.c (finish_block): Remove "listhead" argument.
	(end_symtab_get_static_block): Update.
---
 gdb/ChangeLog    | 11 +++++++++++
 gdb/buildsym.c   |  5 ++---
 gdb/buildsym.h   |  1 -
 gdb/coffread.c   |  4 ++--
 gdb/dbxread.c    |  6 +++---
 gdb/dwarf2read.c |  4 ++--
 gdb/xcoffread.c  |  4 ++--
 7 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 3f367a3b55..516dac6b7e 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -586,12 +586,11 @@ finish_block_internal (struct symbol *symbol,
 
 struct block *
 finish_block (struct symbol *symbol,
-	      struct pending **listhead,
 	      struct pending_block *old_blocks,
 	      const struct dynamic_prop *static_link,
 	      CORE_ADDR start, CORE_ADDR end)
 {
-  return finish_block_internal (symbol, listhead, old_blocks, static_link,
+  return finish_block_internal (symbol, &local_symbols, old_blocks, static_link,
 				start, end, 0, 0);
 }
 
@@ -1206,7 +1205,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
       struct context_stack *cstk = pop_context ();
 
       /* Make a block for the local symbols within.  */
-      finish_block (cstk->name, &local_symbols, cstk->old_blocks, NULL,
+      finish_block (cstk->name, cstk->old_blocks, NULL,
 		    cstk->start_addr, end_addr);
 
       if (!buildsym_compunit->m_context_stack.empty ())
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index ad56ac597f..969afbc828 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -144,7 +144,6 @@ extern struct symbol *find_symbol_in_list (struct pending *list,
 					   char *name, int length);
 
 extern struct block *finish_block (struct symbol *symbol,
-				   struct pending **listhead,
 				   struct pending_block *old_blocks,
 				   const struct dynamic_prop *static_link,
 				   CORE_ADDR start,
diff --git a/gdb/coffread.c b/gdb/coffread.c
index a8e3f59a65..71b6ed9995 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1139,7 +1139,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 		enter_linenos (fcn_line_ptr, fcn_first_line,
 			       fcn_last_line, objfile);
 
-	      finish_block (newobj->name, &local_symbols, newobj->old_blocks,
+	      finish_block (newobj->name, newobj->old_blocks,
 			    NULL, newobj->start_addr,
 			    fcn_cs_saved.c_value
 			    + fcn_aux_saved.x_sym.x_misc.x_fsize
@@ -1183,7 +1183,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 		    cs->c_value + ANOFFSET (objfile->section_offsets,
 					    SECT_OFF_TEXT (objfile));
 		  /* Make a block for the local symbols within.  */
-		  finish_block (0, &local_symbols, newobj->old_blocks, NULL,
+		  finish_block (0, newobj->old_blocks, NULL,
 				newobj->start_addr, tmpaddr);
 		}
 	      /* Now pop locals of block just finished.  */
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 713178809b..b6a44e245e 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2579,7 +2579,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	  newobj = pop_context ();
 
 	  /* Make a block for the local symbols within.  */
-	  block = finish_block (newobj->name, &local_symbols,
+	  block = finish_block (newobj->name,
 				newobj->old_blocks, NULL,
 				newobj->start_addr, newobj->start_addr + valu);
 
@@ -2668,7 +2668,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 		  newobj->start_addr = valu;
 		}
 	      /* Make a block for the local symbols within.  */
-	      finish_block (0, &local_symbols, newobj->old_blocks, NULL,
+	      finish_block (0, newobj->old_blocks, NULL,
 			    newobj->start_addr, valu);
 	    }
 	}
@@ -2956,7 +2956,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 
 		  newobj = pop_context ();
 		  /* Make a block for the local symbols within.  */
-		  block = finish_block (newobj->name, &local_symbols,
+		  block = finish_block (newobj->name,
 					newobj->old_blocks, NULL,
 					newobj->start_addr, valu);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 131dcfbb55..ffea27c064 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -13734,7 +13734,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 
   newobj = pop_context ();
   /* Make a block for the local symbols within.  */
-  block = finish_block (newobj->name, &local_symbols, newobj->old_blocks,
+  block = finish_block (newobj->name, newobj->old_blocks,
 			newobj->static_link, lowpc, highpc);
 
   /* For C++, set the block's scope.  */
@@ -13831,7 +13831,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
   if (local_symbols != NULL || (*get_local_using_directives ()) != NULL)
     {
       struct block *block
-        = finish_block (0, &local_symbols, newobj->old_blocks, NULL,
+        = finish_block (0, newobj->old_blocks, NULL,
 			newobj->start_addr, highpc);
 
       /* Note that recording ranges after traversing children, as we
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index af03c11e8b..73e0638412 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1412,7 +1412,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 		  break;
 		}
 
-	      finish_block (newobj->name, &local_symbols, newobj->old_blocks,
+	      finish_block (newobj->name, newobj->old_blocks,
 			    NULL, newobj->start_addr,
 			    (fcn_cs_saved.c_value
 			     + fcn_aux_saved.x_sym.x_misc.x_fsize
@@ -1504,7 +1504,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 	      if (local_symbols && !outermost_context_p ())
 		{
 		  /* Make a block for the local symbols within.  */
-		  finish_block (newobj->name, &local_symbols,
+		  finish_block (newobj->name,
 				newobj->old_blocks, NULL,
 				newobj->start_addr,
 				(cs->c_value
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 23/42] Move pending addrmap globals to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (12 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 06/42] Move have_line_numbers to buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-10  1:56   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 03/42] Add assert in prepare_for_building Tom Tromey
                   ` (29 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the pending addrmap-related globals into buildsym_compunit.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (struct buildsym_compunit) <m_pending_addrmap,
	m_pending_addrmap_obstack, m_pending_addrmap_interesting>: New
	members.
	(pending_addrmap, pending_addrmap_obstack)
	(pending_addrmap_interesting): Remove.
	(scoped_free_pendings, record_block_range, make_blockvector)
	(prepare_for_building, reset_symtab_globals, buildsym_init):
	Update.
---
 gdb/ChangeLog  | 11 ++++++++++
 gdb/buildsym.c | 63 ++++++++++++++++++++++++----------------------------------
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 4f820f5dc5..179810f463 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -218,6 +218,22 @@ struct buildsym_compunit
   struct context_stack m_popped_context {};
 
   struct subfile *m_current_subfile = nullptr;
+
+  /* The mutable address map for the compilation unit whose symbols
+     we're currently reading.  The symtabs' shared blockvector will
+     point to a fixed copy of this.  */
+  struct addrmap *m_pending_addrmap = nullptr;
+
+  /* The obstack on which we allocate pending_addrmap.
+     If pending_addrmap is NULL, this is uninitialized; otherwise, it is
+     initialized (and holds pending_addrmap).  */
+  auto_obstack m_pending_addrmap_obstack;
+
+  /* True if we recorded any ranges in the addrmap that are different
+     from those in the blockvector already.  We set this to false when
+     we start processing a symfile, and if it's still false at the
+     end, then we just toss the addrmap.  */
+  bool m_pending_addrmap_interesting = false;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -229,22 +245,6 @@ static struct buildsym_compunit *buildsym_compunit;
 
 static struct pending *free_pendings;
 
-/* The mutable address map for the compilation unit whose symbols
-   we're currently reading.  The symtabs' shared blockvector will
-   point to a fixed copy of this.  */
-static struct addrmap *pending_addrmap;
-
-/* The obstack on which we allocate pending_addrmap.
-   If pending_addrmap is NULL, this is uninitialized; otherwise, it is
-   initialized (and holds pending_addrmap).  */
-static struct obstack pending_addrmap_obstack;
-
-/* Non-zero if we recorded any ranges in the addrmap that are
-   different from those in the blockvector already.  We set this to
-   zero when we start processing a symfile, and if it's still zero at
-   the end, then we just toss the addrmap.  */
-static int pending_addrmap_interesting;
-
 /* An obstack used for allocating pending blocks.  */
 
 static struct obstack pending_block_obstack;
@@ -380,10 +380,6 @@ scoped_free_pendings::~scoped_free_pendings ()
     }
   global_symbols = NULL;
 
-  if (pending_addrmap)
-    obstack_free (&pending_addrmap_obstack, NULL);
-  pending_addrmap = NULL;
-
   free_buildsym_compunit ();
 }
 
@@ -660,15 +656,14 @@ record_block_range (struct block *block,
      need to record this block in the addrmap.  */
   if (start != BLOCK_START (block)
       || end_inclusive + 1 != BLOCK_END (block))
-    pending_addrmap_interesting = 1;
+    buildsym_compunit->m_pending_addrmap_interesting = true;
 
-  if (! pending_addrmap)
-    {
-      obstack_init (&pending_addrmap_obstack);
-      pending_addrmap = addrmap_create_mutable (&pending_addrmap_obstack);
-    }
+  if (! buildsym_compunit->m_pending_addrmap)
+    buildsym_compunit->m_pending_addrmap
+      = addrmap_create_mutable (&buildsym_compunit->m_pending_addrmap_obstack);
 
-  addrmap_set_empty (pending_addrmap, start, end_inclusive, block);
+  addrmap_set_empty (buildsym_compunit->m_pending_addrmap,
+		     start, end_inclusive, block);
 }
 
 static struct blockvector *
@@ -706,9 +701,11 @@ make_blockvector (void)
 
   /* If we needed an address map for this symtab, record it in the
      blockvector.  */
-  if (pending_addrmap && pending_addrmap_interesting)
+  if (buildsym_compunit->m_pending_addrmap
+      && buildsym_compunit->m_pending_addrmap_interesting)
     BLOCKVECTOR_MAP (blockvector)
-      = addrmap_create_fixed (pending_addrmap, &objfile->objfile_obstack);
+      = addrmap_create_fixed (buildsym_compunit->m_pending_addrmap,
+			      &objfile->objfile_obstack);
   else
     BLOCKVECTOR_MAP (blockvector) = 0;
 
@@ -1037,7 +1034,6 @@ prepare_for_building ()
      a symtab, or by the scoped_free_pendings destructor.  */
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
-  gdb_assert (pending_addrmap == NULL);
   gdb_assert (buildsym_compunit == nullptr);
 }
 
@@ -1191,10 +1187,6 @@ reset_symtab_globals (void)
   file_symbols = NULL;
   global_symbols = NULL;
 
-  if (pending_addrmap)
-    obstack_free (&pending_addrmap_obstack, NULL);
-  pending_addrmap = NULL;
-
   free_buildsym_compunit ();
 }
 
@@ -1785,14 +1777,11 @@ get_current_subfile ()
 void
 buildsym_init ()
 {
-  pending_addrmap_interesting = 0;
-
   /* Ensure the scoped_free_pendings destructor was called after
      the last time.  */
   gdb_assert (free_pendings == NULL);
   gdb_assert (pending_blocks == NULL);
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
-  gdb_assert (pending_addrmap == NULL);
   gdb_assert (buildsym_compunit == NULL);
 }
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 18/42] Make free_pending_blocks static
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (10 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 26/42] Remove free_pendings Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 17:04   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 06/42] Move have_line_numbers to buildsym_compunit Tom Tromey
                   ` (31 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

free_pending_blocks can be static because scoped_free_pendings (et al)
arrange for it to be NULL in the "steady state".  This removes a
couple of unnecessary calls to free_pending_blocks and changes it to
be static.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Don't call
	free_pending_blocks.
	* dbxread.c (dbx_symfile_read): Don't call free_pending_blocks.
	* buildsym.h (class scoped_free_pendings): Add constructor.
	(free_pending_blocks): Don't declare.
	* buildsym.c (scoped_free_pendings::scoped_free_pendings): New.
	(free_pending_blocks): Now static.
---
 gdb/ChangeLog   | 10 ++++++++++
 gdb/buildsym.c  | 11 +++++++++--
 gdb/buildsym.h  |  4 +---
 gdb/dbxread.c   |  1 -
 gdb/xcoffread.c |  2 --
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index f828fceb72..5d3d1f2942 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -264,6 +264,8 @@ static void record_pending_block (struct objfile *objfile,
 				  struct block *block,
 				  struct pending_block *opblock);
 
+static void free_pending_blocks ();
+
 /* Initial sizes of data structures.  These are realloc'd larger if
    needed, and realloc'd down to the size actually used, when
    completed.  */
@@ -332,6 +334,11 @@ find_symbol_in_list (struct pending *list, char *name, int length)
   return (NULL);
 }
 
+scoped_free_pendings::scoped_free_pendings ()
+{
+  gdb_assert (pending_blocks == nullptr);
+}
+
 /* At end of reading syms, or in case of quit, ensure everything
    associated with building symtabs is freed.
 
@@ -374,8 +381,8 @@ scoped_free_pendings::~scoped_free_pendings ()
 
 /* This function is called to discard any pending blocks.  */
 
-void
-free_pending_blocks (void)
+static void
+free_pending_blocks ()
 {
   if (pending_blocks != NULL)
     {
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index b5ea63d3f4..512d926dcb 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -176,7 +176,7 @@ class scoped_free_pendings
 {
 public:
 
-  scoped_free_pendings () = default;
+  scoped_free_pendings ();
   ~scoped_free_pendings ();
 
   DISABLE_COPY_AND_ASSIGN (scoped_free_pendings);
@@ -222,8 +222,6 @@ extern struct compunit_symtab *start_symtab (struct objfile *objfile,
 extern void restart_symtab (struct compunit_symtab *cust,
 			    const char *name, CORE_ADDR start_addr);
 
-extern void free_pending_blocks (void);
-
 /* Record the name of the debug format in the current pending symbol
    table.  FORMAT must be a string with a lifetime at least as long as
    the symtab's objfile.  */
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 52241f620d..127ae5bdf8 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -546,7 +546,6 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   symbol_size = DBX_SYMBOL_SIZE (objfile);
   symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);
 
-  free_pending_blocks ();
   scoped_free_pendings free_pending;
 
   minimal_symbol_reader reader (objfile);
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index e9bb79c87a..21d107f78d 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -3028,8 +3028,6 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
        include N_SLINE.  */
     init_psymbol_list (objfile, num_symbols);
 
-  free_pending_blocks ();
-
   scoped_free_pendings free_pending;
   minimal_symbol_reader reader (objfile);
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 10/42] Move some code from buildsym to stabsread
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (19 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 20/42] Use outermost_context_p in more places Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-05 19:16   ` Keith Seitz
  2018-05-23  4:59 ` [RFA 28/42] Set list_in_scope later in DWARF reader Tom Tromey
                   ` (22 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A few things that currently reside in buildsym.c turn out to be
specific to the stabs reader.  This patch moves these from
buildsym.[ch] to stabsread.[ch].

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* stabsread.h (HASHSIZE, hashname, symnum, next_symbol_text)
	(next_symbol_text_func): Move from buildsym.h.
	* stabsread.c (hashname): Move from buildsym.c.
	* buildsym.h (HASHSIZE, symnum, next_symbol_text)
	(next_symbol_text_func, hashname): Move to stabsread.h.
	* buildsym.c: Don't include bcache.h
	(hashname): Move to stasbread.c.
---
 gdb/ChangeLog   | 10 ++++++++++
 gdb/buildsym.c  | 10 ----------
 gdb/buildsym.h  | 15 ---------------
 gdb/stabsread.c | 13 +++++++++++++
 gdb/stabsread.h | 15 +++++++++++++++
 5 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 85b450383e..0e69865886 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -74,7 +74,6 @@
 #include "gdbtypes.h"
 #include "complaints.h"
 #include "expression.h"		/* For "enum exp_opcode" used by...  */
-#include "bcache.h"
 #include "filenames.h"		/* For DOSish file names.  */
 #include "macrotab.h"
 #include "demangle.h"		/* Needed by SYMBOL_INIT_DEMANGLED_NAME.  */
@@ -1675,15 +1674,6 @@ pop_context (void)
 
 \f
 
-/* Compute a small integer hash code for the given name.  */
-
-int
-hashname (const char *name)
-{
-    return (hash(name,strlen(name)) % HASHSIZE);
-}
-\f
-
 void
 record_debugformat (const char *format)
 {
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 191db8ca4f..0b19c39305 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -46,9 +46,6 @@ struct dynamic_prop;
 #define	EXTERN extern
 #endif
 
-#define HASHSIZE 127		/* Size of things hashed via
-				   hashname().  */
-
 /* The list of sub-source-files within the current individual
    compilation.  Each file gets its own symtab with its own linetable
    and associated info, but they all share one blockvector.  */
@@ -74,10 +71,6 @@ EXTERN struct subfile *current_subfile;
 
 EXTERN unsigned char processing_gcc_compilation;
 
-/* Count symbols as they are processed, for error messages.  */
-
-EXTERN unsigned int symnum;
-
 /* Record the symbols defined for each context in a list.  We don't
    create a struct block for the context until we know how long to
    make it.  */
@@ -173,12 +166,6 @@ typedef void (record_line_ftype) (struct subfile *subfile, int line,
 
 \f
 
-#define next_symbol_text(objfile) (*next_symbol_text_func)(objfile)
-
-/* Function to invoke get the next symbol.  Return the symbol name.  */
-
-EXTERN const char *(*next_symbol_text_func) (struct objfile *);
-
 extern void add_symbol_to_list (struct symbol *symbol,
 				struct pending **listhead);
 
@@ -251,8 +238,6 @@ extern struct compunit_symtab *start_symtab (struct objfile *objfile,
 extern void restart_symtab (struct compunit_symtab *cust,
 			    const char *name, CORE_ADDR start_addr);
 
-extern int hashname (const char *name);
-
 extern void free_pending_blocks (void);
 
 /* Record the name of the debug format in the current pending symbol
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 4cfefaa3e0..13663106dc 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -44,6 +44,7 @@
 #include "target-float.h"
 #include "cp-abi.h"
 #include "cp-support.h"
+#include "bcache.h"
 #include <ctype.h>
 
 /* Ask stabsread.h to define the vars it normally declares `extern'.  */
@@ -4839,6 +4840,18 @@ find_name_end (const char *name)
     }
 }
 
+\f
+
+/* Compute a small integer hash code for the given name.  */
+
+int
+hashname (const char *name)
+{
+  return hash (name, strlen (name)) % HASHSIZE;
+}
+
+\f
+
 /* Initializer for this module.  */
 
 void
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index d24b25dc72..7958990112 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -31,6 +31,21 @@ enum language;
 #define	EXTERN extern
 #endif
 
+#define HASHSIZE 127		/* Size of things hashed via
+				   hashname().  */
+
+extern int hashname (const char *name);
+
+/* Count symbols as they are processed, for error messages.  */
+
+EXTERN unsigned int symnum;
+
+#define next_symbol_text(objfile) (*next_symbol_text_func)(objfile)
+
+/* Function to invoke get the next symbol.  Return the symbol name.  */
+
+EXTERN const char *(*next_symbol_text_func) (struct objfile *);
+
 /* Hash table of global symbols whose values are not known yet.
    They are chained thru the SYMBOL_VALUE_CHAIN, since we don't
    have the correct data for that slot yet.
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 09/42] Make context_stack_size static in buildsym.c
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (15 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 08/42] Move processing_acc_compilation to dbxread.c Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-08 16:16   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 16/42] Use gdb_assert in two places " Tom Tromey
                   ` (26 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

context_stack_size is declared in buildsym.h, but only used in
buildsym.c.  This makes it static in buildsym.c.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.h (context_stack_size): Don't declare.
	* buildsym.c (context_stack_size): New global.
---
 gdb/ChangeLog  | 5 +++++
 gdb/buildsym.c | 4 ++++
 gdb/buildsym.h | 4 ----
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 583c294790..85b450383e 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -258,6 +258,10 @@ struct subfile_stack
 
 static struct subfile_stack *subfile_stack;
 
+/* Currently allocated size of context stack.  */
+
+static int context_stack_size;
+
 static void free_buildsym_compunit (void);
 
 static int compare_line_numbers (const void *ln1p, const void *ln2p);
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 088c1d790e..191db8ca4f 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -159,10 +159,6 @@ EXTERN struct context_stack *context_stack;
 
 EXTERN int context_stack_depth;
 
-/* Currently allocated size of context stack.  */
-
-EXTERN int context_stack_size;
-
 /* Non-zero if the context stack is empty.  */
 #define outermost_context_p() (context_stack_depth == 0)
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 03/42] Add assert in prepare_for_building
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (13 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 23/42] Move pending addrmap globals " Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-07 14:06   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 08/42] Move processing_acc_compilation to dbxread.c Tom Tromey
                   ` (28 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds an assertion in prepare_for_building.  This was useful for
verifying whether some subsequent changes were valid.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (prepare_for_building): Add assert.
---
 gdb/ChangeLog  | 4 ++++
 gdb/buildsym.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b747a082b5..9e0c39a4a4 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1025,6 +1025,7 @@ prepare_for_building (const char *name, CORE_ADDR start_addr)
   gdb_assert (pending_macros == NULL);
   gdb_assert (pending_addrmap == NULL);
   gdb_assert (current_subfile == NULL);
+  gdb_assert (buildsym_compunit == nullptr);
 }
 
 /* Start a new symtab for a new source file in OBJFILE.  Called, for example,
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 21/42] Move the context stack to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (23 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 14/42] Move scan_file_globals declaration to stabsread.h Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-06 17:30   ` Keith Seitz
       [not found]   ` <93a9597f-e7ff-e8ff-e873-9cee5b84d7cc@simark.ca>
  2018-05-23  4:59 ` [RFA 01/42] Use new and delete for buildsym_compunit Tom Tromey
                   ` (18 subsequent siblings)
  43 siblings, 2 replies; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the context stack globals to be members of
buildsym_compunit, changing the type to a std::vector in the process.

Note that the context stack works in a somewhat odd way, where callers
can pop the stack and expect the returned pointer to remain valid
until the next pop.  In the new code we handle this by having a
"popped context" object that remains valid in this way.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (new_symbol): Update.
	* dbxread.c (process_one_symbol): Update.
	* buildsym.h (context_stack, context_stack_depth): Don't declare.
	(outermost_context_p): Remove macro.
	(outermost_context_p, get_current_context_stack)
	(get_context_stack_depth): Declare.
	* buildsym.c (struct buildsym_compunit) <m_context_stack,
	m_popped_context>: New members.
	(context_stack_size): Remove.
	(INITIAL_CONTEXT_STACK_SIZE): Remove.
	(prepare_for_building, end_symtab_get_static_block)
	(augment_type_symtab, push_context, pop_context): Update.
	(outermost_context_p, get_current_context_stack)
	(get_context_stack_depth): New functions.
	(buildsym_init): Update.
---
 gdb/ChangeLog    | 18 +++++++++++++
 gdb/buildsym.c   | 82 ++++++++++++++++++++++++++++++++------------------------
 gdb/buildsym.h   | 22 ++++++++-------
 gdb/dbxread.c    |  4 +--
 gdb/dwarf2read.c | 40 ++++++++++++++-------------
 5 files changed, 101 insertions(+), 65 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 4e3ca5e4b1..54592b7795 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -213,6 +213,9 @@ struct buildsym_compunit
   /* global "using" directives.  */
 
   struct using_direct *m_global_using_directives = nullptr;
+
+  std::vector<struct context_stack> m_context_stack;
+  struct context_stack m_popped_context {};
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -260,10 +263,6 @@ struct pending_block
 
 static struct pending_block *pending_blocks;
 
-/* Currently allocated size of context stack.  */
-
-static int context_stack_size;
-
 static void free_buildsym_compunit (void);
 
 static int compare_line_numbers (const void *ln1p, const void *ln2p);
@@ -278,7 +277,6 @@ static void free_pending_blocks ();
    needed, and realloc'd down to the size actually used, when
    completed.  */
 
-#define	INITIAL_CONTEXT_STACK_SIZE	10
 #define	INITIAL_LINE_VECTOR_LENGTH	1000
 \f
 
@@ -1032,8 +1030,6 @@ prepare_for_building ()
 {
   local_symbols = NULL;
 
-  context_stack_depth = 0;
-
   /* These should have been reset either by successful completion of building
      a symtab, or by the scoped_free_pendings destructor.  */
   gdb_assert (file_symbols == NULL);
@@ -1222,7 +1218,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
   /* Finish the lexical context of the last function in the file; pop
      the context stack.  */
 
-  if (context_stack_depth > 0)
+  if (!buildsym_compunit->m_context_stack.empty ())
     {
       struct context_stack *cstk = pop_context ();
 
@@ -1230,7 +1226,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
       finish_block (cstk->name, &local_symbols, cstk->old_blocks, NULL,
 		    cstk->start_addr, end_addr);
 
-      if (context_stack_depth > 0)
+      if (!buildsym_compunit->m_context_stack.empty ())
 	{
 	  /* This is said to happen with SCO.  The old coffread.c
 	     code simply emptied the context stack, so we do the
@@ -1239,7 +1235,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
 	     it used to be an abort().  */
 	  complaint (&symfile_complaints,
 	             _("Context stack not empty in end_symtab"));
-	  context_stack_depth = 0;
+	  buildsym_compunit->m_context_stack.clear ();
 	}
     }
 
@@ -1583,12 +1579,9 @@ augment_type_symtab (void)
   struct compunit_symtab *cust = buildsym_compunit->compunit_symtab;
   const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
 
-  if (context_stack_depth > 0)
-    {
-      complaint (&symfile_complaints,
-		 _("Context stack not empty in augment_type_symtab"));
-      context_stack_depth = 0;
-    }
+  if (!buildsym_compunit->m_context_stack.empty ())
+    complaint (&symfile_complaints,
+	       _("Context stack not empty in augment_type_symtab"));
   if (pending_blocks != NULL)
     complaint (&symfile_complaints, _("Blocks in a type symtab"));
   if (buildsym_compunit->m_pending_macros != NULL)
@@ -1629,17 +1622,11 @@ augment_type_symtab (void)
 struct context_stack *
 push_context (int desc, CORE_ADDR valu)
 {
-  struct context_stack *newobj;
+  gdb_assert (buildsym_compunit != nullptr);
 
-  if (context_stack_depth == context_stack_size)
-    {
-      context_stack_size *= 2;
-      context_stack = (struct context_stack *)
-	xrealloc ((char *) context_stack,
-		  (context_stack_size * sizeof (struct context_stack)));
-    }
+  buildsym_compunit->m_context_stack.emplace_back ();
+  struct context_stack *newobj = &buildsym_compunit->m_context_stack.back ();
 
-  newobj = &context_stack[context_stack_depth++];
   newobj->depth = desc;
   newobj->locals = local_symbols;
   newobj->old_blocks = pending_blocks;
@@ -1660,8 +1647,12 @@ push_context (int desc, CORE_ADDR valu)
 struct context_stack *
 pop_context (void)
 {
-  gdb_assert (context_stack_depth > 0);
-  return (&context_stack[--context_stack_depth]);
+  gdb_assert (buildsym_compunit != nullptr);
+  gdb_assert (!buildsym_compunit->m_context_stack.empty ());
+  buildsym_compunit->m_popped_context
+    = buildsym_compunit->m_context_stack.back ();
+  buildsym_compunit->m_context_stack.pop_back ();
+  return &buildsym_compunit->m_popped_context;
 }
 
 \f
@@ -1745,6 +1736,35 @@ get_global_using_directives ()
   return &buildsym_compunit->m_global_using_directives;
 }
 
+/* See buildsym.h.  */
+
+bool
+outermost_context_p ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->m_context_stack.empty ();
+}
+
+/* See buildsym.h.  */
+
+struct context_stack *
+get_current_context_stack ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  if (buildsym_compunit->m_context_stack.empty ())
+    return nullptr;
+  return &buildsym_compunit->m_context_stack.back ();
+}
+
+/* See buildsym.h.  */
+
+int
+get_context_stack_depth ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->m_context_stack.size ();
+}
+
 \f
 
 /* Initialize anything that needs initializing when starting to read a
@@ -1756,14 +1776,6 @@ buildsym_init ()
 {
   pending_addrmap_interesting = 0;
 
-  /* Context stack is initially empty.  Allocate first one with room
-     for a few levels; reuse it forever afterward.  */
-  if (context_stack == NULL)
-    {
-      context_stack_size = INITIAL_CONTEXT_STACK_SIZE;
-      context_stack = XNEWVEC (struct context_stack, context_stack_size);
-    }
-
   /* Ensure the scoped_free_pendings destructor was called after
      the last time.  */
   gdb_assert (free_pendings == NULL);
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index efb35c907b..fe158d183c 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -133,15 +133,6 @@ struct context_stack
 
   };
 
-EXTERN struct context_stack *context_stack;
-
-/* Index of first unused entry in context stack.  */
-
-EXTERN int context_stack_depth;
-
-/* Non-zero if the context stack is empty.  */
-#define outermost_context_p() (context_stack_depth == 0)
-
 /* The type of the record_line function.  */
 typedef void (record_line_ftype) (struct subfile *subfile, int line,
 				  CORE_ADDR pc);
@@ -270,6 +261,19 @@ extern void set_local_using_directives (struct using_direct *new_local);
 
 extern struct using_direct **get_global_using_directives ();
 
+/* Non-zero if the context stack is empty.  */
+
+extern bool outermost_context_p ();
+
+/* Return the top of the context stack, or nullptr if there is
+   entry.  */
+
+extern struct context_stack *get_current_context_stack ();
+
+/* Return the context stack depth.  */
+
+extern int get_context_stack_depth ();
+
 #undef EXTERN
 
 #endif /* defined (BUILDSYM_H) */
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index ed6e6be458..fe7f4a2815 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2648,7 +2648,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	}
       local_symbols = newobj->locals;
 
-      if (context_stack_depth > 1)
+      if (get_context_stack_depth () > 1)
 	{
 	  /* This is not the outermost LBRAC...RBRAC pair in the
 	     function, its local symbols preceded it, and are the ones
@@ -2942,7 +2942,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 
 	      within_function = 1;
 
-	      if (context_stack_depth > 1)
+	      if (get_context_stack_depth () > 1)
 		{
 		  complaint (&symfile_complaints,
 			     _("unmatched N_LBRAC before symtab pos %d"),
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b39c14365a..354ff920e5 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -21467,26 +21467,28 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	    }
 	  break;
 	case DW_TAG_formal_parameter:
-	  /* If we are inside a function, mark this as an argument.  If
-	     not, we might be looking at an argument to an inlined function
-	     when we do not have enough information to show inlined frames;
-	     pretend it's a local variable in that case so that the user can
-	     still see it.  */
-	  if (!outermost_context_p ()
-	      && context_stack[context_stack_depth - 1].name != NULL)
-	    SYMBOL_IS_ARGUMENT (sym) = 1;
-	  attr = dwarf2_attr (die, DW_AT_location, cu);
-	  if (attr)
-	    {
-	      var_decode_location (attr, sym, cu);
-	    }
-	  attr = dwarf2_attr (die, DW_AT_const_value, cu);
-	  if (attr)
-	    {
-	      dwarf2_const_value (attr, sym, cu);
-	    }
+	  {
+	    /* If we are inside a function, mark this as an argument.  If
+	       not, we might be looking at an argument to an inlined function
+	       when we do not have enough information to show inlined frames;
+	       pretend it's a local variable in that case so that the user can
+	       still see it.  */
+	    struct context_stack *curr = get_current_context_stack ();
+	    if (curr != nullptr && curr->name != nullptr)
+	      SYMBOL_IS_ARGUMENT (sym) = 1;
+	    attr = dwarf2_attr (die, DW_AT_location, cu);
+	    if (attr)
+	      {
+		var_decode_location (attr, sym, cu);
+	      }
+	    attr = dwarf2_attr (die, DW_AT_const_value, cu);
+	    if (attr)
+	      {
+		dwarf2_const_value (attr, sym, cu);
+	      }
 
-	  list_to_add = cu->list_in_scope;
+	    list_to_add = cu->list_in_scope;
+	  }
 	  break;
 	case DW_TAG_unspecified_parameters:
 	  /* From varargs functions; gdb doesn't seem to have any
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 01/42] Use new and delete for buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (24 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 21/42] Move the context stack to buildsym_compunit Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-05 18:50   ` Keith Seitz
  2018-05-23  4:59 ` [RFA 12/42] Move within_function to stabsread Tom Tromey
                   ` (17 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes buildsym_compunit to use new and delete.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (struct buildsym_compunit): Add constructor,
	destructor, initializers.
	(start_buildsym_compunit): Remove.
	(free_buildsym_compunit): Use "delete".
	(start_symtab, restart_symtab): Use "new".
---
 gdb/ChangeLog  |  8 ++++++
 gdb/buildsym.c | 91 ++++++++++++++++++++++++++--------------------------------
 2 files changed, 49 insertions(+), 50 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 5d38cb250f..9863e4ea1e 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -100,6 +100,35 @@
 
 struct buildsym_compunit
 {
+  /* Start recording information about a primary source file (IOW, not an
+     included source file).
+     COMP_DIR is the directory in which the compilation unit was compiled
+     (or NULL if not known).  */
+
+  buildsym_compunit (struct objfile *objfile_, const char *comp_dir_,
+		     enum language language_)
+    : objfile (objfile_),
+      comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
+      language (language_)
+  {
+  }
+
+  ~buildsym_compunit ()
+  {
+    struct subfile *subfile, *nextsub;
+
+    for (subfile = subfiles;
+	 subfile != NULL;
+	 subfile = nextsub)
+      {
+	nextsub = subfile->next;
+	xfree (subfile->name);
+	xfree (subfile->line_vector);
+	xfree (subfile);
+      }
+    xfree (comp_dir);
+  }
+
   /* The objfile we're reading debug info from.  */
   struct objfile *objfile;
 
@@ -107,24 +136,24 @@ struct buildsym_compunit
      Files are added to the front of the list.
      This is important mostly for the language determination hacks we use,
      which iterate over previously added files.  */
-  struct subfile *subfiles;
+  struct subfile *subfiles = nullptr;
 
   /* The subfile of the main source file.  */
-  struct subfile *main_subfile;
+  struct subfile *main_subfile = nullptr;
 
   /* E.g., DW_AT_comp_dir if DWARF.  Space for this is malloc'd.  */
   char *comp_dir;
 
   /* Space for this is not malloc'd, and is assumed to have at least
      the same lifetime as objfile.  */
-  const char *producer;
+  const char *producer = nullptr;
 
   /* Space for this is not malloc'd, and is assumed to have at least
      the same lifetime as objfile.  */
-  const char *debugformat;
+  const char *debugformat = nullptr;
 
   /* The compunit we are building.  */
-  struct compunit_symtab *compunit_symtab;
+  struct compunit_symtab *compunit_symtab = nullptr;
 
   /* Language of this compunit_symtab.  */
   enum language language;
@@ -763,54 +792,14 @@ start_subfile (const char *name)
     }
 }
 
-/* Start recording information about a primary source file (IOW, not an
-   included source file).
-   COMP_DIR is the directory in which the compilation unit was compiled
-   (or NULL if not known).  */
-
-static struct buildsym_compunit *
-start_buildsym_compunit (struct objfile *objfile, const char *comp_dir,
-			 enum language language)
-{
-  struct buildsym_compunit *bscu;
-
-  bscu = XNEW (struct buildsym_compunit);
-  memset (bscu, 0, sizeof (struct buildsym_compunit));
-
-  bscu->objfile = objfile;
-  bscu->comp_dir = (comp_dir == NULL) ? NULL : xstrdup (comp_dir);
-  bscu->language = language;
-
-  /* Initialize the debug format string to NULL.  We may supply it
-     later via a call to record_debugformat.  */
-  bscu->debugformat = NULL;
-
-  /* Similarly for the producer.  */
-  bscu->producer = NULL;
-
-  return bscu;
-}
-
 /* Delete the buildsym compunit.  */
 
 static void
 free_buildsym_compunit (void)
 {
-  struct subfile *subfile, *nextsub;
-
   if (buildsym_compunit == NULL)
     return;
-  for (subfile = buildsym_compunit->subfiles;
-       subfile != NULL;
-       subfile = nextsub)
-    {
-      nextsub = subfile->next;
-      xfree (subfile->name);
-      xfree (subfile->line_vector);
-      xfree (subfile);
-    }
-  xfree (buildsym_compunit->comp_dir);
-  xfree (buildsym_compunit);
+  delete buildsym_compunit;
   buildsym_compunit = NULL;
   current_subfile = NULL;
 }
@@ -1057,7 +1046,8 @@ start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
 {
   prepare_for_building (name, start_addr);
 
-  buildsym_compunit = start_buildsym_compunit (objfile, comp_dir, language);
+  buildsym_compunit = new struct buildsym_compunit (objfile, comp_dir,
+						    language);
 
   /* Allocate the compunit symtab now.  The caller needs it to allocate
      non-primary symtabs.  It is also needed by get_macro_table.  */
@@ -1093,9 +1083,10 @@ restart_symtab (struct compunit_symtab *cust,
 {
   prepare_for_building (name, start_addr);
 
-  buildsym_compunit = start_buildsym_compunit (COMPUNIT_OBJFILE (cust),
-					       COMPUNIT_DIRNAME (cust),
-					       compunit_language (cust));
+  buildsym_compunit
+    = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust),
+				    COMPUNIT_DIRNAME (cust),
+				    compunit_language (cust));
   buildsym_compunit->compunit_symtab = cust;
 }
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 22/42] Move current_subfile to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (3 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 15/42] Remove merge_symbol_lists Tom Tromey
@ 2018-05-23  4:59 ` Tom Tromey
  2018-07-10  1:52   ` Simon Marchi
  2018-05-23  4:59 ` [RFA 27/42] Do not look at file symbols when reading psymtabs Tom Tromey
                   ` (38 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  4:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the global current_subfile into buildsym_compunit.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (process_linenos): Update.
	* stabsread.c (define_symbol, read_type, read_enum_type): Update.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* dwarf2read.c (setup_type_unit_groups)
	(lnp_state_machine::handle_set_file, dwarf_record_line_p)
	(lnp_state_machine::record_line, dwarf_decode_lines): Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read, enter_linenos)
	(process_coff_symbol): Update.
	* buildsym.h (current_subfile): Don't declare.
	(get_current_subfile): Declare.
	* buildsym.c (struct buildsym_compunit) <m_current_subfile>: New
	member.
	(start_subfile, free_buildsym_compunit, push_subfile)
	(prepare_for_building, start_symtab): Update.
	(get_current_subfile): New function.
---
 gdb/ChangeLog    | 19 +++++++++++++++++++
 gdb/buildsym.c   | 25 ++++++++++++++++++-------
 gdb/buildsym.h   |  6 ++++--
 gdb/coffread.c   |  8 ++++----
 gdb/dbxread.c    |  8 ++++----
 gdb/dwarf2read.c | 26 +++++++++++++-------------
 gdb/mdebugread.c |  2 +-
 gdb/stabsread.c  |  8 ++++----
 gdb/xcoffread.c  |  4 +++-
 9 files changed, 70 insertions(+), 36 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 54592b7795..4f820f5dc5 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -216,6 +216,8 @@ struct buildsym_compunit
 
   std::vector<struct context_stack> m_context_stack;
   struct context_stack m_popped_context {};
+
+  struct subfile *m_current_subfile = nullptr;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -767,7 +769,7 @@ start_subfile (const char *name)
 
       if (FILENAME_CMP (subfile_name, name) == 0)
 	{
-	  current_subfile = subfile;
+	  buildsym_compunit->m_current_subfile = subfile;
 	  if (subfile_name != subfile->name)
 	    xfree (subfile_name);
 	  return;
@@ -785,7 +787,7 @@ start_subfile (const char *name)
   subfile->next = buildsym_compunit->subfiles;
   buildsym_compunit->subfiles = subfile;
 
-  current_subfile = subfile;
+  buildsym_compunit->m_current_subfile = subfile;
 
   subfile->name = xstrdup (name);
 
@@ -845,7 +847,6 @@ free_buildsym_compunit (void)
     return;
   delete buildsym_compunit;
   buildsym_compunit = NULL;
-  current_subfile = NULL;
 }
 
 /* For stabs readers, the first N_SO symbol is assumed to be the
@@ -901,8 +902,10 @@ void
 push_subfile ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  gdb_assert (! (current_subfile == NULL || current_subfile->name == NULL));
-  buildsym_compunit->m_subfile_stack.push_back (current_subfile->name);
+  gdb_assert (! (buildsym_compunit->m_current_subfile == NULL
+		 || buildsym_compunit->m_current_subfile->name == NULL));
+  buildsym_compunit->m_subfile_stack.push_back
+    (buildsym_compunit->m_current_subfile->name);
 }
 
 const char *
@@ -1035,7 +1038,6 @@ prepare_for_building ()
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
   gdb_assert (pending_addrmap == NULL);
-  gdb_assert (current_subfile == NULL);
   gdb_assert (buildsym_compunit == nullptr);
 }
 
@@ -1074,7 +1076,7 @@ start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
   start_subfile (name);
   /* Save this so that we don't have to go looking for it at the end
      of the subfiles list.  */
-  buildsym_compunit->main_subfile = current_subfile;
+  buildsym_compunit->main_subfile = buildsym_compunit->m_current_subfile;
 
   return buildsym_compunit->compunit_symtab;
 }
@@ -1765,6 +1767,15 @@ get_context_stack_depth ()
   return buildsym_compunit->m_context_stack.size ();
 }
 
+/* See buildsym.h.  */
+
+struct subfile *
+get_current_subfile ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->m_current_subfile;
+}
+
 \f
 
 /* Initialize anything that needs initializing when starting to read a
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index fe158d183c..ad56ac597f 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -64,8 +64,6 @@ struct subfile
   struct symtab *symtab;
 };
 
-EXTERN struct subfile *current_subfile;
-
 /* Record the symbols defined for each context in a list.  We don't
    create a struct block for the context until we know how long to
    make it.  */
@@ -274,6 +272,10 @@ extern struct context_stack *get_current_context_stack ();
 
 extern int get_context_stack_depth ();
 
+/* Return the current subfile.  */
+
+extern struct subfile *get_current_subfile ();
+
 #undef EXTERN
 
 #endif /* defined (BUILDSYM_H) */
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 85718b252a..a8e3f59a65 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -857,7 +857,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 	     language_unknown, since such a ``file name'' is not
 	     recognized.  Override that with the minimal language to
 	     allow printing values in this symtab.  */
-	  current_subfile->language = language_minimal;
+	  get_current_subfile ()->language = language_minimal;
 	  complete_symtab ("_globals_", 0, 0);
 	  /* Done with all files, everything from here on out is
 	     globals.  */
@@ -1132,7 +1132,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 	         of the closing '}', and for which we do not have any
 	         other statement-line-number.  */
 	      if (fcn_last_line == 1)
-		record_line (current_subfile, fcn_first_line,
+		record_line (get_current_subfile (), fcn_first_line,
 			     gdbarch_addr_bits_remove (gdbarch,
 						       fcn_first_line_addr));
 	      else
@@ -1511,7 +1511,7 @@ enter_linenos (long file_offset, int first_line,
 	  CORE_ADDR addr = lptr.l_addr.l_paddr;
 	  addr += ANOFFSET (objfile->section_offsets,
 			    SECT_OFF_TEXT (objfile));
-	  record_line (current_subfile,
+	  record_line (get_current_subfile (),
 		       first_line + L_LNNO32 (&lptr),
 		       gdbarch_addr_bits_remove (gdbarch, addr));
 	}
@@ -1634,7 +1634,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
   name = cs->c_name;
   name = EXTERNAL_NAME (name, objfile->obfd);
-  SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+  SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
 		       &objfile->objfile_obstack);
   SYMBOL_SET_NAMES (sym, name, strlen (name), 1, objfile);
 
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index fe7f4a2815..713178809b 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2571,7 +2571,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	    {
 	      CORE_ADDR addr = last_function_start + valu;
 
-	      record_line (current_subfile, 0,
+	      record_line (get_current_subfile (), 0,
 			   gdbarch_addr_bits_remove (gdbarch, addr));
 	    }
 
@@ -2707,7 +2707,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	     name.  Patch things up.  */
 	  if (previous_stab_code == (unsigned char) N_SO)
 	    {
-	      patch_subfile_names (current_subfile, name);
+	      patch_subfile_names (get_current_subfile (), name);
 	      break;		/* Ignore repeated SOs.  */
 	    }
 	  end_symtab (valu, SECT_OFF_TEXT (objfile));
@@ -2777,12 +2777,12 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	  CORE_ADDR addr = processing_gcc_compilation == 2 ?
 			   last_function_start : valu;
 
-	  record_line (current_subfile, desc,
+	  record_line (get_current_subfile (), desc,
 		       gdbarch_addr_bits_remove (gdbarch, addr));
 	  sline_found_in_function = 1;
 	}
       else
-	record_line (current_subfile, desc,
+	record_line (get_current_subfile (), desc,
 		     gdbarch_addr_bits_remove (gdbarch, valu));
       break;
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 354ff920e5..131dcfbb55 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11614,18 +11614,18 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
 
 	  dwarf2_start_subfile (fe.name, fe.include_dir (cu->line_header));
 
-	  if (current_subfile->symtab == NULL)
+	  if (get_current_subfile ()->symtab == NULL)
 	    {
 	      /* NOTE: start_subfile will recognize when it's been
 		 passed a file it has already seen.  So we can't
 		 assume there's a simple mapping from
 		 cu->line_header->file_names to subfiles, plus
 		 cu->line_header->file_names may contain dups.  */
-	      current_subfile->symtab
-		= allocate_symtab (cust, current_subfile->name);
+	      get_current_subfile ()->symtab
+		= allocate_symtab (cust, get_current_subfile ()->name);
 	    }
 
-	  fe.symtab = current_subfile->symtab;
+	  fe.symtab = get_current_subfile ()->symtab;
 	  tu_group->symtabs[i] = fe.symtab;
 	}
     }
@@ -20577,7 +20577,7 @@ lnp_state_machine::handle_set_file (file_name_index file)
     {
       const char *dir = fe->include_dir (m_line_header);
 
-      m_last_subfile = current_subfile;
+      m_last_subfile = get_current_subfile ();
       m_line_has_non_zero_discriminator = m_discriminator != 0;
       dwarf2_start_subfile (fe->name, dir);
     }
@@ -20642,7 +20642,7 @@ dwarf_record_line_p (unsigned int line, unsigned int last_line,
 		     int line_has_non_zero_discriminator,
 		     struct subfile *last_subfile)
 {
-  if (current_subfile != last_subfile)
+  if (get_current_subfile () != last_subfile)
     return 1;
   if (line != last_line)
     return 1;
@@ -20723,7 +20723,7 @@ lnp_state_machine::record_line (bool end_sequence)
       fe->included_p = 1;
       if (m_record_lines_p && m_is_stmt)
 	{
-	  if (m_last_subfile != current_subfile || end_sequence)
+	  if (m_last_subfile != get_current_subfile () || end_sequence)
 	    {
 	      dwarf_finish_line (m_gdbarch, m_last_subfile,
 				 m_address, m_record_line_callback);
@@ -20735,11 +20735,11 @@ lnp_state_machine::record_line (bool end_sequence)
 				       m_line_has_non_zero_discriminator,
 				       m_last_subfile))
 		{
-		  dwarf_record_line_1 (m_gdbarch, current_subfile,
+		  dwarf_record_line_1 (m_gdbarch, get_current_subfile (),
 				       m_line, m_address,
 				       m_record_line_callback);
 		}
-	      m_last_subfile = current_subfile;
+	      m_last_subfile = get_current_subfile ();
 	      m_last_line = m_line;
 	    }
 	}
@@ -21073,12 +21073,12 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
 
 	  dwarf2_start_subfile (fe.name, fe.include_dir (lh));
 
-	  if (current_subfile->symtab == NULL)
+	  if (get_current_subfile ()->symtab == NULL)
 	    {
-	      current_subfile->symtab
-		= allocate_symtab (cust, current_subfile->name);
+	      get_current_subfile ()->symtab
+		= allocate_symtab (cust, get_current_subfile ()->name);
 	    }
-	  fe.symtab = current_subfile->symtab;
+	  fe.symtab = get_current_subfile ()->symtab;
 	}
     }
 }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index e56e009589..704c064fd8 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4075,7 +4075,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
 		  /* Handle encoded stab line number.  */
 		  valu += ANOFFSET (section_offsets,
 				    SECT_OFF_TEXT (objfile));
-		  record_line (current_subfile, sh.index,
+		  record_line (get_current_subfile (), sh.index,
 			       gdbarch_addr_bits_remove (gdbarch, valu));
 		}
 	    }
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index bb50a16829..8c90241165 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -697,7 +697,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_LINE (sym) = 0;	/* unknown */
     }
 
-  SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+  SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
 		       &objfile->objfile_obstack);
 
   if (is_cplus_marker (string[0]))
@@ -1298,7 +1298,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 		 */
 
 	      /* Pascal accepts names for pointer types.  */
-	      if (current_subfile->language == language_pascal)
+	      if (get_current_subfile ()->language == language_pascal)
 		{
 		  TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_LINKAGE_NAME (sym);
           	}
@@ -1642,7 +1642,7 @@ again:
 		return error_type (pp, objfile);
 	    }
 	  type_name = NULL;
-	  if (current_subfile->language == language_cplus)
+	  if (get_current_subfile ()->language == language_cplus)
 	    {
 	      char *name = (char *) alloca (p - *pp + 1);
 
@@ -3699,7 +3699,7 @@ read_enum_type (const char **pp, struct type *type,
 
       sym = allocate_symbol (objfile);
       SYMBOL_SET_LINKAGE_NAME (sym, name);
-      SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+      SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
 			   &objfile->objfile_obstack);
       SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 89896baded..af03c11e8b 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -716,6 +716,7 @@ process_linenos (CORE_ADDR start, CORE_ADDR end)
       /* Line numbers are not necessarily ordered.  xlc compilation will
          put static function to the end.  */
 
+      struct subfile *current_subfile = get_current_subfile ();
       lineTb = arrange_linetable (lv);
       if (lv == lineTb)
 	{
@@ -778,8 +779,9 @@ process_linenos (CORE_ADDR start, CORE_ADDR end)
 	    if (fakename == NULL)
 	      fakename = " ?";
 	    start_subfile (fakename);
-	    xfree (current_subfile->name);
+	    xfree (get_current_subfile ()->name);
 	  }
+	  struct subfile *current_subfile = get_current_subfile ();
 	  current_subfile->name = xstrdup (inclTable[ii].name);
 #endif
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 32/42] Remove EXTERN from buildsym.h
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (30 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 40/42] Convert the DWARF reader to new-style buildysm Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  3:44   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 39/42] Parameterize cp_scan_for_anonymous_namespaces Tom Tromey
                   ` (11 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Nothing in buildsym.h relies on the "EXTERN" method of
declaration/definition, so remove the traces.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.h (EXTERN): Don't define or undef.
	* buildsym.c (EXTERN): Don't define.
---
 gdb/ChangeLog  |  5 +++++
 gdb/buildsym.c |  7 +------
 gdb/buildsym.h | 13 +------------
 3 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index a39c003e7c..1c7b3de215 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -62,6 +62,7 @@
 */
 
 #include "defs.h"
+#include "buildsym.h"
 #include "bfd.h"
 #include "gdb_obstack.h"
 #include "symtab.h"
@@ -79,12 +80,6 @@
 #include "addrmap.h"
 #include <algorithm>
 
-/* Ask buildsym.h to define the vars it normally declares `extern'.  */
-#define	EXTERN
-/**/
-#include "buildsym.h"		/* Our own declarations.  */
-#undef	EXTERN
-
 /* For cleanup_undefined_stabs_types and finish_global_stabs (somewhat
    questionable--see comment where we call them).  */
 
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index b6d16876d6..8a4f47b375 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -30,22 +30,13 @@ enum language;
    file-reading routines.
 
    They originated in dbxread.c of gdb-4.2, and were split out to
-   make xcoffread.c more maintainable by sharing code.
-
-   Variables declared in this file can be defined by #define-ing the
-   name EXTERN to null.  It is used to declare variables that are
-   normally extern, but which get defined in a single module using
-   this technique.  */
+   make xcoffread.c more maintainable by sharing code.  */
 
 struct block;
 struct pending_block;
 
 struct dynamic_prop;
 
-#ifndef EXTERN
-#define	EXTERN extern
-#endif
-
 /* The list of sub-source-files within the current individual
    compilation.  Each file gets its own symtab with its own linetable
    and associated info, but they all share one blockvector.  */
@@ -271,6 +262,4 @@ extern struct pending **get_file_symbols ();
 
 extern struct pending **get_global_symbols ();
 
-#undef EXTERN
-
 #endif /* defined (BUILDSYM_H) */
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 39/42] Parameterize cp_scan_for_anonymous_namespaces
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (31 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 32/42] Remove EXTERN from buildsym.h Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-06 19:23   ` Keith Seitz
  2018-05-23  6:16 ` [RFA 35/42] Do not use buildsym.h in some files Tom Tromey
                   ` (10 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes cp_scan_for_anonymous_namespaces to use the
buildsym_compunit API, rather than the function-based API.

2018-05-22  Tom Tromey  <tom@tromey.com>

	* stabsread.c (define_symbol): Update.
	* legacy-buildsym.h (get_buildsym_compunit): Declare.
	* dwarf2read.c (new_symbol): Update.
	* cp-support.h (cp_scan_for_anonymous_namespaces): Update.
	* cp-namespace.c: Include buildsym.h.
	(cp_scan_for_anonymous_namespaces): Add "compunit" parameter.
	* buildsym.c (get_buildsym_compunit): New function.
---
 gdb/ChangeLog         | 10 ++++++++++
 gdb/buildsym.c        |  7 +++++++
 gdb/cp-namespace.c    | 11 ++++++-----
 gdb/cp-support.h      |  4 +++-
 gdb/dwarf2read.c      |  3 ++-
 gdb/legacy-buildsym.h |  4 ++++
 gdb/stabsread.c       |  3 ++-
 7 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 3e3170f0ee..d9a0e02653 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1634,3 +1634,10 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc)
   gdb_assert (buildsym_compunit != nullptr);
   buildsym_compunit->record_line (subfile, line, pc);
 }
+
+struct buildsym_compunit *
+get_buildsym_compunit ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit;
+}
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 41affca3a8..03f75ae486 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -29,7 +29,7 @@
 #include "dictionary.h"
 #include "command.h"
 #include "frame.h"
-#include "legacy-buildsym.h"
+#include "buildsym.h"
 #include "language.h"
 #include "namespace.h"
 #include <string>
@@ -50,7 +50,8 @@ static struct type *cp_lookup_transparent_type_loop (const char *name,
    anonymous namespace; if so, add an appropriate using directive.  */
 
 void
-cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
+cp_scan_for_anonymous_namespaces (struct buildsym_compunit *compunit,
+				  const struct symbol *const symbol,
 				  struct objfile *const objfile)
 {
   if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
@@ -94,9 +95,9 @@ cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
 		 namespace given by the previous component if there is
 		 one, or to the global namespace if there isn't.  */
 	      std::vector<const char *> excludes;
-	      add_using_directive (get_local_using_directives (),
-				   dest, src, NULL, NULL, excludes, 1,
-				   &objfile->objfile_obstack);
+	      add_using_directive (compunit->get_local_using_directives (),
+				   dest, src, NULL, NULL, excludes,
+				   1, &objfile->objfile_obstack);
 	    }
 	  /* The "+ 2" is for the "::".  */
 	  previous_component = next_component + 2;
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 44725818e9..0739dcdf5f 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -33,6 +33,7 @@
 
 struct symbol;
 struct block;
+struct buildsym_compunit;
 struct objfile;
 struct type;
 struct demangle_component;
@@ -132,7 +133,8 @@ extern symbol_name_matcher_ftype *cp_get_symbol_name_matcher
 
 extern int cp_is_in_anonymous (const char *symbol_name);
 
-extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
+extern void cp_scan_for_anonymous_namespaces (struct buildsym_compunit *,
+					      const struct symbol *symbol,
 					      struct objfile *objfile);
 
 extern struct block_symbol cp_lookup_symbol_nonlocal
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 75a121073c..504e8e4e6c 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -21596,7 +21596,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	 namespaces based on the demangled name.  */
       if (!cu->processing_has_namespace_info
 	  && cu->language == language_cplus)
-	cp_scan_for_anonymous_namespaces (sym, objfile);
+	cp_scan_for_anonymous_namespaces (get_buildsym_compunit (), sym,
+					  objfile);
     }
   return (sym);
 }
diff --git a/gdb/legacy-buildsym.h b/gdb/legacy-buildsym.h
index 66a3ea8cd0..5d405ee881 100644
--- a/gdb/legacy-buildsym.h
+++ b/gdb/legacy-buildsym.h
@@ -207,4 +207,8 @@ extern struct pending **get_file_symbols ();
 
 extern struct pending **get_global_symbols ();
 
+/* Return the current buildsym_compunit.  */
+
+extern struct buildsym_compunit *get_buildsym_compunit ();
+
 #endif /* defined (LEGACY_BUILDSYM_H) */
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 62221d03cf..481948117b 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -755,7 +755,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile);
 
       if (SYMBOL_LANGUAGE (sym) == language_cplus)
-	cp_scan_for_anonymous_namespaces (sym, objfile);
+	cp_scan_for_anonymous_namespaces (get_buildsym_compunit (), sym,
+					  objfile);
 
     }
   p++;
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 36/42] Remove reset_symtab_globals
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (33 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 35/42] Do not use buildsym.h in some files Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  4:11   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 42/42] Remove record_line_ftype Tom Tromey
                   ` (8 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch arranges for the remaining buildsym global --
buildsym_compunit -- to only be cleared by the wrapper functions, not
by methods on struct buildsym_compunit.  In the process,
reset_symtab_globals is removed.

2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (reset_symtab_globals): Remove.
	(buildsym_compunit::end_symtab_from_static_block): Update.
	(buildsym_compunit::augment_type_symtab): Update.
	(end_symtab_from_static_block): Call free_buildsym_compunit.
	(augment_type_symtab, end_symtab, end_expandable_symtab):
	Likewise.
---
 gdb/ChangeLog  |  9 +++++++++
 gdb/buildsym.c | 20 ++++----------------
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b9be6dd61a..16756d8835 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1251,14 +1251,6 @@ buildsym_compunit::watch_main_source_file_lossage ()
     }
 }
 
-/* Reset state after a successful building of a symtab.  */
-
-static void
-reset_symtab_globals (void)
-{
-  free_buildsym_compunit ();
-}
-
 /* Implementation of the first part of end_symtab.  It allows modifying
    STATIC_BLOCK before it gets finalized by end_symtab_from_static_block.
    If the returned value is NULL there is no blockvector created for
@@ -1562,8 +1554,6 @@ buildsym_compunit::end_symtab_from_static_block (struct block *static_block,
   else
     cu = end_symtab_with_blockvector (static_block, section, expandable);
 
-  reset_symtab_globals ();
-
   return cu;
 }
 
@@ -1672,8 +1662,6 @@ buildsym_compunit::augment_type_symtab ()
       dict_add_pending (BLOCK_DICT (block),
 			m_global_symbols);
     }
-
-  reset_symtab_globals ();
 }
 
 /* Push a context block.  Args are an identifying nesting level
@@ -1899,7 +1887,7 @@ end_symtab_from_static_block (struct block *static_block,
   struct compunit_symtab *result
     = buildsym_compunit->end_symtab_from_static_block (static_block,
 						       section, expandable);
-  reset_symtab_globals ();
+  free_buildsym_compunit ();
   return result;
 }
 
@@ -1909,7 +1897,7 @@ end_symtab (CORE_ADDR end_addr, int section)
   gdb_assert (buildsym_compunit != nullptr);
   struct compunit_symtab *result
     = buildsym_compunit->end_symtab (end_addr, section);
-  reset_symtab_globals ();
+  free_buildsym_compunit ();
   return result;
 }
 
@@ -1919,7 +1907,7 @@ end_expandable_symtab (CORE_ADDR end_addr, int section)
   gdb_assert (buildsym_compunit != nullptr);
   struct compunit_symtab *result
     = buildsym_compunit->end_expandable_symtab (end_addr, section);
-  reset_symtab_globals ();
+  free_buildsym_compunit ();
   return result;
 }
 
@@ -1928,7 +1916,7 @@ augment_type_symtab ()
 {
   gdb_assert (buildsym_compunit != nullptr);
   buildsym_compunit->augment_type_symtab ();
-  reset_symtab_globals ();
+  free_buildsym_compunit ();
 }
 
 struct context_stack *
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 41/42] Remove some unused buildsym functions
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (38 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 37/42] Move struct buildsym_compunit to buildsym.h Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  4:37   ` Simon Marchi
  2018-05-23  7:31 ` [RFA 38/42] Introduce legacy-buildsym.h Tom Tromey
                   ` (3 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Now that the DWARF reader uses the builder-based API, we can remove a
few "legacy" functions that were only ever called by it.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* legacy-buildsym.h (augment_type_symtab): Don't declare.
	(end_expandable_symtab): Likewise.
	(end_symtab_get_static_block): Likewise.
	(end_symtab_from_static_block): Likewise.
	* buildsym.c (augment_type_symtab): Remove.
	(end_expandable_symtab): Remove.
	(end_symtab_get_static_block): Remove.
	(end_symtab_from_static_block): Remove.
---
 gdb/ChangeLog         | 11 +++++++++++
 gdb/buildsym.c        | 38 --------------------------------------
 gdb/legacy-buildsym.h | 32 --------------------------------
 3 files changed, 11 insertions(+), 70 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index d9a0e02653..c4e14f0272 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1548,26 +1548,6 @@ pop_subfile ()
   return buildsym_compunit->pop_subfile ();
 }
 
-struct block *
-end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
-{
-  gdb_assert (buildsym_compunit != nullptr);
-  return buildsym_compunit->end_symtab_get_static_block (end_addr, expandable,
-							 required);
-}
-
-struct compunit_symtab *
-end_symtab_from_static_block (struct block *static_block,
-			      int section, int expandable)
-{
-  gdb_assert (buildsym_compunit != nullptr);
-  struct compunit_symtab *result
-    = buildsym_compunit->end_symtab_from_static_block (static_block,
-						       section, expandable);
-  free_buildsym_compunit ();
-  return result;
-}
-
 struct compunit_symtab *
 end_symtab (CORE_ADDR end_addr, int section)
 {
@@ -1578,24 +1558,6 @@ end_symtab (CORE_ADDR end_addr, int section)
   return result;
 }
 
-struct compunit_symtab *
-end_expandable_symtab (CORE_ADDR end_addr, int section)
-{
-  gdb_assert (buildsym_compunit != nullptr);
-  struct compunit_symtab *result
-    = buildsym_compunit->end_expandable_symtab (end_addr, section);
-  free_buildsym_compunit ();
-  return result;
-}
-
-void
-augment_type_symtab ()
-{
-  gdb_assert (buildsym_compunit != nullptr);
-  buildsym_compunit->augment_type_symtab ();
-  free_buildsym_compunit ();
-}
-
 struct context_stack *
 push_context (int desc, CORE_ADDR valu)
 {
diff --git a/gdb/legacy-buildsym.h b/gdb/legacy-buildsym.h
index 5d405ee881..55f9d14f7e 100644
--- a/gdb/legacy-buildsym.h
+++ b/gdb/legacy-buildsym.h
@@ -37,25 +37,6 @@
    The compunit symtab pointer ("cust") is returned from both start_symtab
    and end_symtab to simplify the debug info readers.
 
-   There are minor variations on this, e.g., dwarf2read.c splits end_symtab
-   into two calls: end_symtab_get_static_block, end_symtab_from_static_block,
-   but all debug info readers follow this basic flow.
-
-   Reading DWARF Type Units is another variation:
-
-   scoped_free_pendings free_pending;
-   cust = start_symtab (...);
-   ... read debug info ...
-   cust = end_expandable_symtab (...);
-
-   And then reading subsequent Type Units within the containing "Comp Unit"
-   will use a second flow:
-
-   scoped_free_pendings free_pending;
-   cust = restart_symtab (...);
-   ... read debug info ...
-   cust = augment_type_symtab (...);
-
    dbxread.c and xcoffread.c use another variation:
 
    scoped_free_pendings free_pending;
@@ -92,21 +73,8 @@ extern void push_subfile ();
 
 extern const char *pop_subfile ();
 
-extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
-						  int expandable,
-						  int required);
-
-extern struct compunit_symtab *
-  end_symtab_from_static_block (struct block *static_block,
-				int section, int expandable);
-
 extern struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
 
-extern struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
-						      int section);
-
-extern void augment_type_symtab (void);
-
 extern struct context_stack *push_context (int desc, CORE_ADDR valu);
 
 extern struct context_stack *pop_context (void);
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 40/42] Convert the DWARF reader to new-style buildysm
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (29 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 24/42] Move pending_blocks and pending_block_obstack to buildsym_compunit Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-06 20:10   ` Keith Seitz
  2018-07-10  4:36   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 32/42] Remove EXTERN from buildsym.h Tom Tromey
                   ` (12 subsequent siblings)
  43 siblings, 2 replies; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This converts the DWARF reader to use the new-style buildsym API.  A
new buildsym_compunit is created for each CU and is used to construct
the symbol table.  In some cases the CU must be passed to functions
which previously did not accept it.  FWIW I tend to think that most
methods in the DWARF reader ought to be methods on the dwarf2_cu
object.

2018-05-22  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c: Include buildsym.h.
	(struct dwarf2_cu) <builder>: New method.
	(fixup_go_packaging): Update.
	(process_full_comp_unit, process_full_type_unit): Update.  Don't
	use scoped_free_pendings.
	(using_directives): Add "cu" parameter, remove "language".
	(read_import_statement, setup_type_unit_groups, )
	(read_func_scope, read_lexical_block_scope)
	(dwarf2_record_block_ranges, read_namespace): Update.
	(lnp_state_machine::lnp_state_machine): Add cu parameter.
	(lnp_state_machine::handle_end_sequence): Update.
	(class lnp_state_machine) <m_cu>: New member.
	<m_record_line_callback>: Remove.
	<m_currently_recording_lines>: New member.
	(lnp_state_machine::handle_set_file): Update.
	(noop_record_line): Remove.
	(dwarf_record_line_p): Add cu parameter.
	(dwarf_record_line_1, dwarf_finish_line): Likewise.
	(lnp_state_machine::record_line)
	(lnp_state_machine::lnp_state_machine)
	(lnp_state_machine::check_line_address, dwarf_decode_lines_1)
	(dwarf_decode_lines): Update.
	(dwarf2_start_subfile): Add cu parameter.
	(dwarf2_start_symtab, new_symbol): Update.
	(macro_start_file, dwarf_decode_macro_bytes): Add cu parameter.
	(dwarf_decode_macros): Update.
---
 gdb/ChangeLog    |  29 ++++++
 gdb/dwarf2read.c | 283 +++++++++++++++++++++++++++++++------------------------
 2 files changed, 190 insertions(+), 122 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 504e8e4e6c..94743fdd77 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -37,7 +37,7 @@
 #include "gdbtypes.h"
 #include "objfiles.h"
 #include "dwarf2.h"
-#include "legacy-buildsym.h"
+#include "buildsym.h"
 #include "demangle.h"
 #include "gdb-demangle.h"
 #include "expression.h"
@@ -435,6 +435,10 @@ struct dwarf2_cu
 
   const char *producer = nullptr;
 
+  /* The symtab builder for this CU.  This is only non-NULL when full
+     symbols are being read.  */
+  std::unique_ptr<buildsym_compunit> builder;
+
   /* The generic symbol table building routines have separate lists for
      file scope symbols and all all other scopes (local scopes).  So
      we need to select the right one to pass to add_symbol_to_list().
@@ -1570,7 +1574,8 @@ static void dwarf_decode_lines (struct line_header *, const char *,
 				struct dwarf2_cu *, struct partial_symtab *,
 				CORE_ADDR, int decode_mapping);
 
-static void dwarf2_start_subfile (const char *, const char *);
+static void dwarf2_start_subfile (struct dwarf2_cu *, const char *,
+				  const char *);
 
 static struct compunit_symtab *dwarf2_start_symtab (struct dwarf2_cu *,
 						    const char *, const char *,
@@ -1683,7 +1688,7 @@ static void read_namespace (struct die_info *die, struct dwarf2_cu *);
 
 static void read_module (struct die_info *die, struct dwarf2_cu *cu);
 
-static struct using_direct **using_directives (enum language);
+static struct using_direct **using_directives (struct dwarf2_cu *cu);
 
 static void read_import_statement (struct die_info *die, struct dwarf2_cu *);
 
@@ -9739,7 +9744,9 @@ fixup_go_packaging (struct dwarf2_cu *cu)
   struct pending *list;
   int i;
 
-  for (list = *get_global_symbols (); list != NULL; list = list->next)
+  for (list = *cu->builder->get_global_symbols ();
+       list != NULL;
+       list = list->next)
     {
       for (i = 0; i < list->nsyms; ++i)
 	{
@@ -9795,7 +9802,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
       SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
       SYMBOL_TYPE (sym) = type;
 
-      add_symbol_to_list (sym, get_global_symbols ());
+      add_symbol_to_list (sym, cu->builder->get_global_symbols ());
 
       xfree (package_name);
     }
@@ -10275,8 +10282,6 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
-  scoped_free_pendings free_pending;
-
   /* Clear the list here in case something was left over.  */
   cu->method_list.clear ();
 
@@ -10304,7 +10309,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
   get_scope_pc_bounds (cu->dies, &lowpc, &highpc, cu);
 
   addr = gdbarch_adjust_dwarf2_addr (gdbarch, highpc + baseaddr);
-  static_block = end_symtab_get_static_block (addr, 0, 1);
+  static_block = cu->builder->end_symtab_get_static_block (addr, 0, 1);
 
   /* If the comp unit has DW_AT_ranges, it may have discontiguous ranges.
      Also, DW_AT_ranges may record ranges not belonging to any child DIEs
@@ -10313,8 +10318,9 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
      this comp unit.  */
   dwarf2_record_block_ranges (cu->dies, static_block, baseaddr, cu);
 
-  cust = end_symtab_from_static_block (static_block,
-				       SECT_OFF_TEXT (objfile), 0);
+  cust = cu->builder->end_symtab_from_static_block (static_block,
+						    SECT_OFF_TEXT (objfile),
+						    0);
 
   if (cust != NULL)
     {
@@ -10359,6 +10365,9 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
 
   /* Push it for inclusion processing later.  */
   VEC_safe_push (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus, per_cu);
+
+  /* Not needed any more.  */
+  cu->builder.reset ();
 }
 
 /* Generate full symbol information for type unit PER_CU, whose DIEs have
@@ -10377,8 +10386,6 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
   gdb_assert (per_cu->is_debug_types);
   sig_type = (struct signatured_type *) per_cu;
 
-  scoped_free_pendings free_pending;
-
   /* Clear the list here in case something was left over.  */
   cu->method_list.clear ();
 
@@ -10406,7 +10413,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
      this TU's symbols to the existing symtab.  */
   if (sig_type->type_unit_group->compunit_symtab == NULL)
     {
-      cust = end_expandable_symtab (0, SECT_OFF_TEXT (objfile));
+      cust = cu->builder->end_expandable_symtab (0, SECT_OFF_TEXT (objfile));
       sig_type->type_unit_group->compunit_symtab = cust;
 
       if (cust != NULL)
@@ -10422,7 +10429,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
     }
   else
     {
-      augment_type_symtab ();
+      cu->builder->augment_type_symtab ();
       cust = sig_type->type_unit_group->compunit_symtab;
     }
 
@@ -10434,6 +10441,9 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
       pst->compunit_symtab = cust;
       pst->readin = 1;
     }
+
+  /* Not needed any more.  */
+  cu->builder.reset ();
 }
 
 /* Process an imported unit DIE.  */
@@ -11129,12 +11139,12 @@ read_namespace_alias (struct die_info *die, struct dwarf2_cu *cu)
    global only in Ada.  */
 
 static struct using_direct **
-using_directives (enum language language)
+using_directives (struct dwarf2_cu *cu)
 {
-  if (language == language_ada && outermost_context_p ())
-    return get_global_using_directives ();
+  if (cu->language == language_ada && cu->builder->outermost_context_p ())
+    return cu->builder->get_global_using_directives ();
   else
-    return get_local_using_directives ();
+    return cu->builder->get_local_using_directives ();
 }
 
 /* Read the import statement specified by the given die and record it.  */
@@ -11272,7 +11282,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
 	process_die (child_die, cu);
       }
 
-  add_using_directive (using_directives (cu->language),
+  add_using_directive (using_directives (cu),
 		       import_prefix,
 		       canonical_name,
 		       import_alias,
@@ -11578,7 +11588,13 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
       else
 	{
 	  gdb_assert (tu_group->symtabs == NULL);
-	  restart_symtab (tu_group->compunit_symtab, "", 0);
+	  gdb_assert (!bool (cu->builder));
+	  struct compunit_symtab *cust = tu_group->compunit_symtab;
+	  cu->builder.reset (new struct buildsym_compunit
+			     (COMPUNIT_OBJFILE (cust), "",
+			      COMPUNIT_DIRNAME (cust),
+			      compunit_language (cust),
+			      0, cust));
 	}
       return;
     }
@@ -11603,26 +11619,33 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
 	{
 	  file_entry &fe = cu->line_header->file_names[i];
 
-	  dwarf2_start_subfile (fe.name, fe.include_dir (cu->line_header));
+	  dwarf2_start_subfile (cu, fe.name, fe.include_dir (cu->line_header));
 
-	  if (get_current_subfile ()->symtab == NULL)
+	  if (cu->builder->get_current_subfile ()->symtab == NULL)
 	    {
 	      /* NOTE: start_subfile will recognize when it's been
 		 passed a file it has already seen.  So we can't
 		 assume there's a simple mapping from
 		 cu->line_header->file_names to subfiles, plus
 		 cu->line_header->file_names may contain dups.  */
-	      get_current_subfile ()->symtab
-		= allocate_symtab (cust, get_current_subfile ()->name);
+	      cu->builder->get_current_subfile ()->symtab
+		= allocate_symtab (cust,
+				   cu->builder->get_current_subfile ()->name);
 	    }
 
-	  fe.symtab = get_current_subfile ()->symtab;
+	  fe.symtab = cu->builder->get_current_subfile ()->symtab;
 	  tu_group->symtabs[i] = fe.symtab;
 	}
     }
   else
     {
-      restart_symtab (tu_group->compunit_symtab, "", 0);
+      gdb_assert (!bool (cu->builder));
+      struct compunit_symtab *cust = tu_group->compunit_symtab;
+      cu->builder.reset (new struct buildsym_compunit
+			 (COMPUNIT_OBJFILE (cust), "",
+			  COMPUNIT_DIRNAME (cust),
+			  compunit_language (cust),
+			  0, cust));
 
       for (i = 0; i < cu->line_header->file_names.size (); ++i)
 	{
@@ -13655,7 +13678,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 	}
     }
 
-  newobj = push_context (0, lowpc);
+  newobj = cu->builder->push_context (0, lowpc);
   newobj->name = new_symbol (die, read_type_die (die, cu), cu,
 			     (struct symbol *) templ_func);
 
@@ -13675,7 +13698,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
       attr_to_dynamic_prop (attr, die, cu, newobj->static_link);
     }
 
-  cu->list_in_scope = get_local_symbols ();
+  cu->list_in_scope = cu->builder->get_local_symbols ();
 
   if (die->child != NULL)
     {
@@ -13723,10 +13746,10 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 	}
     }
 
-  newobj = pop_context ();
+  newobj = cu->builder->pop_context ();
   /* Make a block for the local symbols within.  */
-  block = finish_block (newobj->name, newobj->old_blocks,
-			newobj->static_link, lowpc, highpc);
+  block = cu->builder->finish_block (newobj->name, newobj->old_blocks,
+				     newobj->static_link, lowpc, highpc);
 
   /* For C++, set the block's scope.  */
   if ((cu->language == language_cplus
@@ -13760,13 +13783,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
      a function declares a class that has methods).  This means that
      when we finish processing a function scope, we may need to go
      back to building a containing block's symbol lists.  */
-  *get_local_symbols () = newobj->locals;
-  set_local_using_directives (newobj->local_using_directives);
+  *cu->builder->get_local_symbols () = newobj->locals;
+  cu->builder->set_local_using_directives (newobj->local_using_directives);
 
   /* If we've finished processing a top-level function, subsequent
      symbols go in the file symbol list.  */
-  if (outermost_context_p ())
-    cu->list_in_scope = get_file_symbols ();
+  if (cu->builder->outermost_context_p ())
+    cu->list_in_scope = cu->builder->get_file_symbols ();
 }
 
 /* Process all the DIES contained within a lexical block scope.  Start
@@ -13806,7 +13829,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
   lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
   highpc = gdbarch_adjust_dwarf2_addr (gdbarch, highpc + baseaddr);
 
-  push_context (0, lowpc);
+  cu->builder->push_context (0, lowpc);
   if (die->child != NULL)
     {
       child_die = die->child;
@@ -13817,13 +13840,14 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
 	}
     }
   inherit_abstract_dies (die, cu);
-  newobj = pop_context ();
+  newobj = cu->builder->pop_context ();
 
-  if (*get_local_symbols () != NULL || (*get_local_using_directives ()) != NULL)
+  if (*cu->builder->get_local_symbols () != NULL
+      || (*cu->builder->get_local_using_directives ()) != NULL)
     {
       struct block *block
-        = finish_block (0, newobj->old_blocks, NULL,
-			newobj->start_addr, highpc);
+        = cu->builder->finish_block (0, newobj->old_blocks, NULL,
+				     newobj->start_addr, highpc);
 
       /* Note that recording ranges after traversing children, as we
          do here, means that recording a parent's ranges entails
@@ -13837,8 +13861,8 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
          to do.  */
       dwarf2_record_block_ranges (die, block, baseaddr, cu);
     }
-  *get_local_symbols () = newobj->locals;
-  set_local_using_directives (newobj->local_using_directives);
+  *cu->builder->get_local_symbols () = newobj->locals;
+  cu->builder->set_local_using_directives (newobj->local_using_directives);
 }
 
 /* Read in DW_TAG_call_site and insert it to CU->call_site_htab.  */
@@ -14766,7 +14790,7 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
 
 	  low = gdbarch_adjust_dwarf2_addr (gdbarch, low + baseaddr);
 	  high = gdbarch_adjust_dwarf2_addr (gdbarch, high + baseaddr);
-	  record_block_range (block, low, high - 1);
+	  cu->builder->record_block_range (block, low, high - 1);
         }
     }
 
@@ -14790,7 +14814,7 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
 	  end += baseaddr;
 	  start = gdbarch_adjust_dwarf2_addr (gdbarch, start);
 	  end = gdbarch_adjust_dwarf2_addr (gdbarch, end);
-	  record_block_range (block, start, end - 1);
+	  cu->builder->record_block_range (block, start, end - 1);
 	});
     }
 }
@@ -16783,7 +16807,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
 	  const char *previous_prefix = determine_prefix (die, cu);
 
 	  std::vector<const char *> excludes;
-	  add_using_directive (using_directives (cu->language),
+	  add_using_directive (using_directives (cu),
 			       previous_prefix, TYPE_NAME (type), NULL,
 			       NULL, excludes, 0, &objfile->objfile_obstack);
 	}
@@ -20397,7 +20421,8 @@ class lnp_state_machine
 public:
   /* Initialize a machine state for the start of a line number
      program.  */
-  lnp_state_machine (gdbarch *arch, line_header *lh, bool record_lines_p);
+  lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, line_header *lh,
+		     bool record_lines_p);
 
   file_entry *current_file ()
   {
@@ -20471,7 +20496,7 @@ public:
   /* Handle DW_LNE_end_sequence.  */
   void handle_end_sequence ()
   {
-    m_record_line_callback = ::record_line;
+    m_currently_recording_lines = true;
   }
 
 private:
@@ -20484,6 +20509,8 @@ private:
       m_line_has_non_zero_discriminator = m_discriminator != 0;
   }
 
+  struct dwarf2_cu *m_cu;
+
   gdbarch *m_gdbarch;
 
   /* True if we're recording lines.
@@ -20516,8 +20543,8 @@ private:
   /* The last file a line number was recorded for.  */
   struct subfile *m_last_subfile = NULL;
 
-  /* The function to call to record a line.  */
-  record_line_ftype *m_record_line_callback = NULL;
+  /* When true, record the lines we decode.  */
+  bool m_currently_recording_lines = false;
 
   /* The last line number that was recorded, used to coalesce
      consecutive entries for the same line.  This can happen, for
@@ -20568,9 +20595,9 @@ lnp_state_machine::handle_set_file (file_name_index file)
     {
       const char *dir = fe->include_dir (m_line_header);
 
-      m_last_subfile = get_current_subfile ();
+      m_last_subfile = m_cu->builder->get_current_subfile ();
       m_line_has_non_zero_discriminator = m_discriminator != 0;
-      dwarf2_start_subfile (fe->name, dir);
+      dwarf2_start_subfile (m_cu, fe->name, dir);
     }
 }
 
@@ -20590,14 +20617,6 @@ lnp_state_machine::handle_const_add_pc ()
 		% m_line_header->maximum_ops_per_instruction);
 }
 
-/* Ignore this record_line request.  */
-
-static void
-noop_record_line (struct subfile *subfile, int line, CORE_ADDR pc)
-{
-  return;
-}
-
 /* Return non-zero if we should add LINE to the line number table.
    LINE is the line to add, LAST_LINE is the last line that was added,
    LAST_SUBFILE is the subfile for LAST_LINE.
@@ -20629,11 +20648,12 @@ noop_record_line (struct subfile *subfile, int line, CORE_ADDR pc)
    within one sequence, thus this coalescing is ok.  */
 
 static int
-dwarf_record_line_p (unsigned int line, unsigned int last_line,
+dwarf_record_line_p (struct dwarf2_cu *cu,
+		     unsigned int line, unsigned int last_line,
 		     int line_has_non_zero_discriminator,
 		     struct subfile *last_subfile)
 {
-  if (get_current_subfile () != last_subfile)
+  if (cu->builder->get_current_subfile () != last_subfile)
     return 1;
   if (line != last_line)
     return 1;
@@ -20645,13 +20665,13 @@ dwarf_record_line_p (unsigned int line, unsigned int last_line,
   return 0;
 }
 
-/* Use P_RECORD_LINE to record line number LINE beginning at address ADDRESS
-   in the line table of subfile SUBFILE.  */
+/* Use the CU's builder to record line number LINE beginning at
+   address ADDRESS in the line table of subfile SUBFILE.  */
 
 static void
 dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile,
 		     unsigned int line, CORE_ADDR address,
-		     record_line_ftype p_record_line)
+		     struct dwarf2_cu *cu)
 {
   CORE_ADDR addr = gdbarch_addr_bits_remove (gdbarch, address);
 
@@ -20663,7 +20683,8 @@ dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile,
 			  paddress (gdbarch, address));
     }
 
-  (*p_record_line) (subfile, line, addr);
+  if (cu != nullptr)
+    cu->builder->record_line (subfile, line, addr);
 }
 
 /* Subroutine of dwarf_decode_lines_1 to simplify it.
@@ -20673,7 +20694,7 @@ dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile,
 
 static void
 dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile,
-		   CORE_ADDR address, record_line_ftype p_record_line)
+		   CORE_ADDR address, struct dwarf2_cu *cu)
 {
   if (subfile == NULL)
     return;
@@ -20686,7 +20707,7 @@ dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile,
 			  paddress (gdbarch, address));
     }
 
-  dwarf_record_line_1 (gdbarch, subfile, 0, address, p_record_line);
+  dwarf_record_line_1 (gdbarch, subfile, 0, address, cu);
 }
 
 void
@@ -20714,37 +20735,40 @@ lnp_state_machine::record_line (bool end_sequence)
       fe->included_p = 1;
       if (m_record_lines_p && m_is_stmt)
 	{
-	  if (m_last_subfile != get_current_subfile () || end_sequence)
+	  if (m_last_subfile != m_cu->builder->get_current_subfile ()
+	      || end_sequence)
 	    {
-	      dwarf_finish_line (m_gdbarch, m_last_subfile,
-				 m_address, m_record_line_callback);
+	      dwarf_finish_line (m_gdbarch, m_last_subfile, m_address,
+				 m_currently_recording_lines ? m_cu : nullptr);
 	    }
 
 	  if (!end_sequence)
 	    {
-	      if (dwarf_record_line_p (m_line, m_last_line,
+	      if (dwarf_record_line_p (m_cu, m_line, m_last_line,
 				       m_line_has_non_zero_discriminator,
 				       m_last_subfile))
 		{
-		  dwarf_record_line_1 (m_gdbarch, get_current_subfile (),
+		  dwarf_record_line_1 (m_gdbarch,
+				       m_cu->builder->get_current_subfile (),
 				       m_line, m_address,
-				       m_record_line_callback);
+				       m_currently_recording_lines ? m_cu : nullptr);
 		}
-	      m_last_subfile = get_current_subfile ();
+	      m_last_subfile = m_cu->builder->get_current_subfile ();
 	      m_last_line = m_line;
 	    }
 	}
     }
 }
 
-lnp_state_machine::lnp_state_machine (gdbarch *arch, line_header *lh,
-				      bool record_lines_p)
+lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch,
+				      line_header *lh, bool record_lines_p)
 {
+  m_cu = cu;
   m_gdbarch = arch;
   m_record_lines_p = record_lines_p;
   m_line_header = lh;
 
-  m_record_line_callback = ::record_line;
+  m_currently_recording_lines = true;
 
   /* Call `gdbarch_adjust_dwarf2_line' on the initial 0 address as if there
      was a line entry for it so that the backend has a chance to adjust it
@@ -20776,9 +20800,9 @@ lnp_state_machine::check_line_address (struct dwarf2_cu *cu,
       complaint (&symfile_complaints,
 		 _(".debug_line address at offset 0x%lx is 0 [in module %s]"),
 		 line_offset, objfile_name (objfile));
-      m_record_line_callback = noop_record_line;
-      /* Note: record_line_callback is left as noop_record_line until
-	 we see DW_LNE_end_sequence.  */
+      m_currently_recording_lines = false;
+      /* Note: m_currently_recording_lines is left as false until we see
+	 DW_LNE_end_sequence.  */
     }
 }
 
@@ -20814,7 +20838,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
     {
       /* The DWARF line number program state machine.  Reset the state
 	 machine at the start of each sequence.  */
-      lnp_state_machine state_machine (gdbarch, lh, record_lines_p);
+      lnp_state_machine state_machine (cu, gdbarch, lh, record_lines_p);
       bool end_sequence = false;
 
       if (record_lines_p)
@@ -20824,7 +20848,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 	  const file_entry *fe = state_machine.current_file ();
 
 	  if (fe != NULL)
-	    dwarf2_start_subfile (fe->name, fe->include_dir (lh));
+	    dwarf2_start_subfile (cu, fe->name, fe->include_dir (lh));
 	}
 
       /* Decode the table.  */
@@ -21055,21 +21079,22 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
       /* Make sure a symtab is created for every file, even files
 	 which contain only variables (i.e. no code with associated
 	 line numbers).  */
-      struct compunit_symtab *cust = buildsym_compunit_symtab ();
+      struct compunit_symtab *cust = cu->builder->get_compunit_symtab ();
       int i;
 
       for (i = 0; i < lh->file_names.size (); i++)
 	{
 	  file_entry &fe = lh->file_names[i];
 
-	  dwarf2_start_subfile (fe.name, fe.include_dir (lh));
+	  dwarf2_start_subfile (cu, fe.name, fe.include_dir (lh));
 
-	  if (get_current_subfile ()->symtab == NULL)
+	  if (cu->builder->get_current_subfile ()->symtab == NULL)
 	    {
-	      get_current_subfile ()->symtab
-		= allocate_symtab (cust, get_current_subfile ()->name);
+	      cu->builder->get_current_subfile ()->symtab
+		= allocate_symtab (cust,
+				   cu->builder->get_current_subfile ()->name);
 	    }
-	  fe.symtab = get_current_subfile ()->symtab;
+	  fe.symtab = cu->builder->get_current_subfile ()->symtab;
 	}
     }
 }
@@ -21098,7 +21123,8 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
    subfile's name.  */
 
 static void
-dwarf2_start_subfile (const char *filename, const char *dirname)
+dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
+		      const char *dirname)
 {
   char *copy = NULL;
 
@@ -21115,31 +21141,33 @@ dwarf2_start_subfile (const char *filename, const char *dirname)
       filename = copy;
     }
 
-  start_subfile (filename);
+  cu->builder->start_subfile (filename);
 
   if (copy != NULL)
     xfree (copy);
 }
 
-/* Start a symtab for DWARF.
-   NAME, COMP_DIR, LOW_PC are passed to start_symtab.  */
+/* Start a symtab for DWARF.  NAME, COMP_DIR, LOW_PC are passed to the
+   buildsym_compunit constructor.  */
 
 static struct compunit_symtab *
 dwarf2_start_symtab (struct dwarf2_cu *cu,
 		     const char *name, const char *comp_dir, CORE_ADDR low_pc)
 {
-  struct compunit_symtab *cust
-    = start_symtab (cu->per_cu->dwarf2_per_objfile->objfile, name, comp_dir,
-		    low_pc, cu->language);
+  gdb_assert (!bool (cu->builder));
+
+  cu->builder.reset (new struct buildsym_compunit
+		     (cu->per_cu->dwarf2_per_objfile->objfile,
+		      name, comp_dir, cu->language, low_pc));
 
-  cu->list_in_scope = get_file_symbols ();
+  cu->list_in_scope = cu->builder->get_file_symbols ();
 
-  record_debugformat ("DWARF 2");
-  record_producer (cu->producer);
+  cu->builder->record_debugformat ("DWARF 2");
+  cu->builder->record_producer (cu->producer);
 
   cu->processing_has_namespace_info = 0;
 
-  return cust;
+  return cu->builder->get_compunit_symtab ();
 }
 
 static void
@@ -21326,7 +21354,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
                  access them globally.  For instance, we want to be able
                  to break on a nested subprogram without having to
                  specify the context.  */
-	      list_to_add = get_global_symbols ();
+	      list_to_add = cu->builder->get_global_symbols ();
 	    }
 	  else
 	    {
@@ -21369,7 +21397,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	      if (!suppress_add)
 		{
 		  if (attr2 && (DW_UNSND (attr2) != 0))
-		    list_to_add = get_global_symbols ();
+		    list_to_add = cu->builder->get_global_symbols ();
 		  else
 		    list_to_add = cu->list_in_scope;
 		}
@@ -21414,8 +21442,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 
 		  /* A variable with DW_AT_external is never static,
 		     but it may be block-scoped.  */
-		  list_to_add = (cu->list_in_scope == get_file_symbols ()
-				 ? get_global_symbols () : cu->list_in_scope);
+		  list_to_add
+		    = (cu->list_in_scope == cu->builder->get_file_symbols ()
+		       ? cu->builder->get_global_symbols ()
+		       : cu->list_in_scope);
 		}
 	      else
 		list_to_add = cu->list_in_scope;
@@ -21445,8 +21475,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 		{
 		  /* A variable with DW_AT_external is never static, but it
 		     may be block-scoped.  */
-		  list_to_add = (cu->list_in_scope == get_file_symbols ()
-				 ? get_global_symbols () : cu->list_in_scope);
+		  list_to_add
+		    = (cu->list_in_scope == cu->builder->get_file_symbols ()
+		       ? cu->builder->get_global_symbols ()
+		       : cu->list_in_scope);
 
 		  SYMBOL_ACLASS_INDEX (sym) = LOC_UNRESOLVED;
 		}
@@ -21466,7 +21498,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	       when we do not have enough information to show inlined frames;
 	       pretend it's a local variable in that case so that the user can
 	       still see it.  */
-	    struct context_stack *curr = get_current_context_stack ();
+	    struct context_stack *curr
+	      = cu->builder->get_current_context_stack ();
 	    if (curr != nullptr && curr->name != nullptr)
 	      SYMBOL_IS_ARGUMENT (sym) = 1;
 	    attr = dwarf2_attr (die, DW_AT_location, cu);
@@ -21511,9 +21544,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 
 	    if (!suppress_add)
 	      {
-		list_to_add = (cu->list_in_scope == get_file_symbols ()
-			       && cu->language == language_cplus
-			       ? get_global_symbols () : cu->list_in_scope);
+		list_to_add
+		  = (cu->list_in_scope == cu->builder->get_file_symbols ()
+		     && cu->language == language_cplus
+		     ? cu->builder->get_global_symbols ()
+		     : cu->list_in_scope);
 
 		/* The semantics of C++ state that "struct foo {
 		   ... }" also defines a typedef for "foo".  */
@@ -21552,20 +21587,22 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	    /* NOTE: carlton/2003-11-10: See comment above in the
 	       DW_TAG_class_type, etc. block.  */
 
-	    list_to_add = (cu->list_in_scope == get_file_symbols ()
-			   && cu->language == language_cplus
-			   ? get_global_symbols () : cu->list_in_scope);
+	    list_to_add
+	      = (cu->list_in_scope == cu->builder->get_file_symbols ()
+		 && cu->language == language_cplus
+		 ? cu->builder->get_global_symbols ()
+		 : cu->list_in_scope);
 	  }
 	  break;
 	case DW_TAG_imported_declaration:
 	case DW_TAG_namespace:
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
-	  list_to_add = get_global_symbols ();
+	  list_to_add = cu->builder->get_global_symbols ();
 	  break;
 	case DW_TAG_module:
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
 	  SYMBOL_DOMAIN (sym) = MODULE_DOMAIN;
-	  list_to_add = get_global_symbols ();
+	  list_to_add = cu->builder->get_global_symbols ();
 	  break;
 	case DW_TAG_common_block:
 	  SYMBOL_ACLASS_INDEX (sym) = LOC_COMMON_BLOCK;
@@ -21596,8 +21633,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	 namespaces based on the demangled name.  */
       if (!cu->processing_has_namespace_info
 	  && cu->language == language_cplus)
-	cp_scan_for_anonymous_namespaces (get_buildsym_compunit (), sym,
-					  objfile);
+	cp_scan_for_anonymous_namespaces (cu->builder.get (), sym, objfile);
     }
   return (sym);
 }
@@ -23820,7 +23856,8 @@ file_full_name (int file, struct line_header *lh, const char *comp_dir)
 
 
 static struct macro_source_file *
-macro_start_file (int file, int line,
+macro_start_file (struct dwarf2_cu *cu,
+		  int file, int line,
                   struct macro_source_file *current_file,
                   struct line_header *lh)
 {
@@ -23831,7 +23868,7 @@ macro_start_file (int file, int line,
     {
       /* Note: We don't create a macro table for this compilation unit
 	 at all until we actually get a filename.  */
-      struct macro_table *macro_table = get_macro_table ();
+      struct macro_table *macro_table = cu->builder->get_macro_table ();
 
       /* If we have no current file, then this must be the start_file
 	 directive for the compilation unit's main source file.  */
@@ -24200,6 +24237,7 @@ dwarf_parse_macro_header (const gdb_byte **opcode_definitions,
 
 static void
 dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
+			  struct dwarf2_cu *cu,
 			  bfd *abfd,
 			  const gdb_byte *mac_ptr, const gdb_byte *mac_end,
 			  struct macro_source_file *current_file,
@@ -24355,7 +24393,8 @@ dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
 		at_commandline = 0;
 	      }
 	    else
-	      current_file = macro_start_file (file, line, current_file, lh);
+	      current_file = macro_start_file (cu, file, line, current_file,
+					       lh);
           }
           break;
 
@@ -24439,7 +24478,7 @@ dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
 	      {
 		*slot = (void *) new_mac_ptr;
 
-		dwarf_decode_macro_bytes (dwarf2_per_objfile,
+		dwarf_decode_macro_bytes (dwarf2_per_objfile, cu,
 					  include_bfd, new_mac_ptr,
 					  include_mac_end, current_file, lh,
 					  section, section_is_gnu, is_dwz,
@@ -24602,7 +24641,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	    file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 
-	    current_file = macro_start_file (file, line, current_file, lh);
+	    current_file = macro_start_file (cu, file, line, current_file, lh);
 	  }
 	  break;
 
@@ -24667,7 +24706,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
   mac_ptr = section->buffer + offset;
   slot = htab_find_slot (include_hash.get (), mac_ptr, INSERT);
   *slot = (void *) mac_ptr;
-  dwarf_decode_macro_bytes (dwarf2_per_objfile,
+  dwarf_decode_macro_bytes (dwarf2_per_objfile, cu,
 			    abfd, mac_ptr, mac_end,
 			    current_file, lh, section,
 			    section_is_gnu, 0, offset_size,
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 31/42] Remove a TODO
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (36 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 33/42] Remove parameter from record_pending_block Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  3:42   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 37/42] Move struct buildsym_compunit to buildsym.h Tom Tromey
                   ` (5 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes a TODO comment -- the work has been done.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c: Remove TODO comment.
---
 gdb/ChangeLog  | 4 ++++
 gdb/buildsym.c | 3 +--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index fec06f3d88..a39c003e7c 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -90,8 +90,7 @@
 
 #include "stabsread.h"
 
-/* Buildsym's counterpart to struct compunit_symtab.
-   TODO(dje): Move all related global state into here.  */
+/* Buildsym's counterpart to struct compunit_symtab.  */
 
 struct buildsym_compunit
 {
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 11/42] Move processing_gcc to stabsread
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (27 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 34/42] Add many methods to buildsym_compunit Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-08 16:46   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 24/42] Move pending_blocks and pending_block_obstack to buildsym_compunit Tom Tromey
                   ` (14 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

processing_gcc is also only used by stabsread -- it is set by the
DWARF reader, but this turns out not to be needed.  So, this patch
moves processing_gcc and removes the assignment from the DWARF reader.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* stabsread.h (processing_gcc_compilation): Move from buildsym.h.
	* dwarf2read.c (dwarf2_start_symtab): Don't set
	processing_gcc_compilation.
	* buildsym.h (processing_gcc_compilation): Move to stabsread.h.
---
 gdb/ChangeLog    | 7 +++++++
 gdb/buildsym.h   | 5 -----
 gdb/dwarf2read.c | 3 ---
 gdb/stabsread.h  | 5 +++++
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 0b19c39305..01d9acc2c9 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -66,11 +66,6 @@ struct subfile
 
 EXTERN struct subfile *current_subfile;
 
-/* Global variable which, when set, indicates that we are processing a
-   .o file compiled with gcc */
-
-EXTERN unsigned char processing_gcc_compilation;
-
 /* Record the symbols defined for each context in a list.  We don't
    create a struct block for the context until we know how long to
    make it.  */
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 49ce83ff20..4871787583 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -21144,9 +21144,6 @@ dwarf2_start_symtab (struct dwarf2_cu *cu,
   record_debugformat ("DWARF 2");
   record_producer (cu->producer);
 
-  /* We assume that we're processing GCC output.  */
-  processing_gcc_compilation = 2;
-
   cu->processing_has_namespace_info = 0;
 
   return cust;
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index 7958990112..fdb404a25d 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -46,6 +46,11 @@ EXTERN unsigned int symnum;
 
 EXTERN const char *(*next_symbol_text_func) (struct objfile *);
 
+/* Global variable which, when set, indicates that we are processing a
+   .o file compiled with gcc */
+
+EXTERN unsigned char processing_gcc_compilation;
+
 /* Hash table of global symbols whose values are not known yet.
    They are chained thru the SYMBOL_VALUE_CHAIN, since we don't
    have the correct data for that slot yet.
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 24/42] Move pending_blocks and pending_block_obstack to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (28 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 11/42] Move processing_gcc to stabsread Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  2:05   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 40/42] Convert the DWARF reader to new-style buildysm Tom Tromey
                   ` (13 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the pending_blocks and pending_block_obstack into
buildsym_compunit.

The obstack could perhaps be merged with the addrmap obstack, but I
did not do that in this series.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (struct buildsym_compunit) <free_pending_blocks>: New
	method.
	<m_pending_block_obstack, m_pending_blocks>: New members.
	(pending_block_obstack, pending_blocks): Remove.
	(scoped_free_pendings::scoped_free_pendings): Remove assert.
	(~scoped_free_pendings): Update.
	(free_pending_blocks): Remove.
	(finish_block_internal, record_pending_block, make_blockvector)
	(end_symtab_get_static_block, augment_type_symtab, push_context)
	(buildsym_init): Update.
---
 gdb/ChangeLog  | 13 ++++++++++
 gdb/buildsym.c | 80 +++++++++++++++++++++++++---------------------------------
 2 files changed, 47 insertions(+), 46 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 179810f463..3f367a3b55 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -155,6 +155,14 @@ struct buildsym_compunit
     return result;
   }
 
+  /* This function is called to discard any pending blocks.  */
+
+  void free_pending_blocks ()
+  {
+    m_pending_block_obstack.clear ();
+    m_pending_blocks = nullptr;
+  }
+
   /* The objfile we're reading debug info from.  */
   struct objfile *objfile;
 
@@ -234,6 +242,15 @@ struct buildsym_compunit
      we start processing a symfile, and if it's still false at the
      end, then we just toss the addrmap.  */
   bool m_pending_addrmap_interesting = false;
+
+  /* An obstack used for allocating pending blocks.  */
+  auto_obstack m_pending_block_obstack;
+
+  /* Pointer to the head of a linked list of symbol blocks which have
+     already been finalized (lexical contexts already closed) and which
+     are just waiting to be built into a blockvector when finalizing the
+     associated symtab.  */
+  struct pending_block *m_pending_blocks = nullptr;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -245,10 +262,6 @@ static struct buildsym_compunit *buildsym_compunit;
 
 static struct pending *free_pendings;
 
-/* An obstack used for allocating pending blocks.  */
-
-static struct obstack pending_block_obstack;
-
 /* List of blocks already made (lexical contexts already closed).
    This is used at the end to make the blockvector.  */
 
@@ -258,13 +271,6 @@ struct pending_block
     struct block *block;
   };
 
-/* Pointer to the head of a linked list of symbol blocks which have
-   already been finalized (lexical contexts already closed) and which
-   are just waiting to be built into a blockvector when finalizing the
-   associated symtab.  */
-
-static struct pending_block *pending_blocks;
-
 static void free_buildsym_compunit (void);
 
 static int compare_line_numbers (const void *ln1p, const void *ln2p);
@@ -273,8 +279,6 @@ static void record_pending_block (struct objfile *objfile,
 				  struct block *block,
 				  struct pending_block *opblock);
 
-static void free_pending_blocks ();
-
 /* Initial sizes of data structures.  These are realloc'd larger if
    needed, and realloc'd down to the size actually used, when
    completed.  */
@@ -344,7 +348,6 @@ find_symbol_in_list (struct pending *list, char *name, int length)
 
 scoped_free_pendings::scoped_free_pendings ()
 {
-  gdb_assert (pending_blocks == nullptr);
 }
 
 /* At end of reading syms, or in case of quit, ensure everything
@@ -364,8 +367,6 @@ scoped_free_pendings::~scoped_free_pendings ()
     }
   free_pendings = NULL;
 
-  free_pending_blocks ();
-
   for (next = file_symbols; next != NULL; next = next1)
     {
       next1 = next->next;
@@ -383,18 +384,6 @@ scoped_free_pendings::~scoped_free_pendings ()
   free_buildsym_compunit ();
 }
 
-/* This function is called to discard any pending blocks.  */
-
-static void
-free_pending_blocks ()
-{
-  if (pending_blocks != NULL)
-    {
-      obstack_free (&pending_block_obstack, NULL);
-      pending_blocks = NULL;
-    }
-}
-
 /* Take one of the lists of symbols and make a block from it.  Keep
    the order the symbols have in the list (reversed from the input
    file).  Put the block on the list of pending blocks.  */
@@ -537,7 +526,7 @@ finish_block_internal (struct symbol *symbol,
      start of this scope that don't have superblocks yet.  */
 
   opblock = NULL;
-  for (pblock = pending_blocks; 
+  for (pblock = buildsym_compunit->m_pending_blocks; 
        pblock && pblock != old_blocks; 
        pblock = pblock->next)
     {
@@ -619,10 +608,8 @@ record_pending_block (struct objfile *objfile, struct block *block,
 {
   struct pending_block *pblock;
 
-  if (pending_blocks == NULL)
-    obstack_init (&pending_block_obstack);
-
-  pblock = XOBNEW (&pending_block_obstack, struct pending_block);
+  pblock = XOBNEW (&buildsym_compunit->m_pending_block_obstack,
+		   struct pending_block);
   pblock->block = block;
   if (opblock)
     {
@@ -631,8 +618,8 @@ record_pending_block (struct objfile *objfile, struct block *block,
     }
   else
     {
-      pblock->next = pending_blocks;
-      pending_blocks = pblock;
+      pblock->next = buildsym_compunit->m_pending_blocks;
+      buildsym_compunit->m_pending_blocks = pblock;
     }
 }
 
@@ -676,8 +663,10 @@ make_blockvector (void)
 
   /* Count the length of the list of blocks.  */
 
-  for (next = pending_blocks, i = 0; next; next = next->next, i++)
-    {;
+  for (next = buildsym_compunit->m_pending_blocks, i = 0;
+       next;
+       next = next->next, i++)
+    {
     }
 
   blockvector = (struct blockvector *)
@@ -692,12 +681,12 @@ make_blockvector (void)
      sure this is true.  */
 
   BLOCKVECTOR_NBLOCKS (blockvector) = i;
-  for (next = pending_blocks; next; next = next->next)
+  for (next = buildsym_compunit->m_pending_blocks; next; next = next->next)
     {
       BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
     }
 
-  free_pending_blocks ();
+  buildsym_compunit->free_pending_blocks ();
 
   /* If we needed an address map for this symtab, record it in the
      blockvector.  */
@@ -1236,13 +1225,13 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
   /* Reordered executables may have out of order pending blocks; if
      OBJF_REORDERED is true, then sort the pending blocks.  */
 
-  if ((objfile->flags & OBJF_REORDERED) && pending_blocks)
+  if ((objfile->flags & OBJF_REORDERED) && buildsym_compunit->m_pending_blocks)
     {
       struct pending_block *pb;
 
       std::vector<block *> barray;
 
-      for (pb = pending_blocks; pb != NULL; pb = pb->next)
+      for (pb = buildsym_compunit->m_pending_blocks; pb != NULL; pb = pb->next)
 	barray.push_back (pb->block);
 
       /* Sort blocks by start address in descending order.  Blocks with the
@@ -1255,7 +1244,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
 			});
 
       int i = 0;
-      for (pb = pending_blocks; pb != NULL; pb = pb->next)
+      for (pb = buildsym_compunit->m_pending_blocks; pb != NULL; pb = pb->next)
 	pb->block = barray[i++];
     }
 
@@ -1273,7 +1262,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
   finish_global_stabs (objfile);
 
   if (!required
-      && pending_blocks == NULL
+      && buildsym_compunit->m_pending_blocks == NULL
       && file_symbols == NULL
       && global_symbols == NULL
       && buildsym_compunit->m_have_line_numbers == 0
@@ -1576,7 +1565,7 @@ augment_type_symtab (void)
   if (!buildsym_compunit->m_context_stack.empty ())
     complaint (&symfile_complaints,
 	       _("Context stack not empty in augment_type_symtab"));
-  if (pending_blocks != NULL)
+  if (buildsym_compunit->m_pending_blocks != NULL)
     complaint (&symfile_complaints, _("Blocks in a type symtab"));
   if (buildsym_compunit->m_pending_macros != NULL)
     complaint (&symfile_complaints, _("Macro in a type symtab"));
@@ -1623,7 +1612,7 @@ push_context (int desc, CORE_ADDR valu)
 
   newobj->depth = desc;
   newobj->locals = local_symbols;
-  newobj->old_blocks = pending_blocks;
+  newobj->old_blocks = buildsym_compunit->m_pending_blocks;
   newobj->start_addr = valu;
   newobj->local_using_directives
     = buildsym_compunit->m_local_using_directives;
@@ -1780,7 +1769,6 @@ buildsym_init ()
   /* Ensure the scoped_free_pendings destructor was called after
      the last time.  */
   gdb_assert (free_pendings == NULL);
-  gdb_assert (pending_blocks == NULL);
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
   gdb_assert (buildsym_compunit == NULL);
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 34/42] Add many methods to buildsym_compunit
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (26 preceding siblings ...)
  2018-05-23  4:59 ` [RFA 12/42] Move within_function to stabsread Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-06 19:16   ` Keith Seitz
                     ` (2 more replies)
  2018-05-23  6:16 ` [RFA 11/42] Move processing_gcc to stabsread Tom Tromey
                   ` (15 subsequent siblings)
  43 siblings, 3 replies; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds many methods to buildsym_compunit and makes the data members
private.  Essentially the entire buildsym API is now available as a
method on buildsym_compunit.  However, standalone functions are still
provided, as this is what the sybmol readers actually use.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (buildsym_compunit::buildsym_compunit): Do more
	initialization.
	(buildsym_compunit): Add new constructor.
	(struct buildsym_compunit) <get_last_source_file, finish_block,
	record_block_range, start_subfile, patch_subfile_names,
	push_subfile, pop_subfile, record_line, get_compunit_symtab,
	set_last_source_start_addr, get_last_source_start_addr,
	get_local_using_directives, set_local_using_directives,
	get_global_using_directives, outermost_context_p,
	get_current_context_stack, get_context_stack_depth,
	get_current_subfile, get_local_symbols, get_file_symbols,
	get_global_symbols, record_debugformat, record_producer,
	push_context, pop_context, end_symtab_get_static_block,
	end_symtab_from_static_block, end_symtab, end_expandable_symtab>:
	New public methods.
	<record_pending_block, finish_block_internal, make_blockvector,
	watch_main_source_file_lossage, end_symtab_with_blockvector>: New
	private methods.
	Update all users.
---
 gdb/ChangeLog  |  22 +++
 gdb/buildsym.c | 610 +++++++++++++++++++++++++++++++++++++++------------------
 2 files changed, 444 insertions(+), 188 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index c965776d82..b9be6dd61a 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -103,6 +103,32 @@ struct buildsym_compunit
       language (language_),
       m_last_source_start_addr (last_addr)
   {
+    /* Allocate the compunit symtab now.  The caller needs it to allocate
+       non-primary symtabs.  It is also needed by get_macro_table.  */
+    compunit_symtab = allocate_compunit_symtab (objfile, name);
+
+    /* Build the subfile for NAME (the main source file) so that we can record
+       a pointer to it for later.
+       IMPORTANT: Do not allocate a struct symtab for NAME here.
+       It can happen that the debug info provides a different path to NAME than
+       DIRNAME,NAME.  We cope with this in watch_main_source_file_lossage but
+       that only works if the main_subfile doesn't have a symtab yet.  */
+    start_subfile (name);
+    /* Save this so that we don't have to go looking for it at the end
+       of the subfiles list.  */
+    main_subfile = m_current_subfile;
+  }
+
+  buildsym_compunit (struct objfile *objfile_, const char *name,
+		     const char *comp_dir_, enum language language_,
+		     CORE_ADDR last_addr, struct compunit_symtab *cust)
+    : objfile (objfile_),
+      m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
+      comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
+      compunit_symtab (cust),
+      language (language_),
+      m_last_source_start_addr (last_addr)
+  {
   }
 
   ~buildsym_compunit ()
@@ -143,6 +169,11 @@ struct buildsym_compunit
     m_last_source_file.reset (new_name);
   }
 
+  const char *get_last_source_file ()
+  {
+    return m_last_source_file.get ();
+  }
+
   struct macro_table *get_macro_table ()
   {
     if (m_pending_macros == nullptr)
@@ -167,6 +198,136 @@ struct buildsym_compunit
     m_pending_blocks = nullptr;
   }
 
+  struct block *finish_block (struct symbol *symbol,
+			      struct pending_block *old_blocks,
+			      const struct dynamic_prop *static_link,
+			      CORE_ADDR start, CORE_ADDR end);
+
+  void record_block_range (struct block *block,
+			   CORE_ADDR start, CORE_ADDR end_inclusive);
+
+  void start_subfile (const char *name);
+
+  void patch_subfile_names (struct subfile *subfile, const char *name);
+
+  void push_subfile ();
+
+  const char *pop_subfile ();
+
+  void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
+
+  struct compunit_symtab *get_compunit_symtab ()
+  {
+    return compunit_symtab;
+  }
+
+  void set_last_source_start_addr (CORE_ADDR addr)
+  {
+    m_last_source_start_addr = addr;
+  }
+
+  CORE_ADDR get_last_source_start_addr ()
+  {
+    return m_last_source_start_addr;
+  }
+
+  struct using_direct **get_local_using_directives ()
+  {
+    return &m_local_using_directives;
+  }
+
+  void set_local_using_directives (struct using_direct *new_local)
+  {
+    m_local_using_directives = new_local;
+  }
+
+  struct using_direct **get_global_using_directives ()
+  {
+    return &m_global_using_directives;
+  }
+
+  bool outermost_context_p () const
+  {
+    return m_context_stack.empty ();
+  }
+
+  struct context_stack *get_current_context_stack ()
+  {
+    if (m_context_stack.empty ())
+      return nullptr;
+    return &m_context_stack.back ();
+  }
+
+  int get_context_stack_depth () const
+  {
+    return m_context_stack.size ();
+  }
+
+  struct subfile *get_current_subfile ()
+  {
+    return m_current_subfile;
+  }
+
+  struct pending **get_local_symbols ()
+  {
+    return &m_local_symbols;
+  }
+
+  struct pending **get_file_symbols ()
+  {
+    return &m_file_symbols;
+  }
+
+  struct pending **get_global_symbols ()
+  {
+    return &m_global_symbols;
+  }
+
+  void record_debugformat (const char *format)
+  {
+    debugformat = format;
+  }
+
+  void record_producer (const char *producer)
+  {
+    this->producer = producer;
+  }
+
+  struct context_stack *push_context (int desc, CORE_ADDR valu);
+
+  struct context_stack *pop_context ();
+
+  struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
+					     int expandable, int required);
+
+  struct compunit_symtab *end_symtab_from_static_block
+      (struct block *static_block, int section, int expandable);
+
+  struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
+
+  struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
+						 int section);
+
+  void augment_type_symtab ();
+
+private:
+
+  void record_pending_block (struct block *block, struct pending_block *opblock);
+
+  struct block *finish_block_internal (struct symbol *symbol,
+				       struct pending **listhead,
+				       struct pending_block *old_blocks,
+				       const struct dynamic_prop *static_link,
+				       CORE_ADDR start, CORE_ADDR end,
+				       int is_global, int expandable);
+
+  struct blockvector *make_blockvector ();
+
+  void watch_main_source_file_lossage ();
+
+  struct compunit_symtab *end_symtab_with_blockvector
+      (struct block *static_block, int section, int expandable);
+
   /* The objfile we're reading debug info from.  */
   struct objfile *objfile;
 
@@ -366,13 +527,13 @@ scoped_free_pendings::~scoped_free_pendings ()
    OPBLOCK, or at the beginning if opblock is NULL.  This puts the
    block in the list after all its subblocks.  */
 
-static void
-record_pending_block (struct block *block, struct pending_block *opblock)
+void
+buildsym_compunit::record_pending_block (struct block *block,
+					 struct pending_block *opblock)
 {
   struct pending_block *pblock;
 
-  pblock = XOBNEW (&buildsym_compunit->m_pending_block_obstack,
-		   struct pending_block);
+  pblock = XOBNEW (&m_pending_block_obstack, struct pending_block);
   pblock->block = block;
   if (opblock)
     {
@@ -381,8 +542,8 @@ record_pending_block (struct block *block, struct pending_block *opblock)
     }
   else
     {
-      pblock->next = buildsym_compunit->m_pending_blocks;
-      buildsym_compunit->m_pending_blocks = pblock;
+      pblock->next = m_pending_blocks;
+      m_pending_blocks = pblock;
     }
 }
 
@@ -390,15 +551,15 @@ record_pending_block (struct block *block, struct pending_block *opblock)
    the order the symbols have in the list (reversed from the input
    file).  Put the block on the list of pending blocks.  */
 
-static struct block *
-finish_block_internal (struct symbol *symbol,
-		       struct pending **listhead,
-		       struct pending_block *old_blocks,
-		       const struct dynamic_prop *static_link,
-		       CORE_ADDR start, CORE_ADDR end,
-		       int is_global, int expandable)
+struct block *
+buildsym_compunit::finish_block_internal
+    (struct symbol *symbol,
+     struct pending **listhead,
+     struct pending_block *old_blocks,
+     const struct dynamic_prop *static_link,
+     CORE_ADDR start, CORE_ADDR end,
+     int is_global, int expandable)
 {
-  struct objfile *objfile = buildsym_compunit->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct pending *next, *next1;
   struct block *block;
@@ -413,21 +574,20 @@ finish_block_internal (struct symbol *symbol,
     {
       BLOCK_DICT (block)
 	= dict_create_linear (&objfile->objfile_obstack,
-			      buildsym_compunit->language, *listhead);
+			      language, *listhead);
     }
   else
     {
       if (expandable)
 	{
-	  BLOCK_DICT (block)
-	    = dict_create_hashed_expandable (buildsym_compunit->language);
+	  BLOCK_DICT (block) = dict_create_hashed_expandable (language);
 	  dict_add_pending (BLOCK_DICT (block), *listhead);
 	}
       else
 	{
 	  BLOCK_DICT (block) =
 	    dict_create_hashed (&objfile->objfile_obstack,
-				buildsym_compunit->language, *listhead);
+				language, *listhead);
 	}
     }
 
@@ -527,7 +687,7 @@ finish_block_internal (struct symbol *symbol,
      start of this scope that don't have superblocks yet.  */
 
   opblock = NULL;
-  for (pblock = buildsym_compunit->m_pending_blocks; 
+  for (pblock = m_pending_blocks;
        pblock && pblock != old_blocks; 
        pblock = pblock->next)
     {
@@ -572,13 +732,13 @@ finish_block_internal (struct symbol *symbol,
 
   block_set_using (block,
 		   (is_global
-		    ? buildsym_compunit->m_global_using_directives
-		    : buildsym_compunit->m_local_using_directives),
+		    ? m_global_using_directives
+		    : m_local_using_directives),
 		   &objfile->objfile_obstack);
   if (is_global)
-    buildsym_compunit->m_global_using_directives = NULL;
+    m_global_using_directives = NULL;
   else
-    buildsym_compunit->m_local_using_directives = NULL;
+    m_local_using_directives = NULL;
 
   record_pending_block (block, opblock);
 
@@ -586,14 +746,13 @@ finish_block_internal (struct symbol *symbol,
 }
 
 struct block *
-finish_block (struct symbol *symbol,
-	      struct pending_block *old_blocks,
-	      const struct dynamic_prop *static_link,
-	      CORE_ADDR start, CORE_ADDR end)
+buildsym_compunit::finish_block (struct symbol *symbol,
+				 struct pending_block *old_blocks,
+				 const struct dynamic_prop *static_link,
+				 CORE_ADDR start, CORE_ADDR end)
 {
-  return finish_block_internal (symbol, &buildsym_compunit->m_local_symbols,
-				old_blocks, static_link,
-				start, end, 0, 0);
+  return finish_block_internal (symbol, &m_local_symbols,
+				old_blocks, static_link, start, end, 0, 0);
 }
 
 /* Record that the range of addresses from START to END_INCLUSIVE
@@ -605,8 +764,9 @@ finish_block (struct symbol *symbol,
    already provided by BLOCK_START and BLOCK_END, then we create an
    address map for the block.  */
 void
-record_block_range (struct block *block,
-                    CORE_ADDR start, CORE_ADDR end_inclusive)
+buildsym_compunit::record_block_range (struct block *block,
+				       CORE_ADDR start,
+				       CORE_ADDR end_inclusive)
 {
   /* If this is any different from the range recorded in the block's
      own BLOCK_START and BLOCK_END, then note that the address map has
@@ -615,29 +775,24 @@ record_block_range (struct block *block,
      need to record this block in the addrmap.  */
   if (start != BLOCK_START (block)
       || end_inclusive + 1 != BLOCK_END (block))
-    buildsym_compunit->m_pending_addrmap_interesting = true;
+    m_pending_addrmap_interesting = true;
 
-  if (! buildsym_compunit->m_pending_addrmap)
-    buildsym_compunit->m_pending_addrmap
-      = addrmap_create_mutable (&buildsym_compunit->m_pending_addrmap_obstack);
+  if (! m_pending_addrmap)
+    m_pending_addrmap = addrmap_create_mutable (&m_pending_addrmap_obstack);
 
-  addrmap_set_empty (buildsym_compunit->m_pending_addrmap,
-		     start, end_inclusive, block);
+  addrmap_set_empty (m_pending_addrmap, start, end_inclusive, block);
 }
 
-static struct blockvector *
-make_blockvector (void)
+struct blockvector *
+buildsym_compunit::make_blockvector ()
 {
-  struct objfile *objfile = buildsym_compunit->objfile;
   struct pending_block *next;
   struct blockvector *blockvector;
   int i;
 
   /* Count the length of the list of blocks.  */
 
-  for (next = buildsym_compunit->m_pending_blocks, i = 0;
-       next;
-       next = next->next, i++)
+  for (next = m_pending_blocks, i = 0; next; next = next->next, i++)
     {
     }
 
@@ -653,20 +808,18 @@ make_blockvector (void)
      sure this is true.  */
 
   BLOCKVECTOR_NBLOCKS (blockvector) = i;
-  for (next = buildsym_compunit->m_pending_blocks; next; next = next->next)
+  for (next = m_pending_blocks; next; next = next->next)
     {
       BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
     }
 
-  buildsym_compunit->free_pending_blocks ();
+  free_pending_blocks ();
 
   /* If we needed an address map for this symtab, record it in the
      blockvector.  */
-  if (buildsym_compunit->m_pending_addrmap
-      && buildsym_compunit->m_pending_addrmap_interesting)
+  if (m_pending_addrmap && m_pending_addrmap_interesting)
     BLOCKVECTOR_MAP (blockvector)
-      = addrmap_create_fixed (buildsym_compunit->m_pending_addrmap,
-			      &objfile->objfile_obstack);
+      = addrmap_create_fixed (m_pending_addrmap, &objfile->objfile_obstack);
   else
     BLOCKVECTOR_MAP (blockvector) = 0;
 
@@ -700,18 +853,16 @@ make_blockvector (void)
    name.  NAME is the name of the file (cannot be NULL).  */
 
 void
-start_subfile (const char *name)
+buildsym_compunit::start_subfile (const char *name)
 {
   const char *subfile_dirname;
   struct subfile *subfile;
 
-  gdb_assert (buildsym_compunit != NULL);
-
-  subfile_dirname = buildsym_compunit->comp_dir.get ();
+  subfile_dirname = comp_dir.get ();
 
   /* See if this subfile is already registered.  */
 
-  for (subfile = buildsym_compunit->subfiles; subfile; subfile = subfile->next)
+  for (subfile = subfiles; subfile; subfile = subfile->next)
     {
       char *subfile_name;
 
@@ -727,7 +878,7 @@ start_subfile (const char *name)
 
       if (FILENAME_CMP (subfile_name, name) == 0)
 	{
-	  buildsym_compunit->m_current_subfile = subfile;
+	  m_current_subfile = subfile;
 	  if (subfile_name != subfile->name)
 	    xfree (subfile_name);
 	  return;
@@ -740,12 +891,12 @@ start_subfile (const char *name)
 
   subfile = XNEW (struct subfile);
   memset (subfile, 0, sizeof (struct subfile));
-  subfile->buildsym_compunit = buildsym_compunit;
+  subfile->buildsym_compunit = this;
 
-  subfile->next = buildsym_compunit->subfiles;
-  buildsym_compunit->subfiles = subfile;
+  subfile->next = subfiles;
+  subfiles = subfile;
 
-  buildsym_compunit->m_current_subfile = subfile;
+  m_current_subfile = subfile;
 
   subfile->name = xstrdup (name);
 
@@ -781,7 +932,7 @@ start_subfile (const char *name)
       enum language sublang = deduce_language_from_filename (subfile->name);
 
       if (sublang == language_cplus || sublang == language_fortran)
-	for (s = buildsym_compunit->subfiles; s != NULL; s = s->next)
+	for (s = subfiles; s != NULL; s = s->next)
 	  if (s->language == language_c)
 	    s->language = sublang;
     }
@@ -820,14 +971,15 @@ free_buildsym_compunit (void)
    directory name actually is (by checking for a trailing '/').  */
 
 void
-patch_subfile_names (struct subfile *subfile, const char *name)
+buildsym_compunit::patch_subfile_names (struct subfile *subfile,
+					const char *name)
 {
   if (subfile != NULL
-      && buildsym_compunit->comp_dir == NULL
+      && comp_dir == NULL
       && subfile->name != NULL
       && IS_DIR_SEPARATOR (subfile->name[strlen (subfile->name) - 1]))
     {
-      buildsym_compunit->comp_dir.reset (subfile->name);
+      comp_dir.reset (subfile->name);
       subfile->name = xstrdup (name);
       set_last_source_file (name);
 
@@ -857,22 +1009,19 @@ patch_subfile_names (struct subfile *subfile, const char *name)
    order.  */
 
 void
-push_subfile ()
+buildsym_compunit::push_subfile ()
 {
-  gdb_assert (buildsym_compunit != nullptr);
-  gdb_assert (! (buildsym_compunit->m_current_subfile == NULL
-		 || buildsym_compunit->m_current_subfile->name == NULL));
-  buildsym_compunit->m_subfile_stack.push_back
-    (buildsym_compunit->m_current_subfile->name);
+  gdb_assert (! (m_current_subfile == NULL
+		 || m_current_subfile->name == NULL));
+  m_subfile_stack.push_back (m_current_subfile->name);
 }
 
 const char *
-pop_subfile ()
+buildsym_compunit::pop_subfile ()
 {
-  gdb_assert (buildsym_compunit != nullptr);
-  gdb_assert (!buildsym_compunit->m_subfile_stack.empty ());
-  const char *name = buildsym_compunit->m_subfile_stack.back ();
-  buildsym_compunit->m_subfile_stack.pop_back ();
+  gdb_assert (!m_subfile_stack.empty ());
+  const char *name = m_subfile_stack.back ();
+  m_subfile_stack.pop_back ();
   return name;
 }
 \f
@@ -880,7 +1029,8 @@ pop_subfile ()
    line vector for SUBFILE.  */
 
 void
-record_line (struct subfile *subfile, int line, CORE_ADDR pc)
+buildsym_compunit::record_line (struct subfile *subfile, int line,
+				CORE_ADDR pc)
 {
   struct linetable_entry *e;
 
@@ -898,7 +1048,7 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc)
 	xmalloc (sizeof (struct linetable)
 	   + subfile->line_vector_length * sizeof (struct linetable_entry));
       subfile->line_vector->nitems = 0;
-      buildsym_compunit->m_have_line_numbers = true;
+      m_have_line_numbers = true;
     }
 
   if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length)
@@ -967,7 +1117,7 @@ buildsym_compunit_symtab (void)
 {
   gdb_assert (buildsym_compunit != NULL);
 
-  return buildsym_compunit->compunit_symtab;
+  return buildsym_compunit->get_compunit_symtab ();
 }
 
 /* See buildsym.h.  */
@@ -1004,23 +1154,7 @@ start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
   buildsym_compunit = new struct buildsym_compunit (objfile, name, comp_dir,
 						    language, start_addr);
 
-  /* Allocate the compunit symtab now.  The caller needs it to allocate
-     non-primary symtabs.  It is also needed by get_macro_table.  */
-  buildsym_compunit->compunit_symtab = allocate_compunit_symtab (objfile,
-								 name);
-
-  /* Build the subfile for NAME (the main source file) so that we can record
-     a pointer to it for later.
-     IMPORTANT: Do not allocate a struct symtab for NAME here.
-     It can happen that the debug info provides a different path to NAME than
-     DIRNAME,NAME.  We cope with this in watch_main_source_file_lossage but
-     that only works if the main_subfile doesn't have a symtab yet.  */
-  start_subfile (name);
-  /* Save this so that we don't have to go looking for it at the end
-     of the subfiles list.  */
-  buildsym_compunit->main_subfile = buildsym_compunit->m_current_subfile;
-
-  return buildsym_compunit->compunit_symtab;
+  return buildsym_compunit->get_compunit_symtab ();
 }
 
 /* Restart compilation for a symtab.
@@ -1045,8 +1179,8 @@ restart_symtab (struct compunit_symtab *cust,
 				    name,
 				    COMPUNIT_DIRNAME (cust),
 				    compunit_language (cust),
-				    start_addr);
-  buildsym_compunit->compunit_symtab = cust;
+				    start_addr,
+				    cust);
 }
 
 /* Subroutine of end_symtab to simplify it.  Look for a subfile that
@@ -1059,18 +1193,13 @@ restart_symtab (struct compunit_symtab *cust,
    manipulates the debug info.  This can also happen from an innocent
    symlink in the paths, we don't canonicalize paths here.  */
 
-static void
-watch_main_source_file_lossage (void)
+void
+buildsym_compunit::watch_main_source_file_lossage ()
 {
   struct subfile *mainsub, *subfile;
 
-  /* We have to watch for buildsym_compunit == NULL here.  It's a quirk of
-     end_symtab, it can return NULL so there may not be a main subfile.  */
-  if (buildsym_compunit == NULL)
-    return;
-
   /* Get the main source file.  */
-  mainsub = buildsym_compunit->main_subfile;
+  mainsub = main_subfile;
 
   /* If the main source file doesn't have any line number or symbol
      info, look for an alias in another subfile.  */
@@ -1085,7 +1214,7 @@ watch_main_source_file_lossage (void)
       struct subfile *prev_mainsub_alias = NULL;
 
       prevsub = NULL;
-      for (subfile = buildsym_compunit->subfiles;
+      for (subfile = subfiles;
 	   subfile != NULL;
 	   subfile = subfile->next)
 	{
@@ -1113,7 +1242,7 @@ watch_main_source_file_lossage (void)
 	  mainsub->symtab = mainsub_alias->symtab;
 
 	  if (prev_mainsub_alias == NULL)
-	    buildsym_compunit->subfiles = mainsub_alias->next;
+	    subfiles = mainsub_alias->next;
 	  else
 	    prev_mainsub_alias->next = mainsub_alias->next;
 	  xfree (mainsub_alias->name);
@@ -1145,14 +1274,13 @@ reset_symtab_globals (void)
    not contain any symbols.  */
 
 struct block *
-end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
+buildsym_compunit::end_symtab_get_static_block (CORE_ADDR end_addr,
+						int expandable, int required)
 {
-  struct objfile *objfile = buildsym_compunit->objfile;
-
   /* Finish the lexical context of the last function in the file; pop
      the context stack.  */
 
-  if (!buildsym_compunit->m_context_stack.empty ())
+  if (!m_context_stack.empty ())
     {
       struct context_stack *cstk = pop_context ();
 
@@ -1160,7 +1288,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
       finish_block (cstk->name, cstk->old_blocks, NULL,
 		    cstk->start_addr, end_addr);
 
-      if (!buildsym_compunit->m_context_stack.empty ())
+      if (!m_context_stack.empty ())
 	{
 	  /* This is said to happen with SCO.  The old coffread.c
 	     code simply emptied the context stack, so we do the
@@ -1169,20 +1297,20 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
 	     it used to be an abort().  */
 	  complaint (&symfile_complaints,
 	             _("Context stack not empty in end_symtab"));
-	  buildsym_compunit->m_context_stack.clear ();
+	  m_context_stack.clear ();
 	}
     }
 
   /* Reordered executables may have out of order pending blocks; if
      OBJF_REORDERED is true, then sort the pending blocks.  */
 
-  if ((objfile->flags & OBJF_REORDERED) && buildsym_compunit->m_pending_blocks)
+  if ((objfile->flags & OBJF_REORDERED) && m_pending_blocks)
     {
       struct pending_block *pb;
 
       std::vector<block *> barray;
 
-      for (pb = buildsym_compunit->m_pending_blocks; pb != NULL; pb = pb->next)
+      for (pb = m_pending_blocks; pb != NULL; pb = pb->next)
 	barray.push_back (pb->block);
 
       /* Sort blocks by start address in descending order.  Blocks with the
@@ -1195,7 +1323,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
 			});
 
       int i = 0;
-      for (pb = buildsym_compunit->m_pending_blocks; pb != NULL; pb = pb->next)
+      for (pb = m_pending_blocks; pb != NULL; pb = pb->next)
 	pb->block = barray[i++];
     }
 
@@ -1213,12 +1341,12 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
   finish_global_stabs (objfile);
 
   if (!required
-      && buildsym_compunit->m_pending_blocks == NULL
-      && buildsym_compunit->m_file_symbols == NULL
-      && buildsym_compunit->m_global_symbols == NULL
-      && buildsym_compunit->m_have_line_numbers == 0
-      && buildsym_compunit->m_pending_macros == NULL
-      && buildsym_compunit->m_global_using_directives == NULL)
+      && m_pending_blocks == NULL
+      && m_file_symbols == NULL
+      && m_global_symbols == NULL
+      && m_have_line_numbers == 0
+      && m_pending_macros == NULL
+      && m_global_using_directives == NULL)
     {
       /* Ignore symtabs that have no functions with real debugging info.  */
       return NULL;
@@ -1227,7 +1355,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
     {
       /* Define the STATIC_BLOCK.  */
       return finish_block_internal (NULL, get_file_symbols (), NULL, NULL,
-				    buildsym_compunit->m_last_source_start_addr,
+				    m_last_source_start_addr,
 				    end_addr, 0, expandable);
     }
 }
@@ -1236,26 +1364,24 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
    Handle the "have blockvector" case.
    See end_symtab_from_static_block for a description of the arguments.  */
 
-static struct compunit_symtab *
-end_symtab_with_blockvector (struct block *static_block,
-			     int section, int expandable)
+struct compunit_symtab *
+buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
+						int section, int expandable)
 {
-  struct objfile *objfile = buildsym_compunit->objfile;
-  struct compunit_symtab *cu = buildsym_compunit->compunit_symtab;
+  struct compunit_symtab *cu = compunit_symtab;
   struct symtab *symtab;
   struct blockvector *blockvector;
   struct subfile *subfile;
   CORE_ADDR end_addr;
 
   gdb_assert (static_block != NULL);
-  gdb_assert (buildsym_compunit != NULL);
-  gdb_assert (buildsym_compunit->subfiles != NULL);
+  gdb_assert (subfiles != NULL);
 
   end_addr = BLOCK_END (static_block);
 
   /* Create the GLOBAL_BLOCK and build the blockvector.  */
   finish_block_internal (NULL, get_global_symbols (), NULL, NULL,
-			 buildsym_compunit->m_last_source_start_addr, end_addr,
+			 m_last_source_start_addr, end_addr,
 			 1, expandable);
   blockvector = make_blockvector ();
 
@@ -1272,7 +1398,7 @@ end_symtab_with_blockvector (struct block *static_block,
   /* Now create the symtab objects proper, if not already done,
      one for each subfile.  */
 
-  for (subfile = buildsym_compunit->subfiles;
+  for (subfile = subfiles;
        subfile != NULL;
        subfile = subfile->next)
     {
@@ -1325,7 +1451,7 @@ end_symtab_with_blockvector (struct block *static_block,
   {
     struct symtab *main_symtab, *prev_symtab;
 
-    main_symtab = buildsym_compunit->main_subfile->symtab;
+    main_symtab = main_subfile->symtab;
     prev_symtab = NULL;
     ALL_COMPUNIT_FILETABS (cu, symtab)
       {
@@ -1346,20 +1472,20 @@ end_symtab_with_blockvector (struct block *static_block,
 
   /* Fill out the compunit symtab.  */
 
-  if (buildsym_compunit->comp_dir != NULL)
+  if (comp_dir != NULL)
     {
       /* Reallocate the dirname on the symbol obstack.  */
-      const char *comp_dir = buildsym_compunit->comp_dir.get ();
+      const char *comp_dir = this->comp_dir.get ();
       COMPUNIT_DIRNAME (cu)
 	= (const char *) obstack_copy0 (&objfile->objfile_obstack,
 					comp_dir, strlen (comp_dir));
     }
 
   /* Save the debug format string (if any) in the symtab.  */
-  COMPUNIT_DEBUGFORMAT (cu) = buildsym_compunit->debugformat;
+  COMPUNIT_DEBUGFORMAT (cu) = debugformat;
 
   /* Similarly for the producer.  */
-  COMPUNIT_PRODUCER (cu) = buildsym_compunit->producer;
+  COMPUNIT_PRODUCER (cu) = producer;
 
   COMPUNIT_BLOCKVECTOR (cu) = blockvector;
   {
@@ -1370,7 +1496,7 @@ end_symtab_with_blockvector (struct block *static_block,
 
   COMPUNIT_BLOCK_LINE_SECTION (cu) = section;
 
-  COMPUNIT_MACRO_TABLE (cu) = buildsym_compunit->release_macros ();
+  COMPUNIT_MACRO_TABLE (cu) = release_macros ();
 
   /* Default any symbols without a specified symtab to the primary symtab.  */
   {
@@ -1415,8 +1541,8 @@ end_symtab_with_blockvector (struct block *static_block,
    expandable.  */
 
 struct compunit_symtab *
-end_symtab_from_static_block (struct block *static_block,
-			      int section, int expandable)
+buildsym_compunit::end_symtab_from_static_block (struct block *static_block,
+						 int section, int expandable)
 {
   struct compunit_symtab *cu;
 
@@ -1463,7 +1589,7 @@ end_symtab_from_static_block (struct block *static_block,
    yourself.  */
 
 struct compunit_symtab *
-end_symtab (CORE_ADDR end_addr, int section)
+buildsym_compunit::end_symtab (CORE_ADDR end_addr, int section)
 {
   struct block *static_block;
 
@@ -1474,7 +1600,7 @@ end_symtab (CORE_ADDR end_addr, int section)
 /* Same as end_symtab except create a symtab that can be later added to.  */
 
 struct compunit_symtab *
-end_expandable_symtab (CORE_ADDR end_addr, int section)
+buildsym_compunit::end_expandable_symtab (CORE_ADDR end_addr, int section)
 {
   struct block *static_block;
 
@@ -1508,19 +1634,19 @@ set_missing_symtab (struct pending *pending_list,
    This is the case for DWARF4 Type Units.  */
 
 void
-augment_type_symtab (void)
+buildsym_compunit::augment_type_symtab ()
 {
-  struct compunit_symtab *cust = buildsym_compunit->compunit_symtab;
+  struct compunit_symtab *cust = compunit_symtab;
   const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
 
-  if (!buildsym_compunit->m_context_stack.empty ())
+  if (!m_context_stack.empty ())
     complaint (&symfile_complaints,
 	       _("Context stack not empty in augment_type_symtab"));
-  if (buildsym_compunit->m_pending_blocks != NULL)
+  if (m_pending_blocks != NULL)
     complaint (&symfile_complaints, _("Blocks in a type symtab"));
-  if (buildsym_compunit->m_pending_macros != NULL)
+  if (m_pending_macros != NULL)
     complaint (&symfile_complaints, _("Macro in a type symtab"));
-  if (buildsym_compunit->m_have_line_numbers)
+  if (m_have_line_numbers)
     complaint (&symfile_complaints,
 	       _("Line numbers recorded in a type symtab"));
 
@@ -1530,9 +1656,9 @@ augment_type_symtab (void)
 
       /* First mark any symbols without a specified symtab as belonging
 	 to the primary symtab.  */
-      set_missing_symtab (buildsym_compunit->m_file_symbols, cust);
+      set_missing_symtab (m_file_symbols, cust);
 
-      dict_add_pending (BLOCK_DICT (block), buildsym_compunit->m_file_symbols);
+      dict_add_pending (BLOCK_DICT (block), m_file_symbols);
     }
 
   if (*get_global_symbols () != NULL)
@@ -1541,10 +1667,10 @@ augment_type_symtab (void)
 
       /* First mark any symbols without a specified symtab as belonging
 	 to the primary symtab.  */
-      set_missing_symtab (buildsym_compunit->m_global_symbols, cust);
+      set_missing_symtab (m_global_symbols, cust);
 
       dict_add_pending (BLOCK_DICT (block),
-			buildsym_compunit->m_global_symbols);
+			m_global_symbols);
     }
 
   reset_symtab_globals ();
@@ -1555,23 +1681,20 @@ augment_type_symtab (void)
    context.  */
 
 struct context_stack *
-push_context (int desc, CORE_ADDR valu)
+buildsym_compunit::push_context (int desc, CORE_ADDR valu)
 {
-  gdb_assert (buildsym_compunit != nullptr);
-
-  buildsym_compunit->m_context_stack.emplace_back ();
-  struct context_stack *newobj = &buildsym_compunit->m_context_stack.back ();
+  m_context_stack.emplace_back ();
+  struct context_stack *newobj = &m_context_stack.back ();
 
   newobj->depth = desc;
-  newobj->locals = buildsym_compunit->m_local_symbols;
-  newobj->old_blocks = buildsym_compunit->m_pending_blocks;
+  newobj->locals = m_local_symbols;
+  newobj->old_blocks = m_pending_blocks;
   newobj->start_addr = valu;
-  newobj->local_using_directives
-    = buildsym_compunit->m_local_using_directives;
+  newobj->local_using_directives = m_local_using_directives;
   newobj->name = NULL;
 
-  buildsym_compunit->m_local_symbols = NULL;
-  buildsym_compunit->m_local_using_directives = NULL;
+  m_local_symbols = NULL;
+  m_local_using_directives = NULL;
 
   return newobj;
 }
@@ -1580,14 +1703,12 @@ push_context (int desc, CORE_ADDR valu)
    popped.  */
 
 struct context_stack *
-pop_context (void)
+buildsym_compunit::pop_context ()
 {
-  gdb_assert (buildsym_compunit != nullptr);
-  gdb_assert (!buildsym_compunit->m_context_stack.empty ());
-  buildsym_compunit->m_popped_context
-    = buildsym_compunit->m_context_stack.back ();
-  buildsym_compunit->m_context_stack.pop_back ();
-  return &buildsym_compunit->m_popped_context;
+  gdb_assert (!m_context_stack.empty ());
+  m_popped_context = m_context_stack.back ();
+  m_context_stack.pop_back ();
+  return &m_popped_context;
 }
 
 \f
@@ -1595,13 +1716,13 @@ pop_context (void)
 void
 record_debugformat (const char *format)
 {
-  buildsym_compunit->debugformat = format;
+  buildsym_compunit->record_debugformat (format);
 }
 
 void
 record_producer (const char *producer)
 {
-  buildsym_compunit->producer = producer;
+  buildsym_compunit->record_producer (producer);
 }
 
 \f
@@ -1619,11 +1740,11 @@ set_last_source_file (const char *name)
 /* See buildsym.h.  */
 
 const char *
-get_last_source_file (void)
+get_last_source_file ()
 {
   if (buildsym_compunit == nullptr)
     return nullptr;
-  return buildsym_compunit->m_last_source_file.get ();
+  return buildsym_compunit->get_last_source_file ();
 }
 
 /* See buildsym.h.  */
@@ -1632,7 +1753,7 @@ void
 set_last_source_start_addr (CORE_ADDR addr)
 {
   gdb_assert (buildsym_compunit != nullptr);
-  buildsym_compunit->m_last_source_start_addr = addr;
+  buildsym_compunit->set_last_source_start_addr (addr);
 }
 
 /* See buildsym.h.  */
@@ -1641,7 +1762,7 @@ CORE_ADDR
 get_last_source_start_addr ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return buildsym_compunit->m_last_source_start_addr;
+  return buildsym_compunit->get_last_source_start_addr ();
 }
 
 /* See buildsym.h.  */
@@ -1650,7 +1771,7 @@ struct using_direct **
 get_local_using_directives ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return &buildsym_compunit->m_local_using_directives;
+  return buildsym_compunit->get_local_using_directives ();
 }
 
 /* See buildsym.h.  */
@@ -1659,7 +1780,7 @@ void
 set_local_using_directives (struct using_direct *new_local)
 {
   gdb_assert (buildsym_compunit != nullptr);
-  buildsym_compunit->m_local_using_directives = new_local;
+  buildsym_compunit->set_local_using_directives (new_local);
 }
 
 /* See buildsym.h.  */
@@ -1668,7 +1789,7 @@ struct using_direct **
 get_global_using_directives ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return &buildsym_compunit->m_global_using_directives;
+  return buildsym_compunit->get_global_using_directives ();
 }
 
 /* See buildsym.h.  */
@@ -1677,7 +1798,7 @@ bool
 outermost_context_p ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return buildsym_compunit->m_context_stack.empty ();
+  return buildsym_compunit->outermost_context_p ();
 }
 
 /* See buildsym.h.  */
@@ -1686,9 +1807,7 @@ struct context_stack *
 get_current_context_stack ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  if (buildsym_compunit->m_context_stack.empty ())
-    return nullptr;
-  return &buildsym_compunit->m_context_stack.back ();
+  return buildsym_compunit->get_current_context_stack ();
 }
 
 /* See buildsym.h.  */
@@ -1697,7 +1816,7 @@ int
 get_context_stack_depth ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return buildsym_compunit->m_context_stack.size ();
+  return buildsym_compunit->get_context_stack_depth ();
 }
 
 /* See buildsym.h.  */
@@ -1706,7 +1825,7 @@ struct subfile *
 get_current_subfile ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return buildsym_compunit->m_current_subfile;
+  return buildsym_compunit->get_current_subfile ();
 }
 
 /* See buildsym.h.  */
@@ -1715,7 +1834,7 @@ struct pending **
 get_local_symbols ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return &buildsym_compunit->m_local_symbols;
+  return buildsym_compunit->get_local_symbols ();
 }
 
 /* See buildsym.h.  */
@@ -1724,7 +1843,7 @@ struct pending **
 get_file_symbols ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return &buildsym_compunit->m_file_symbols;
+  return buildsym_compunit->get_file_symbols ();
 }
 
 /* See buildsym.h.  */
@@ -1733,5 +1852,120 @@ struct pending **
 get_global_symbols ()
 {
   gdb_assert (buildsym_compunit != nullptr);
-  return &buildsym_compunit->m_global_symbols;
+  return buildsym_compunit->get_global_symbols ();
+}
+
+void
+start_subfile (const char *name)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  buildsym_compunit->start_subfile (name);
+}
+
+void
+patch_subfile_names (struct subfile *subfile, const char *name)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  buildsym_compunit->patch_subfile_names (subfile, name);
+}
+
+void
+push_subfile ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  buildsym_compunit->push_subfile ();
+}
+
+const char *
+pop_subfile ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->pop_subfile ();
+}
+
+struct block *
+end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->end_symtab_get_static_block (end_addr, expandable,
+							 required);
+}
+
+struct compunit_symtab *
+end_symtab_from_static_block (struct block *static_block,
+			      int section, int expandable)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  struct compunit_symtab *result
+    = buildsym_compunit->end_symtab_from_static_block (static_block,
+						       section, expandable);
+  reset_symtab_globals ();
+  return result;
+}
+
+struct compunit_symtab *
+end_symtab (CORE_ADDR end_addr, int section)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  struct compunit_symtab *result
+    = buildsym_compunit->end_symtab (end_addr, section);
+  reset_symtab_globals ();
+  return result;
+}
+
+struct compunit_symtab *
+end_expandable_symtab (CORE_ADDR end_addr, int section)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  struct compunit_symtab *result
+    = buildsym_compunit->end_expandable_symtab (end_addr, section);
+  reset_symtab_globals ();
+  return result;
+}
+
+void
+augment_type_symtab ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  buildsym_compunit->augment_type_symtab ();
+  reset_symtab_globals ();
+}
+
+struct context_stack *
+push_context (int desc, CORE_ADDR valu)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->push_context (desc, valu);
+}
+
+struct context_stack *
+pop_context ()
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->pop_context ();
+}
+
+struct block *
+finish_block (struct symbol *symbol, struct pending_block *old_blocks,
+	      const struct dynamic_prop *static_link,
+	      CORE_ADDR start, CORE_ADDR end)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  return buildsym_compunit->finish_block (symbol, old_blocks, static_link,
+					  start, end);
+}
+
+void
+record_block_range (struct block *block, CORE_ADDR start,
+		    CORE_ADDR end_inclusive)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  buildsym_compunit->record_block_range (block, start, end_inclusive);
+}
+
+void
+record_line (struct subfile *subfile, int line, CORE_ADDR pc)
+{
+  gdb_assert (buildsym_compunit != nullptr);
+  buildsym_compunit->record_line (subfile, line, pc);
 }
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 42/42] Remove record_line_ftype
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (34 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 36/42] Remove reset_symtab_globals Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  4:38   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 33/42] Remove parameter from record_pending_block Tom Tromey
                   ` (7 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The record_line_ftype typedef was only used in the DWARF reader, and
we removed those uses a few patches ago.  So, remove the typedef.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* legacy-buildsym.h (record_line): Don't use record_line_ftype.
	* buildsym.h (record_line_ftype): Remove typedef.
---
 gdb/ChangeLog         | 5 +++++
 gdb/buildsym.h        | 4 ----
 gdb/legacy-buildsym.h | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 05b80f5cb7..d90faff903 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -399,10 +399,6 @@ private:
   struct pending *m_local_symbols = nullptr;
 };
 
-/* The type of the record_line function.  */
-typedef void (record_line_ftype) (struct subfile *subfile, int line,
-				  CORE_ADDR pc);
-
 \f
 
 extern void add_symbol_to_list (struct symbol *symbol,
diff --git a/gdb/legacy-buildsym.h b/gdb/legacy-buildsym.h
index 55f9d14f7e..43d3e6c09c 100644
--- a/gdb/legacy-buildsym.h
+++ b/gdb/legacy-buildsym.h
@@ -79,7 +79,7 @@ extern struct context_stack *push_context (int desc, CORE_ADDR valu);
 
 extern struct context_stack *pop_context (void);
 
-extern record_line_ftype record_line;
+extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
 
 extern struct compunit_symtab *start_symtab (struct objfile *objfile,
 					     const char *name,
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 33/42] Remove parameter from record_pending_block
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (35 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 42/42] Remove record_line_ftype Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  3:49   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 31/42] Remove a TODO Tom Tromey
                   ` (6 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes a redundant parameter from record_pending_block.  It also
moves record_pending_block earlier in the file, so that a forward
declaration is no longer needed.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (record_pending_block): Move earlier.  Remove objfile
	parameter.
	(finish_block_internal): Update.
---
 gdb/ChangeLog  |  6 ++++++
 gdb/buildsym.c | 59 +++++++++++++++++++++++++---------------------------------
 2 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 1c7b3de215..c965776d82 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -289,10 +289,6 @@ static void free_buildsym_compunit (void);
 
 static int compare_line_numbers (const void *ln1p, const void *ln2p);
 
-static void record_pending_block (struct objfile *objfile,
-				  struct block *block,
-				  struct pending_block *opblock);
-
 /* Initial sizes of data structures.  These are realloc'd larger if
    needed, and realloc'd down to the size actually used, when
    completed.  */
@@ -366,6 +362,30 @@ scoped_free_pendings::~scoped_free_pendings ()
   free_buildsym_compunit ();
 }
 
+/* Record BLOCK on the list of all blocks in the file.  Put it after
+   OPBLOCK, or at the beginning if opblock is NULL.  This puts the
+   block in the list after all its subblocks.  */
+
+static void
+record_pending_block (struct block *block, struct pending_block *opblock)
+{
+  struct pending_block *pblock;
+
+  pblock = XOBNEW (&buildsym_compunit->m_pending_block_obstack,
+		   struct pending_block);
+  pblock->block = block;
+  if (opblock)
+    {
+      pblock->next = opblock->next;
+      opblock->next = pblock;
+    }
+  else
+    {
+      pblock->next = buildsym_compunit->m_pending_blocks;
+      buildsym_compunit->m_pending_blocks = pblock;
+    }
+}
+
 /* Take one of the lists of symbols and make a block from it.  Keep
    the order the symbols have in the list (reversed from the input
    file).  Put the block on the list of pending blocks.  */
@@ -560,7 +580,7 @@ finish_block_internal (struct symbol *symbol,
   else
     buildsym_compunit->m_local_using_directives = NULL;
 
-  record_pending_block (objfile, block, opblock);
+  record_pending_block (block, opblock);
 
   return block;
 }
@@ -576,35 +596,6 @@ finish_block (struct symbol *symbol,
 				start, end, 0, 0);
 }
 
-/* Record BLOCK on the list of all blocks in the file.  Put it after
-   OPBLOCK, or at the beginning if opblock is NULL.  This puts the
-   block in the list after all its subblocks.
-
-   Allocate the pending block struct in the objfile_obstack to save
-   time.  This wastes a little space.  FIXME: Is it worth it?  */
-
-static void
-record_pending_block (struct objfile *objfile, struct block *block,
-		      struct pending_block *opblock)
-{
-  struct pending_block *pblock;
-
-  pblock = XOBNEW (&buildsym_compunit->m_pending_block_obstack,
-		   struct pending_block);
-  pblock->block = block;
-  if (opblock)
-    {
-      pblock->next = opblock->next;
-      opblock->next = pblock;
-    }
-  else
-    {
-      pblock->next = buildsym_compunit->m_pending_blocks;
-      buildsym_compunit->m_pending_blocks = pblock;
-    }
-}
-
-
 /* Record that the range of addresses from START to END_INCLUSIVE
    (inclusive, like it says) belongs to BLOCK.  BLOCK's start and end
    addresses must be set already.  You must apply this function to all
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 35/42] Do not use buildsym.h in some files
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (32 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 39/42] Parameterize cp_scan_for_anonymous_namespaces Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  4:10   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 36/42] Remove reset_symtab_globals Tom Tromey
                   ` (9 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A few files no longer need to include buildsym.h.

2018-05-22  Tom Tromey  <tom@tromey.com>

	* arch-utils.c: Do not include buildsym.h.
	* mipsread.c: Do not include buildsym.h.
	* machoread.c: Do not include buildsym.h.
	* elfread.c: Do not include buildsym.h.
---
 gdb/ChangeLog    | 7 +++++++
 gdb/arch-utils.c | 1 -
 gdb/elfread.c    | 1 -
 gdb/machoread.c  | 1 -
 gdb/mipsread.c   | 1 -
 5 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index e3cce491ee..0b7aff182b 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -20,7 +20,6 @@
 #include "defs.h"
 
 #include "arch-utils.h"
-#include "buildsym.h"
 #include "gdbcmd.h"
 #include "inferior.h"		/* enum CALL_DUMMY_LOCATION et al.  */
 #include "infrun.h"
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 9bbd0c85e4..6b87f28fb8 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -28,7 +28,6 @@
 #include "symtab.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include "buildsym.h"
 #include "stabsread.h"
 #include "gdb-stabs.h"
 #include "complaints.h"
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 230bd860a4..d2a4e24bd4 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -24,7 +24,6 @@
 #include "bfd.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include "buildsym.h"
 #include "gdbcmd.h"
 #include "gdbcore.h"
 #include "mach-o.h"
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 52130dab20..cbfa9cc03c 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -27,7 +27,6 @@
 #include "bfd.h"
 #include "symtab.h"
 #include "objfiles.h"
-#include "buildsym.h"
 #include "stabsread.h"
 
 #include "coff/sym.h"
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 37/42] Move struct buildsym_compunit to buildsym.h
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (37 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 31/42] Remove a TODO Tom Tromey
@ 2018-05-23  6:16 ` Tom Tromey
  2018-07-10  4:15   ` Simon Marchi
  2018-05-23  6:16 ` [RFA 41/42] Remove some unused buildsym functions Tom Tromey
                   ` (4 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  6:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves struct buildsym_compunit to buildsym.h.  Now that the
members are private, and it no longer affects any global state in
buildsym.c, an instance can be used directly for symtab creation.

2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.h (struct buildsym_compunit): Move from buildsym.c.
	* buildsym.c (struct buildsym_compunit): Move to buildsym.h.
	(buildsym_compunit::buildsym_compunit)
	(buildsym_compunit::~buildsym_compunit)
	(buildsym_compunit::get_macro_table): Define.
---
 gdb/ChangeLog  |   8 ++
 gdb/buildsym.c | 416 ++++++++++-----------------------------------------------
 gdb/buildsym.h | 291 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 368 insertions(+), 347 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 16756d8835..2f4b0c79ef 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -85,353 +85,6 @@
 
 #include "stabsread.h"
 
-/* Buildsym's counterpart to struct compunit_symtab.  */
-
-struct buildsym_compunit
-{
-  /* Start recording information about a primary source file (IOW, not an
-     included source file).
-     COMP_DIR is the directory in which the compilation unit was compiled
-     (or NULL if not known).  */
-
-  buildsym_compunit (struct objfile *objfile_, const char *name,
-		     const char *comp_dir_, enum language language_,
-		     CORE_ADDR last_addr)
-    : objfile (objfile_),
-      m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
-      comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
-      language (language_),
-      m_last_source_start_addr (last_addr)
-  {
-    /* Allocate the compunit symtab now.  The caller needs it to allocate
-       non-primary symtabs.  It is also needed by get_macro_table.  */
-    compunit_symtab = allocate_compunit_symtab (objfile, name);
-
-    /* Build the subfile for NAME (the main source file) so that we can record
-       a pointer to it for later.
-       IMPORTANT: Do not allocate a struct symtab for NAME here.
-       It can happen that the debug info provides a different path to NAME than
-       DIRNAME,NAME.  We cope with this in watch_main_source_file_lossage but
-       that only works if the main_subfile doesn't have a symtab yet.  */
-    start_subfile (name);
-    /* Save this so that we don't have to go looking for it at the end
-       of the subfiles list.  */
-    main_subfile = m_current_subfile;
-  }
-
-  buildsym_compunit (struct objfile *objfile_, const char *name,
-		     const char *comp_dir_, enum language language_,
-		     CORE_ADDR last_addr, struct compunit_symtab *cust)
-    : objfile (objfile_),
-      m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
-      comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
-      compunit_symtab (cust),
-      language (language_),
-      m_last_source_start_addr (last_addr)
-  {
-  }
-
-  ~buildsym_compunit ()
-  {
-    struct subfile *subfile, *nextsub;
-
-    if (m_pending_macros != nullptr)
-      free_macro_table (m_pending_macros);
-
-    for (subfile = subfiles;
-	 subfile != NULL;
-	 subfile = nextsub)
-      {
-	nextsub = subfile->next;
-	xfree (subfile->name);
-	xfree (subfile->line_vector);
-	xfree (subfile);
-      }
-
-    struct pending *next, *next1;
-
-    for (next = m_file_symbols; next != NULL; next = next1)
-      {
-	next1 = next->next;
-	xfree ((void *) next);
-      }
-
-    for (next = m_global_symbols; next != NULL; next = next1)
-      {
-	next1 = next->next;
-	xfree ((void *) next);
-      }
-  }
-
-  void set_last_source_file (const char *name)
-  {
-    char *new_name = name == NULL ? NULL : xstrdup (name);
-    m_last_source_file.reset (new_name);
-  }
-
-  const char *get_last_source_file ()
-  {
-    return m_last_source_file.get ();
-  }
-
-  struct macro_table *get_macro_table ()
-  {
-    if (m_pending_macros == nullptr)
-      m_pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
-					  objfile->per_bfd->macro_cache,
-					  compunit_symtab);
-    return m_pending_macros;
-  }
-
-  struct macro_table *release_macros ()
-  {
-    struct macro_table *result = m_pending_macros;
-    m_pending_macros = nullptr;
-    return result;
-  }
-
-  /* This function is called to discard any pending blocks.  */
-
-  void free_pending_blocks ()
-  {
-    m_pending_block_obstack.clear ();
-    m_pending_blocks = nullptr;
-  }
-
-  struct block *finish_block (struct symbol *symbol,
-			      struct pending_block *old_blocks,
-			      const struct dynamic_prop *static_link,
-			      CORE_ADDR start, CORE_ADDR end);
-
-  void record_block_range (struct block *block,
-			   CORE_ADDR start, CORE_ADDR end_inclusive);
-
-  void start_subfile (const char *name);
-
-  void patch_subfile_names (struct subfile *subfile, const char *name);
-
-  void push_subfile ();
-
-  const char *pop_subfile ();
-
-  void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
-
-  struct compunit_symtab *get_compunit_symtab ()
-  {
-    return compunit_symtab;
-  }
-
-  void set_last_source_start_addr (CORE_ADDR addr)
-  {
-    m_last_source_start_addr = addr;
-  }
-
-  CORE_ADDR get_last_source_start_addr ()
-  {
-    return m_last_source_start_addr;
-  }
-
-  struct using_direct **get_local_using_directives ()
-  {
-    return &m_local_using_directives;
-  }
-
-  void set_local_using_directives (struct using_direct *new_local)
-  {
-    m_local_using_directives = new_local;
-  }
-
-  struct using_direct **get_global_using_directives ()
-  {
-    return &m_global_using_directives;
-  }
-
-  bool outermost_context_p () const
-  {
-    return m_context_stack.empty ();
-  }
-
-  struct context_stack *get_current_context_stack ()
-  {
-    if (m_context_stack.empty ())
-      return nullptr;
-    return &m_context_stack.back ();
-  }
-
-  int get_context_stack_depth () const
-  {
-    return m_context_stack.size ();
-  }
-
-  struct subfile *get_current_subfile ()
-  {
-    return m_current_subfile;
-  }
-
-  struct pending **get_local_symbols ()
-  {
-    return &m_local_symbols;
-  }
-
-  struct pending **get_file_symbols ()
-  {
-    return &m_file_symbols;
-  }
-
-  struct pending **get_global_symbols ()
-  {
-    return &m_global_symbols;
-  }
-
-  void record_debugformat (const char *format)
-  {
-    debugformat = format;
-  }
-
-  void record_producer (const char *producer)
-  {
-    this->producer = producer;
-  }
-
-  struct context_stack *push_context (int desc, CORE_ADDR valu);
-
-  struct context_stack *pop_context ();
-
-  struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
-					     int expandable, int required);
-
-  struct compunit_symtab *end_symtab_from_static_block
-      (struct block *static_block, int section, int expandable);
-
-  struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
-
-  struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
-						 int section);
-
-  void augment_type_symtab ();
-
-private:
-
-  void record_pending_block (struct block *block, struct pending_block *opblock);
-
-  struct block *finish_block_internal (struct symbol *symbol,
-				       struct pending **listhead,
-				       struct pending_block *old_blocks,
-				       const struct dynamic_prop *static_link,
-				       CORE_ADDR start, CORE_ADDR end,
-				       int is_global, int expandable);
-
-  struct blockvector *make_blockvector ();
-
-  void watch_main_source_file_lossage ();
-
-  struct compunit_symtab *end_symtab_with_blockvector
-      (struct block *static_block, int section, int expandable);
-
-  /* The objfile we're reading debug info from.  */
-  struct objfile *objfile;
-
-  /* List of subfiles (source files).
-     Files are added to the front of the list.
-     This is important mostly for the language determination hacks we use,
-     which iterate over previously added files.  */
-  struct subfile *subfiles = nullptr;
-
-  /* The subfile of the main source file.  */
-  struct subfile *main_subfile = nullptr;
-
-  /* Name of source file whose symbol data we are now processing.  This
-     comes from a symbol of type N_SO for stabs.  For Dwarf it comes
-     from the DW_AT_name attribute of a DW_TAG_compile_unit DIE.  */
-
-  gdb::unique_xmalloc_ptr<char> m_last_source_file;
-
-  /* E.g., DW_AT_comp_dir if DWARF.  Space for this is malloc'd.  */
-  gdb::unique_xmalloc_ptr<char> comp_dir;
-
-  /* Space for this is not malloc'd, and is assumed to have at least
-     the same lifetime as objfile.  */
-  const char *producer = nullptr;
-
-  /* Space for this is not malloc'd, and is assumed to have at least
-     the same lifetime as objfile.  */
-  const char *debugformat = nullptr;
-
-  /* The compunit we are building.  */
-  struct compunit_symtab *compunit_symtab = nullptr;
-
-  /* Language of this compunit_symtab.  */
-  enum language language;
-
-  /* The macro table for the compilation unit whose symbols we're
-     currently reading.  */
-  struct macro_table *m_pending_macros = nullptr;
-
-  /* True if symtab has line number info.  This prevents an otherwise
-     empty symtab from being tossed.  */
-  bool m_have_line_numbers = false;
-
-  /* Core address of start of text of current source file.  This too
-     comes from the N_SO symbol.  For Dwarf it typically comes from the
-     DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE.  */
-  CORE_ADDR m_last_source_start_addr;
-
-  /* Stack of subfile names.  */
-  std::vector<const char *> m_subfile_stack;
-
-  /* "using" directives local to lexical context.  */
-
-  struct using_direct *m_local_using_directives = nullptr;
-
-  /* global "using" directives.  */
-
-  struct using_direct *m_global_using_directives = nullptr;
-
-  std::vector<struct context_stack> m_context_stack;
-  struct context_stack m_popped_context {};
-
-  struct subfile *m_current_subfile = nullptr;
-
-  /* The mutable address map for the compilation unit whose symbols
-     we're currently reading.  The symtabs' shared blockvector will
-     point to a fixed copy of this.  */
-  struct addrmap *m_pending_addrmap = nullptr;
-
-  /* The obstack on which we allocate pending_addrmap.
-     If pending_addrmap is NULL, this is uninitialized; otherwise, it is
-     initialized (and holds pending_addrmap).  */
-  auto_obstack m_pending_addrmap_obstack;
-
-  /* True if we recorded any ranges in the addrmap that are different
-     from those in the blockvector already.  We set this to false when
-     we start processing a symfile, and if it's still false at the
-     end, then we just toss the addrmap.  */
-  bool m_pending_addrmap_interesting = false;
-
-  /* An obstack used for allocating pending blocks.  */
-  auto_obstack m_pending_block_obstack;
-
-  /* Pointer to the head of a linked list of symbol blocks which have
-     already been finalized (lexical contexts already closed) and which
-     are just waiting to be built into a blockvector when finalizing the
-     associated symtab.  */
-  struct pending_block *m_pending_blocks = nullptr;
-
-  /* Here are the three lists that symbols are put on.  */
-
-  /* static at top level, and types */
-
-  struct pending *m_file_symbols = nullptr;
-
-  /* global functions and variables */
-
-  struct pending *m_global_symbols = nullptr;
-
-  /* everything local to lexical context */
-
-  struct pending *m_local_symbols = nullptr;
-};
-
 /* The work-in-progress of the compunit we are building.
    This is created first, before any subfiles by start_symtab.  */
 
@@ -457,6 +110,75 @@ static int compare_line_numbers (const void *ln1p, const void *ln2p);
 #define	INITIAL_LINE_VECTOR_LENGTH	1000
 \f
 
+buildsym_compunit::buildsym_compunit (struct objfile *objfile_,
+				      const char *name,
+				      const char *comp_dir_,
+				      enum language language_,
+				      CORE_ADDR last_addr)
+  : objfile (objfile_),
+    m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
+    comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
+    language (language_),
+    m_last_source_start_addr (last_addr)
+{
+  /* Allocate the compunit symtab now.  The caller needs it to allocate
+     non-primary symtabs.  It is also needed by get_macro_table.  */
+  compunit_symtab = allocate_compunit_symtab (objfile, name);
+
+  /* Build the subfile for NAME (the main source file) so that we can record
+     a pointer to it for later.
+     IMPORTANT: Do not allocate a struct symtab for NAME here.
+     It can happen that the debug info provides a different path to NAME than
+     DIRNAME,NAME.  We cope with this in watch_main_source_file_lossage but
+     that only works if the main_subfile doesn't have a symtab yet.  */
+  start_subfile (name);
+  /* Save this so that we don't have to go looking for it at the end
+     of the subfiles list.  */
+  main_subfile = m_current_subfile;
+}
+
+buildsym_compunit::~buildsym_compunit ()
+{
+  struct subfile *subfile, *nextsub;
+
+  if (m_pending_macros != nullptr)
+    free_macro_table (m_pending_macros);
+
+  for (subfile = subfiles;
+       subfile != NULL;
+       subfile = nextsub)
+    {
+      nextsub = subfile->next;
+      xfree (subfile->name);
+      xfree (subfile->line_vector);
+      xfree (subfile);
+    }
+
+  struct pending *next, *next1;
+
+  for (next = m_file_symbols; next != NULL; next = next1)
+    {
+      next1 = next->next;
+      xfree ((void *) next);
+    }
+
+  for (next = m_global_symbols; next != NULL; next = next1)
+    {
+      next1 = next->next;
+      xfree ((void *) next);
+    }
+}
+
+struct macro_table *
+buildsym_compunit::get_macro_table ()
+{
+  if (m_pending_macros == nullptr)
+    m_pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
+					objfile->per_bfd->macro_cache,
+					compunit_symtab);
+  return m_pending_macros;
+}
+
 /* Maintain the lists of symbols and blocks.  */
 
 /* Add a symbol to one of the lists of symbols.  */
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 8a4f47b375..a089623fa2 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -108,6 +108,297 @@ struct context_stack
 
   };
 
+/* Buildsym's counterpart to struct compunit_symtab.  */
+
+struct buildsym_compunit
+{
+  /* Start recording information about a primary source file (IOW, not an
+     included source file).
+     COMP_DIR is the directory in which the compilation unit was compiled
+     (or NULL if not known).  */
+
+  buildsym_compunit (struct objfile *objfile_, const char *name,
+		     const char *comp_dir_, enum language language_,
+		     CORE_ADDR last_addr);
+
+  buildsym_compunit (struct objfile *objfile_, const char *name,
+		     const char *comp_dir_, enum language language_,
+		     CORE_ADDR last_addr, struct compunit_symtab *cust)
+    : objfile (objfile_),
+      m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
+      comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
+      compunit_symtab (cust),
+      language (language_),
+      m_last_source_start_addr (last_addr)
+  {
+  }
+
+  ~buildsym_compunit ();
+
+  DISABLE_COPY_AND_ASSIGN (buildsym_compunit);
+
+  void set_last_source_file (const char *name)
+  {
+    char *new_name = name == NULL ? NULL : xstrdup (name);
+    m_last_source_file.reset (new_name);
+  }
+
+  const char *get_last_source_file ()
+  {
+    return m_last_source_file.get ();
+  }
+
+  struct macro_table *get_macro_table ();
+
+  struct macro_table *release_macros ()
+  {
+    struct macro_table *result = m_pending_macros;
+    m_pending_macros = nullptr;
+    return result;
+  }
+
+  /* This function is called to discard any pending blocks.  */
+
+  void free_pending_blocks ()
+  {
+    m_pending_block_obstack.clear ();
+    m_pending_blocks = nullptr;
+  }
+
+  struct block *finish_block (struct symbol *symbol,
+			      struct pending_block *old_blocks,
+			      const struct dynamic_prop *static_link,
+			      CORE_ADDR start, CORE_ADDR end);
+
+  void record_block_range (struct block *block,
+			   CORE_ADDR start, CORE_ADDR end_inclusive);
+
+  void start_subfile (const char *name);
+
+  void patch_subfile_names (struct subfile *subfile, const char *name);
+
+  void push_subfile ();
+
+  const char *pop_subfile ();
+
+  void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
+
+  struct compunit_symtab *get_compunit_symtab ()
+  {
+    return compunit_symtab;
+  }
+
+  void set_last_source_start_addr (CORE_ADDR addr)
+  {
+    m_last_source_start_addr = addr;
+  }
+
+  CORE_ADDR get_last_source_start_addr ()
+  {
+    return m_last_source_start_addr;
+  }
+
+  struct using_direct **get_local_using_directives ()
+  {
+    return &m_local_using_directives;
+  }
+
+  void set_local_using_directives (struct using_direct *new_local)
+  {
+    m_local_using_directives = new_local;
+  }
+
+  struct using_direct **get_global_using_directives ()
+  {
+    return &m_global_using_directives;
+  }
+
+  bool outermost_context_p () const
+  {
+    return m_context_stack.empty ();
+  }
+
+  struct context_stack *get_current_context_stack ()
+  {
+    if (m_context_stack.empty ())
+      return nullptr;
+    return &m_context_stack.back ();
+  }
+
+  int get_context_stack_depth () const
+  {
+    return m_context_stack.size ();
+  }
+
+  struct subfile *get_current_subfile ()
+  {
+    return m_current_subfile;
+  }
+
+  struct pending **get_local_symbols ()
+  {
+    return &m_local_symbols;
+  }
+
+  struct pending **get_file_symbols ()
+  {
+    return &m_file_symbols;
+  }
+
+  struct pending **get_global_symbols ()
+  {
+    return &m_global_symbols;
+  }
+
+  void record_debugformat (const char *format)
+  {
+    debugformat = format;
+  }
+
+  void record_producer (const char *producer)
+  {
+    this->producer = producer;
+  }
+
+  struct context_stack *push_context (int desc, CORE_ADDR valu);
+
+  struct context_stack *pop_context ();
+
+  struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
+					     int expandable, int required);
+
+  struct compunit_symtab *end_symtab_from_static_block
+      (struct block *static_block, int section, int expandable);
+
+  struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
+
+  struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
+						 int section);
+
+  void augment_type_symtab ();
+
+private:
+
+  void record_pending_block (struct block *block, struct pending_block *opblock);
+
+  struct block *finish_block_internal (struct symbol *symbol,
+				       struct pending **listhead,
+				       struct pending_block *old_blocks,
+				       const struct dynamic_prop *static_link,
+				       CORE_ADDR start, CORE_ADDR end,
+				       int is_global, int expandable);
+
+  struct blockvector *make_blockvector ();
+
+  void watch_main_source_file_lossage ();
+
+  struct compunit_symtab *end_symtab_with_blockvector
+      (struct block *static_block, int section, int expandable);
+
+  /* The objfile we're reading debug info from.  */
+  struct objfile *objfile;
+
+  /* List of subfiles (source files).
+     Files are added to the front of the list.
+     This is important mostly for the language determination hacks we use,
+     which iterate over previously added files.  */
+  struct subfile *subfiles = nullptr;
+
+  /* The subfile of the main source file.  */
+  struct subfile *main_subfile = nullptr;
+
+  /* Name of source file whose symbol data we are now processing.  This
+     comes from a symbol of type N_SO for stabs.  For Dwarf it comes
+     from the DW_AT_name attribute of a DW_TAG_compile_unit DIE.  */
+
+  gdb::unique_xmalloc_ptr<char> m_last_source_file;
+
+  /* E.g., DW_AT_comp_dir if DWARF.  Space for this is malloc'd.  */
+  gdb::unique_xmalloc_ptr<char> comp_dir;
+
+  /* Space for this is not malloc'd, and is assumed to have at least
+     the same lifetime as objfile.  */
+  const char *producer = nullptr;
+
+  /* Space for this is not malloc'd, and is assumed to have at least
+     the same lifetime as objfile.  */
+  const char *debugformat = nullptr;
+
+  /* The compunit we are building.  */
+  struct compunit_symtab *compunit_symtab = nullptr;
+
+  /* Language of this compunit_symtab.  */
+  enum language language;
+
+  /* The macro table for the compilation unit whose symbols we're
+     currently reading.  */
+  struct macro_table *m_pending_macros = nullptr;
+
+  /* True if symtab has line number info.  This prevents an otherwise
+     empty symtab from being tossed.  */
+  bool m_have_line_numbers = false;
+
+  /* Core address of start of text of current source file.  This too
+     comes from the N_SO symbol.  For Dwarf it typically comes from the
+     DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE.  */
+  CORE_ADDR m_last_source_start_addr;
+
+  /* Stack of subfile names.  */
+  std::vector<const char *> m_subfile_stack;
+
+  /* "using" directives local to lexical context.  */
+
+  struct using_direct *m_local_using_directives = nullptr;
+
+  /* global "using" directives.  */
+
+  struct using_direct *m_global_using_directives = nullptr;
+
+  std::vector<struct context_stack> m_context_stack;
+  struct context_stack m_popped_context {};
+
+  struct subfile *m_current_subfile = nullptr;
+
+  /* The mutable address map for the compilation unit whose symbols
+     we're currently reading.  The symtabs' shared blockvector will
+     point to a fixed copy of this.  */
+  struct addrmap *m_pending_addrmap = nullptr;
+
+  /* The obstack on which we allocate pending_addrmap.
+     If pending_addrmap is NULL, this is uninitialized; otherwise, it is
+     initialized (and holds pending_addrmap).  */
+  auto_obstack m_pending_addrmap_obstack;
+
+  /* True if we recorded any ranges in the addrmap that are different
+     from those in the blockvector already.  We set this to false when
+     we start processing a symfile, and if it's still false at the
+     end, then we just toss the addrmap.  */
+  bool m_pending_addrmap_interesting = false;
+
+  /* An obstack used for allocating pending blocks.  */
+  auto_obstack m_pending_block_obstack;
+
+  /* Pointer to the head of a linked list of symbol blocks which have
+     already been finalized (lexical contexts already closed) and which
+     are just waiting to be built into a blockvector when finalizing the
+     associated symtab.  */
+  struct pending_block *m_pending_blocks = nullptr;
+
+  /* Here are the three lists that symbols are put on.  */
+
+  /* static at top level, and types */
+
+  struct pending *m_file_symbols = nullptr;
+
+  /* global functions and variables */
+
+  struct pending *m_global_symbols = nullptr;
+
+  /* everything local to lexical context */
+
+  struct pending *m_local_symbols = nullptr;
+};
+
 /* The type of the record_line function.  */
 typedef void (record_line_ftype) (struct subfile *subfile, int line,
 				  CORE_ADDR pc);
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 38/42] Introduce legacy-buildsym.h
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (39 preceding siblings ...)
  2018-05-23  6:16 ` [RFA 41/42] Remove some unused buildsym functions Tom Tromey
@ 2018-05-23  7:31 ` Tom Tromey
  2018-07-10  4:22   ` Simon Marchi
  2018-05-23  8:49 ` [RFA 30/42] Remove buildsym_init Tom Tromey
                   ` (2 subsequent siblings)
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  7:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a new header, legacy-buildsym.h, and changes all the
symbol readers to use it.  The idea is to put the function-based
interface, that relies on the buildsym_compunit global, into a
separate header.  Then when a symbol reader is updated to use the new
interface, it can simply not include legacy-buildsym.h, so it's easy
to be sure that the new API is used everywhere.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c: Include legacy-buildsym.h.
	* windows-nat.c: Include legacy-buildsym.h.
	* stabsread.c: Include legacy-buildsym.h.
	* mdebugread.c: Include legacy-buildsym.h.
	* legacy-buildsym.h: New file.
	* go32-nat.c: Include legacy-buildsym.h.
	* dwarf2read.c: Include legacy-buildsym.h.
	* dbxread.c: Include legacy-buildsym.h.
	* cp-namespace.c: Include legacy-buildsym.h.
	* coffread.c: Include legacy-buildsym.h.
	* buildsym.h: Move some contents to legacy-buildsym.h.
	* buildsym.c: Include legacy-buildsym.h.
	* Makefile.in (HFILES_NO_SRCDIR): Add legacy-buildsym.h.
---
 gdb/ChangeLog         |  16 ++++
 gdb/Makefile.in       |   1 +
 gdb/buildsym.c        |  47 +----------
 gdb/buildsym.h        | 142 ----------------------------------
 gdb/coffread.c        |   2 +-
 gdb/cp-namespace.c    |   2 +-
 gdb/dbxread.c         |   2 +-
 gdb/dwarf2read.c      |   2 +-
 gdb/go32-nat.c        |   2 +-
 gdb/legacy-buildsym.h | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/mdebugread.c      |   2 +-
 gdb/stabsread.c       |   2 +-
 gdb/windows-nat.c     |   2 +-
 gdb/xcoffread.c       |   2 +-
 14 files changed, 237 insertions(+), 197 deletions(-)
 create mode 100644 gdb/legacy-buildsym.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 09a2ad2ca3..ac1031ca58 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1282,6 +1282,7 @@ HFILES_NO_SRCDIR = \
 	interps.h \
 	jit.h \
 	language.h \
+	legacy-buildsym.h \
 	linespec.h \
 	linux-fork.h \
 	linux-nat.h \
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 2f4b0c79ef..3e3170f0ee 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -16,53 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* This module provides subroutines used for creating and adding to
-   the symbol table.  These routines are called from various symbol-
-   file-reading routines.
-
-   Routines to support specific debugging information formats (stabs,
-   DWARF, etc) belong somewhere else.
-
-   The basic way this module is used is as follows:
-
-   scoped_free_pendings free_pending;
-   cust = start_symtab (...);
-   ... read debug info ...
-   cust = end_symtab (...);
-
-   The compunit symtab pointer ("cust") is returned from both start_symtab
-   and end_symtab to simplify the debug info readers.
-
-   There are minor variations on this, e.g., dwarf2read.c splits end_symtab
-   into two calls: end_symtab_get_static_block, end_symtab_from_static_block,
-   but all debug info readers follow this basic flow.
-
-   Reading DWARF Type Units is another variation:
-
-   scoped_free_pendings free_pending;
-   cust = start_symtab (...);
-   ... read debug info ...
-   cust = end_expandable_symtab (...);
-
-   And then reading subsequent Type Units within the containing "Comp Unit"
-   will use a second flow:
-
-   scoped_free_pendings free_pending;
-   cust = restart_symtab (...);
-   ... read debug info ...
-   cust = augment_type_symtab (...);
-
-   dbxread.c and xcoffread.c use another variation:
-
-   scoped_free_pendings free_pending;
-   cust = start_symtab (...);
-   ... read debug info ...
-   cust = end_symtab (...);
-   ... start_symtab + read + end_symtab repeated ...
-*/
-
 #include "defs.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "bfd.h"
 #include "gdb_obstack.h"
 #include "symtab.h"
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index a089623fa2..05b80f5cb7 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -411,146 +411,4 @@ extern void add_symbol_to_list (struct symbol *symbol,
 extern struct symbol *find_symbol_in_list (struct pending *list,
 					   char *name, int length);
 
-extern struct block *finish_block (struct symbol *symbol,
-				   struct pending_block *old_blocks,
-				   const struct dynamic_prop *static_link,
-				   CORE_ADDR start,
-				   CORE_ADDR end);
-
-extern void record_block_range (struct block *,
-                                CORE_ADDR start, CORE_ADDR end_inclusive);
-
-class scoped_free_pendings
-{
-public:
-
-  scoped_free_pendings ();
-  ~scoped_free_pendings ();
-
-  DISABLE_COPY_AND_ASSIGN (scoped_free_pendings);
-};
-
-extern void start_subfile (const char *name);
-
-extern void patch_subfile_names (struct subfile *subfile, const char *name);
-
-extern void push_subfile ();
-
-extern const char *pop_subfile ();
-
-extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
-						  int expandable,
-						  int required);
-
-extern struct compunit_symtab *
-  end_symtab_from_static_block (struct block *static_block,
-				int section, int expandable);
-
-extern struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
-
-extern struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
-						      int section);
-
-extern void augment_type_symtab (void);
-
-extern struct context_stack *push_context (int desc, CORE_ADDR valu);
-
-extern struct context_stack *pop_context (void);
-
-extern record_line_ftype record_line;
-
-extern struct compunit_symtab *start_symtab (struct objfile *objfile,
-					     const char *name,
-					     const char *comp_dir,
-					     CORE_ADDR start_addr,
-					     enum language language);
-
-extern void restart_symtab (struct compunit_symtab *cust,
-			    const char *name, CORE_ADDR start_addr);
-
-/* Record the name of the debug format in the current pending symbol
-   table.  FORMAT must be a string with a lifetime at least as long as
-   the symtab's objfile.  */
-
-extern void record_debugformat (const char *format);
-
-/* Record the name of the debuginfo producer (usually the compiler) in
-   the current pending symbol table.  PRODUCER must be a string with a
-   lifetime at least as long as the symtab's objfile.  */
-
-extern void record_producer (const char *producer);
-
-/* Set the name of the last source file.  NAME is copied by this
-   function.  */
-
-extern void set_last_source_file (const char *name);
-
-/* Fetch the name of the last source file.  */
-
-extern const char *get_last_source_file (void);
-
-/* Return the compunit symtab object.
-   It is only valid to call this between calls to start_symtab and the
-   end_symtab* functions.  */
-
-extern struct compunit_symtab *buildsym_compunit_symtab (void);
-
-/* Return the macro table.
-   Initialize it if this is the first use.
-   It is only valid to call this between calls to start_symtab and the
-   end_symtab* functions.  */
-
-extern struct macro_table *get_macro_table (void);
-
-/* Set the last source start address.  Can only be used between
-   start_symtab and end_symtab* calls.  */
-
-extern void set_last_source_start_addr (CORE_ADDR addr);
-
-/* Get the last source start address.  Can only be used between
-   start_symtab and end_symtab* calls.  */
-
-extern CORE_ADDR get_last_source_start_addr ();
-
-/* Return the local using directives.  */
-
-extern struct using_direct **get_local_using_directives ();
-
-/* Set the list of local using directives.  */
-
-extern void set_local_using_directives (struct using_direct *new_local);
-
-/* Return the global using directives.  */
-
-extern struct using_direct **get_global_using_directives ();
-
-/* Non-zero if the context stack is empty.  */
-
-extern bool outermost_context_p ();
-
-/* Return the top of the context stack, or nullptr if there is
-   entry.  */
-
-extern struct context_stack *get_current_context_stack ();
-
-/* Return the context stack depth.  */
-
-extern int get_context_stack_depth ();
-
-/* Return the current subfile.  */
-
-extern struct subfile *get_current_subfile ();
-
-/* Return the local symbol list.  */
-
-extern struct pending **get_local_symbols ();
-
-/* Return the file symbol list.  */
-
-extern struct pending **get_file_symbols ();
-
-/* Return the global symbol list.  */
-
-extern struct pending **get_global_symbols ();
-
 #endif /* defined (BUILDSYM_H) */
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 3bb6639914..f44b2180f7 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -30,7 +30,7 @@
 #include "coff/internal.h"	/* Internal format of COFF symbols in BFD */
 #include "libcoff.h"		/* FIXME secret internal data from BFD */
 #include "objfiles.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "gdb-stabs.h"
 #include "stabsread.h"
 #include "complaints.h"
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 22b7af00d6..41affca3a8 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -29,7 +29,7 @@
 #include "dictionary.h"
 #include "command.h"
 #include "frame.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "language.h"
 #include "namespace.h"
 #include <string>
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index d660157a61..52d19310cb 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -45,7 +45,7 @@
 #include "libaout.h"		/* FIXME Secret internal BFD stuff for a.out */
 #include "filenames.h"
 #include "objfiles.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "stabsread.h"
 #include "gdb-stabs.h"
 #include "demangle.h"
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9753a5b57d..75a121073c 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -37,7 +37,7 @@
 #include "gdbtypes.h"
 #include "objfiles.h"
 #include "dwarf2.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "demangle.h"
 #include "gdb-demangle.h"
 #include "expression.h"
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 980180b23a..9796d15f0e 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -94,7 +94,7 @@
 #include "command.h"
 #include "gdbcmd.h"
 #include "floatformat.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "i387-tdep.h"
 #include "i386-tdep.h"
 #include "nat/x86-cpuid.h"
diff --git a/gdb/legacy-buildsym.h b/gdb/legacy-buildsym.h
new file mode 100644
index 0000000000..66a3ea8cd0
--- /dev/null
+++ b/gdb/legacy-buildsym.h
@@ -0,0 +1,210 @@
+/* Build symbol tables in GDB's internal format - legacy APIs
+   Copyright (C) 1986-2018 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#if !defined (LEGACY_BUILDSYM_H)
+#define LEGACY_BUILDSYM_H 1
+
+#include "buildsym.h"
+
+/* This module provides definitions used for creating and adding to
+   the symbol table.  These routines are called from various symbol-
+   file-reading routines.  This file holds the legacy API, which
+   relies on a global variable to work properly.  New or maintained
+   symbol readers should use the builder API in buildsym.h.
+
+   The basic way this module is used is as follows:
+
+   scoped_free_pendings free_pending;
+   cust = start_symtab (...);
+   ... read debug info ...
+   cust = end_symtab (...);
+
+   The compunit symtab pointer ("cust") is returned from both start_symtab
+   and end_symtab to simplify the debug info readers.
+
+   There are minor variations on this, e.g., dwarf2read.c splits end_symtab
+   into two calls: end_symtab_get_static_block, end_symtab_from_static_block,
+   but all debug info readers follow this basic flow.
+
+   Reading DWARF Type Units is another variation:
+
+   scoped_free_pendings free_pending;
+   cust = start_symtab (...);
+   ... read debug info ...
+   cust = end_expandable_symtab (...);
+
+   And then reading subsequent Type Units within the containing "Comp Unit"
+   will use a second flow:
+
+   scoped_free_pendings free_pending;
+   cust = restart_symtab (...);
+   ... read debug info ...
+   cust = augment_type_symtab (...);
+
+   dbxread.c and xcoffread.c use another variation:
+
+   scoped_free_pendings free_pending;
+   cust = start_symtab (...);
+   ... read debug info ...
+   cust = end_symtab (...);
+   ... start_symtab + read + end_symtab repeated ...
+*/
+
+class scoped_free_pendings
+{
+public:
+
+  scoped_free_pendings ();
+  ~scoped_free_pendings ();
+
+  DISABLE_COPY_AND_ASSIGN (scoped_free_pendings);
+};
+
+extern struct block *finish_block (struct symbol *symbol,
+				   struct pending_block *old_blocks,
+				   const struct dynamic_prop *static_link,
+				   CORE_ADDR start,
+				   CORE_ADDR end);
+
+extern void record_block_range (struct block *,
+                                CORE_ADDR start, CORE_ADDR end_inclusive);
+
+extern void start_subfile (const char *name);
+
+extern void patch_subfile_names (struct subfile *subfile, const char *name);
+
+extern void push_subfile ();
+
+extern const char *pop_subfile ();
+
+extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
+						  int expandable,
+						  int required);
+
+extern struct compunit_symtab *
+  end_symtab_from_static_block (struct block *static_block,
+				int section, int expandable);
+
+extern struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
+
+extern struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
+						      int section);
+
+extern void augment_type_symtab (void);
+
+extern struct context_stack *push_context (int desc, CORE_ADDR valu);
+
+extern struct context_stack *pop_context (void);
+
+extern record_line_ftype record_line;
+
+extern struct compunit_symtab *start_symtab (struct objfile *objfile,
+					     const char *name,
+					     const char *comp_dir,
+					     CORE_ADDR start_addr,
+					     enum language language);
+
+extern void restart_symtab (struct compunit_symtab *cust,
+			    const char *name, CORE_ADDR start_addr);
+
+/* Record the name of the debug format in the current pending symbol
+   table.  FORMAT must be a string with a lifetime at least as long as
+   the symtab's objfile.  */
+
+extern void record_debugformat (const char *format);
+
+/* Record the name of the debuginfo producer (usually the compiler) in
+   the current pending symbol table.  PRODUCER must be a string with a
+   lifetime at least as long as the symtab's objfile.  */
+
+extern void record_producer (const char *producer);
+
+/* Set the name of the last source file.  NAME is copied by this
+   function.  */
+
+extern void set_last_source_file (const char *name);
+
+/* Fetch the name of the last source file.  */
+
+extern const char *get_last_source_file (void);
+
+/* Return the compunit symtab object.
+   It is only valid to call this between calls to start_symtab and the
+   end_symtab* functions.  */
+
+extern struct compunit_symtab *buildsym_compunit_symtab (void);
+
+/* Return the macro table.
+   Initialize it if this is the first use.
+   It is only valid to call this between calls to start_symtab and the
+   end_symtab* functions.  */
+
+extern struct macro_table *get_macro_table (void);
+
+/* Set the last source start address.  Can only be used between
+   start_symtab and end_symtab* calls.  */
+
+extern void set_last_source_start_addr (CORE_ADDR addr);
+
+/* Get the last source start address.  Can only be used between
+   start_symtab and end_symtab* calls.  */
+
+extern CORE_ADDR get_last_source_start_addr ();
+
+/* Return the local using directives.  */
+
+extern struct using_direct **get_local_using_directives ();
+
+/* Set the list of local using directives.  */
+
+extern void set_local_using_directives (struct using_direct *new_local);
+
+/* Return the global using directives.  */
+
+extern struct using_direct **get_global_using_directives ();
+
+/* Non-zero if the context stack is empty.  */
+
+extern bool outermost_context_p ();
+
+/* Return the top of the context stack, or nullptr if there is
+   entry.  */
+
+extern struct context_stack *get_current_context_stack ();
+
+/* Return the context stack depth.  */
+
+extern int get_context_stack_depth ();
+
+/* Return the current subfile.  */
+
+extern struct subfile *get_current_subfile ();
+
+/* Return the local symbol list.  */
+
+extern struct pending **get_local_symbols ();
+
+/* Return the file symbol list.  */
+
+extern struct pending **get_file_symbols ();
+
+/* Return the global symbol list.  */
+
+extern struct pending **get_global_symbols ();
+
+#endif /* defined (LEGACY_BUILDSYM_H) */
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 466e36599b..bebefcb724 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -46,7 +46,7 @@
 #include "filenames.h"
 #include "objfiles.h"
 #include "gdb_obstack.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "stabsread.h"
 #include "complaints.h"
 #include "demangle.h"
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index ebb844d2c5..62221d03cf 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -36,7 +36,7 @@
 #include "libaout.h"
 #include "aout/aout64.h"
 #include "gdb-stabs.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "complaints.h"
 #include "demangle.h"
 #include "gdb-demangle.h"
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 16ebd17607..f706b1db39 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -44,7 +44,7 @@
 #endif
 #include <algorithm>
 
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "filenames.h"
 #include "symfile.h"
 #include "objfiles.h"
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 6b561a82b3..92d6934af7 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -41,7 +41,7 @@
 /* FIXME: ezannoni/2004-02-13 Verify if the include below is really needed.  */
 #include "symfile.h"
 #include "objfiles.h"
-#include "buildsym.h"
+#include "legacy-buildsym.h"
 #include "stabsread.h"
 #include "expression.h"
 #include "complaints.h"
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* [RFA 30/42] Remove buildsym_init
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (40 preceding siblings ...)
  2018-05-23  7:31 ` [RFA 38/42] Introduce legacy-buildsym.h Tom Tromey
@ 2018-05-23  8:49 ` Tom Tromey
  2018-07-10  3:41   ` Simon Marchi
  2018-06-18 14:46 ` [RFA 00/42] Remove globals from buildsym Tom Tromey
  2018-07-05 18:21 ` Keith Seitz
  43 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-05-23  8:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Now that buildsym_init does nothing, it can be removed.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_psymtab_to_symtab_1): Update.
	(xcoff_new_init): Update.
	* mipsread.c (mipscoff_new_init): Update.
	* mdebugread.c (mdebug_build_psymtabs): Update.
	* elfread.c (elf_new_init): Update.
	* dwarf2read.c (process_full_comp_unit, process_full_type_unit):
	Update.
	* dbxread.c (dbx_new_init, dbx_psymtab_to_symtab_1)
	(coffstab_build_psymtabs, elfstab_build_psymtabs)
	(stabsect_build_psymtabs): Update.
	* buildsym.h (buildsym_init): Don't declare.
	* buildsym.c: Update comment.
	(prepare_for_building): Remove.
	(start_symtab, restart_symtab): Update.
	(reset_symtab_globals): Update comment.
	(buildsym_init): Remove.
---
 gdb/ChangeLog    | 19 +++++++++++++++++++
 gdb/buildsym.c   | 42 +++++++-----------------------------------
 gdb/buildsym.h   |  2 --
 gdb/dbxread.c    |  5 -----
 gdb/dwarf2read.c |  2 --
 gdb/elfread.c    |  1 -
 gdb/mdebugread.c |  1 -
 gdb/mipsread.c   |  1 -
 gdb/xcoffread.c  |  2 --
 9 files changed, 26 insertions(+), 49 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 0e21cfd83a..fec06f3d88 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -25,7 +25,6 @@
 
    The basic way this module is used is as follows:
 
-   buildsym_init ();
    scoped_free_pendings free_pending;
    cust = start_symtab (...);
    ... read debug info ...
@@ -40,7 +39,6 @@
 
    Reading DWARF Type Units is another variation:
 
-   buildsym_init ();
    scoped_free_pendings free_pending;
    cust = start_symtab (...);
    ... read debug info ...
@@ -49,7 +47,6 @@
    And then reading subsequent Type Units within the containing "Comp Unit"
    will use a second flow:
 
-   buildsym_init ();
    scoped_free_pendings free_pending;
    cust = restart_symtab (...);
    ... read debug info ...
@@ -57,7 +54,6 @@
 
    dbxread.c and xcoffread.c use another variation:
 
-   buildsym_init ();
    scoped_free_pendings free_pending;
    cust = start_symtab (...);
    ... read debug info ...
@@ -1000,19 +996,6 @@ get_macro_table (void)
   return buildsym_compunit->get_macro_table ();
 }
 \f
-/* Init state to prepare for building a symtab.
-   Note: This can't be done in buildsym_init because dbxread.c and xcoffread.c
-   can call start_symtab+end_symtab multiple times after one call to
-   buildsym_init.  */
-
-static void
-prepare_for_building ()
-{
-  /* These should have been reset either by successful completion of building
-     a symtab, or by the scoped_free_pendings destructor.  */
-  gdb_assert (buildsym_compunit == nullptr);
-}
-
 /* Start a new symtab for a new source file in OBJFILE.  Called, for example,
    when a stabs symbol of type N_SO is seen, or when a DWARF
    TAG_compile_unit DIE is seen.  It indicates the start of data for
@@ -1029,7 +1012,9 @@ struct compunit_symtab *
 start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
 	      CORE_ADDR start_addr, enum language language)
 {
-  prepare_for_building ();
+  /* These should have been reset either by successful completion of building
+     a symtab, or by the scoped_free_pendings destructor.  */
+  gdb_assert (buildsym_compunit == nullptr);
 
   buildsym_compunit = new struct buildsym_compunit (objfile, name, comp_dir,
 						    language, start_addr);
@@ -1066,7 +1051,9 @@ void
 restart_symtab (struct compunit_symtab *cust,
 		const char *name, CORE_ADDR start_addr)
 {
-  prepare_for_building ();
+  /* These should have been reset either by successful completion of building
+     a symtab, or by the scoped_free_pendings destructor.  */
+  gdb_assert (buildsym_compunit == nullptr);
 
   buildsym_compunit
     = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust),
@@ -1150,11 +1137,7 @@ watch_main_source_file_lossage (void)
     }
 }
 
-/* Reset state after a successful building of a symtab.
-   This exists because dbxread.c and xcoffread.c can call
-   start_symtab+end_symtab multiple times after one call to buildsym_init,
-   and before the scoped_free_pendings destructor is called.
-   We keep the free_pendings list around for dbx/xcoff sake.  */
+/* Reset state after a successful building of a symtab.  */
 
 static void
 reset_symtab_globals (void)
@@ -1767,14 +1750,3 @@ get_global_symbols ()
   gdb_assert (buildsym_compunit != nullptr);
   return &buildsym_compunit->m_global_symbols;
 }
-
-\f
-
-/* Initialize anything that needs initializing when starting to read a
-   fresh piece of a symbol file, e.g. reading in the stuff
-   corresponding to a psymtab.  */
-
-void
-buildsym_init ()
-{
-}
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 71d133e6ad..b6d16876d6 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -171,8 +171,6 @@ extern struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
 
 extern void augment_type_symtab (void);
 
-extern void buildsym_init ();
-
 extern struct context_stack *push_context (int desc, CORE_ADDR valu);
 
 extern struct context_stack *pop_context (void);
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 989ce77be2..d660157a61 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -568,7 +568,6 @@ static void
 dbx_new_init (struct objfile *ignore)
 {
   stabsread_new_init ();
-  buildsym_init ();
   init_header_files ();
 }
 
@@ -2224,7 +2223,6 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
     {
       /* Init stuff necessary for reading in symbols */
       stabsread_init ();
-      buildsym_init ();
       scoped_free_pendings free_pending;
       file_string_table_offset = FILE_STRING_OFFSET (pst);
       symbol_size = SYMBOL_SIZE (pst);
@@ -3103,7 +3101,6 @@ coffstab_build_psymtabs (struct objfile *objfile,
     perror_with_name (name);
 
   stabsread_new_init ();
-  buildsym_init ();
   free_header_files ();
   init_header_files ();
 
@@ -3192,7 +3189,6 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
     perror_with_name (name);
 
   stabsread_new_init ();
-  buildsym_init ();
   free_header_files ();
   init_header_files ();
 
@@ -3292,7 +3288,6 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
     perror_with_name (name);
 
   stabsread_new_init ();
-  buildsym_init ();
   free_header_files ();
   init_header_files ();
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b73f13bb19..9753a5b57d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10275,7 +10275,6 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
-  buildsym_init ();
   scoped_free_pendings free_pending;
 
   /* Clear the list here in case something was left over.  */
@@ -10378,7 +10377,6 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
   gdb_assert (per_cu->is_debug_types);
   sig_type = (struct signatured_type *) per_cu;
 
-  buildsym_init ();
   scoped_free_pendings free_pending;
 
   /* Clear the list here in case something was left over.  */
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 8978f15e88..9bbd0c85e4 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1325,7 +1325,6 @@ static void
 elf_new_init (struct objfile *ignore)
 {
   stabsread_new_init ();
-  buildsym_init ();
 }
 
 /* Perform any local cleanups required when we are done with a particular
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 1045426c67..466e36599b 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -345,7 +345,6 @@ mdebug_build_psymtabs (minimal_symbol_reader &reader,
   debug_info = info;
 
   stabsread_new_init ();
-  buildsym_init ();
   free_header_files ();
   init_header_files ();
         
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 3bdc50733d..52130dab20 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -54,7 +54,6 @@ static void
 mipscoff_new_init (struct objfile *ignore)
 {
   stabsread_new_init ();
-  buildsym_init ();
 }
 
 /* Initialize to read a symbol file (nothing to do).  */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 4ccc5bf7fc..6b561a82b3 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1875,7 +1875,6 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
     {
       /* Init stuff necessary for reading in symbols.  */
       stabsread_init ();
-      buildsym_init ();
 
       scoped_free_pendings free_pending;
       read_xcoff_symtab (objfile, pst);
@@ -1927,7 +1926,6 @@ static void
 xcoff_new_init (struct objfile *objfile)
 {
   stabsread_new_init ();
-  buildsym_init ();
 }
 
 /* Do initialization in preparation for reading symbols from OBJFILE.
-- 
2.13.6

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 00/42] Remove globals from buildsym
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (41 preceding siblings ...)
  2018-05-23  8:49 ` [RFA 30/42] Remove buildsym_init Tom Tromey
@ 2018-06-18 14:46 ` Tom Tromey
  2018-07-05 18:21 ` Keith Seitz
  43 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-06-18 14:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> I've long wanted to remove the globals from buildsym and generally
Tom> clean it up.  I've finally tackled this project, and this series is
Tom> the result.

Ping.  Sorry about this one.  I could maybe split it into smaller chunks
if that would help.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 00/42] Remove globals from buildsym
  2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
                   ` (42 preceding siblings ...)
  2018-06-18 14:46 ` [RFA 00/42] Remove globals from buildsym Tom Tromey
@ 2018-07-05 18:21 ` Keith Seitz
  43 siblings, 0 replies; 129+ messages in thread
From: Keith Seitz @ 2018-07-05 18:21 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> I've long wanted to remove the globals from buildsym and generally
> clean it up.  I've finally tackled this project, and this series is
> the result.

YAHOO!!!

> Also, I simultaneously wrote this series and learned about some the
> workings of buildsym.  So, there are some cases where something is
> done -- say, an assertion added or a variable made static -- only to
> be un-done later in the series.  Reordering seemed generally painful
> so I have left it as is.

That's reasonable.

> The general idea behind the patches is to move each global variable
> (or related set of global variables) into the existing
> buildsym_compunit structure.  Along the way, some minor cleanups are
> done, for example moving stabs-specific things to stabsread.

Nice.

> Once all of the state is in buildsym_compunit, it is put into
> buildsym.h for use by symbol readers.  Here, I've converted the DWARF
> reader to use the new-style API, leaving the other readers alone.
> (The other readers continue to rely on a global, but now only one.)

There are other symbol readers besides DWARF? :-P

> I haven't tried much to clean up buildsym itself.  The API is just as
> unwieldy as ever -- it just no longer has global state.  I have,
> however, replaced some data structures with self-managing ones.
> 
> There are some holes with the series that you may wish to consider.
> 
> * Perhaps some more comments could be added.
> 
> * There are still some stabs-specific hacks in buildsym.c that I have
>   not attempted to remove.
> 
> * There are some remaining calls to set_last_source_file (NULL) that
>   could perhaps be removed as unnecessary.  I did not check.

Upon a "cursory" inspection, the most common nit that I'll mention is moving comments to header files (from corresponding .c files). TBH, our coding standard appears to be in turmoil right now as we shake out C++ (at least it is in my mind!), so feel free to ignore these types of comments.

> Regression tested by the buildbot.  I also did a reasonable, but not
> exhaustive, amount of testing here.  I've at least smoke-tested the
> stabs reader by running some tests with --target_board=stabs.

I've regtested it locally, too, reproducing a stgit with all of the patches. All looks good.

In general, I didn't find anything glaringly wrong (but I am just back from a `long' vacation and still a little "out of the office"), but I will respond to individual patches with questions and the like.

Thanks,
Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 01/42] Use new and delete for buildsym_compunit
  2018-05-23  4:59 ` [RFA 01/42] Use new and delete for buildsym_compunit Tom Tromey
@ 2018-07-05 18:50   ` Keith Seitz
  2018-07-07  2:31     ` Simon Marchi
  2018-07-08 16:25     ` Tom Tromey
  0 siblings, 2 replies; 129+ messages in thread
From: Keith Seitz @ 2018-07-05 18:50 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Hi, Tom,

I've got one general question:

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> This changes buildsym_compunit to use new and delete.
> 
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index 5d38cb250f..9863e4ea1e 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -107,24 +136,24 @@ struct buildsym_compunit
>       Files are added to the front of the list.
>       This is important mostly for the language determination hacks we use,
>       which iterate over previously added files.  */
> -  struct subfile *subfiles;
> +  struct subfile *subfiles = nullptr;
>  
>    /* The subfile of the main source file.  */
> -  struct subfile *main_subfile;
> +  struct subfile *main_subfile = nullptr;
>  
>    /* E.g., DW_AT_comp_dir if DWARF.  Space for this is malloc'd.  */
>    char *comp_dir;
>  
>    /* Space for this is not malloc'd, and is assumed to have at least
>       the same lifetime as objfile.  */
> -  const char *producer;
> +  const char *producer = nullptr;
>  
>    /* Space for this is not malloc'd, and is assumed to have at least
>       the same lifetime as objfile.  */
> -  const char *debugformat;
> +  const char *debugformat = nullptr;
>  
>    /* The compunit we are building.  */
> -  struct compunit_symtab *compunit_symtab;
> +  struct compunit_symtab *compunit_symtab = nullptr;
>  
>    /* Language of this compunit_symtab.  */
>    enum language language;

By the end of the series, this struct declaration is moved to buildsym.h and a bunch of new, private data is added. All those data members are named "m_XYZ" whereas the above variable names are never receive the "m_" treatment.

Since these variables will later become private, should they not also (some time) be renamed?
[I think this should/could be a follow-on patch -- no changes needed here.]

Keith

PS:

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 0c7efa3d51..32f9b69331 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -70,15 +70,15 @@ buildsym_compunit::buildsym_compunit (struct objfile *objfile_,
 				      const char *comp_dir_,
 				      enum language language_,
 				      CORE_ADDR last_addr)
-  : objfile (objfile_),
+  : m_objfile (objfile_),
     m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
-    comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
-    language (language_),
+    m_comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
+    m_language (language_),
     m_last_source_start_addr (last_addr)
 {
   /* Allocate the compunit symtab now.  The caller needs it to allocate
      non-primary symtabs.  It is also needed by get_macro_table.  */
-  compunit_symtab = allocate_compunit_symtab (objfile, name);
+  m_compunit_symtab = allocate_compunit_symtab (m_objfile, name);
 
   /* Build the subfile for NAME (the main source file) so that we can record
      a pointer to it for later.
@@ -89,7 +89,7 @@ buildsym_compunit::buildsym_compunit (struct objfile *objfile_,
   start_subfile (name);
   /* Save this so that we don't have to go looking for it at the end
      of the subfiles list.  */
-  main_subfile = m_current_subfile;
+  m_main_subfile = m_current_subfile;
 }
 
 buildsym_compunit::~buildsym_compunit ()
@@ -99,7 +99,7 @@ buildsym_compunit::~buildsym_compunit ()
   if (m_pending_macros != nullptr)
     free_macro_table (m_pending_macros);
 
-  for (subfile = subfiles;
+  for (subfile = m_subfiles;
        subfile != NULL;
        subfile = nextsub)
     {
@@ -128,9 +128,9 @@ struct macro_table *
 buildsym_compunit::get_macro_table ()
 {
   if (m_pending_macros == nullptr)
-    m_pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
-					objfile->per_bfd->macro_cache,
-					compunit_symtab);
+    m_pending_macros = new_macro_table (&m_objfile->per_bfd->storage_obstack,
+					m_objfile->per_bfd->macro_cache,
+					m_compunit_symtab);
   return m_pending_macros;
 }
 
@@ -237,34 +237,34 @@ buildsym_compunit::finish_block_internal
      CORE_ADDR start, CORE_ADDR end,
      int is_global, int expandable)
 {
-  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+  struct gdbarch *gdbarch = get_objfile_arch (m_objfile);
   struct pending *next, *next1;
   struct block *block;
   struct pending_block *pblock;
   struct pending_block *opblock;
 
   block = (is_global
-	   ? allocate_global_block (&objfile->objfile_obstack)
-	   : allocate_block (&objfile->objfile_obstack));
+	   ? allocate_global_block (&m_objfile->objfile_obstack)
+	   : allocate_block (&m_objfile->objfile_obstack));
 
   if (symbol)
     {
       BLOCK_DICT (block)
-	= dict_create_linear (&objfile->objfile_obstack,
-			      language, *listhead);
+	= dict_create_linear (&m_objfile->objfile_obstack,
+			      m_language, *listhead);
     }
   else
     {
       if (expandable)
 	{
-	  BLOCK_DICT (block) = dict_create_hashed_expandable (language);
+	  BLOCK_DICT (block) = dict_create_hashed_expandable (m_language);
 	  dict_add_pending (BLOCK_DICT (block), *listhead);
 	}
       else
 	{
 	  BLOCK_DICT (block) =
-	    dict_create_hashed (&objfile->objfile_obstack,
-				language, *listhead);
+	    dict_create_hashed (&m_objfile->objfile_obstack,
+				m_language, *listhead);
 	}
     }
 
@@ -325,7 +325,7 @@ buildsym_compunit::finish_block_internal
     }
 
   if (static_link != NULL)
-    objfile_register_static_link (objfile, block, static_link);
+    objfile_register_static_link (m_objfile, block, static_link);
 
   /* Now free the links of the list, and empty the list.  */
 
@@ -407,7 +407,7 @@ buildsym_compunit::finish_block_internal
 		   (is_global
 		    ? m_global_using_directives
 		    : m_local_using_directives),
-		   &objfile->objfile_obstack);
+		   &m_objfile->objfile_obstack);
   if (is_global)
     m_global_using_directives = NULL;
   else
@@ -470,7 +470,7 @@ buildsym_compunit::make_blockvector ()
     }
 
   blockvector = (struct blockvector *)
-    obstack_alloc (&objfile->objfile_obstack,
+    obstack_alloc (&m_objfile->objfile_obstack,
 		   (sizeof (struct blockvector)
 		    + (i - 1) * sizeof (struct block *)));
 
@@ -492,7 +492,7 @@ buildsym_compunit::make_blockvector ()
      blockvector.  */
   if (m_pending_addrmap && m_pending_addrmap_interesting)
     BLOCKVECTOR_MAP (blockvector)
-      = addrmap_create_fixed (m_pending_addrmap, &objfile->objfile_obstack);
+      = addrmap_create_fixed (m_pending_addrmap, &m_objfile->objfile_obstack);
   else
     BLOCKVECTOR_MAP (blockvector) = 0;
 
@@ -531,11 +531,11 @@ buildsym_compunit::start_subfile (const char *name)
   const char *subfile_dirname;
   struct subfile *subfile;
 
-  subfile_dirname = comp_dir.get ();
+  subfile_dirname = m_comp_dir.get ();
 
   /* See if this subfile is already registered.  */
 
-  for (subfile = subfiles; subfile; subfile = subfile->next)
+  for (subfile = m_subfiles; subfile; subfile = subfile->next)
     {
       char *subfile_name;
 
@@ -566,8 +566,8 @@ buildsym_compunit::start_subfile (const char *name)
   memset (subfile, 0, sizeof (struct subfile));
   subfile->buildsym_compunit = this;
 
-  subfile->next = subfiles;
-  subfiles = subfile;
+  subfile->next = m_subfiles;
+  m_subfiles = subfile;
 
   m_current_subfile = subfile;
 
@@ -605,7 +605,7 @@ buildsym_compunit::start_subfile (const char *name)
       enum language sublang = deduce_language_from_filename (subfile->name);
 
       if (sublang == language_cplus || sublang == language_fortran)
-	for (s = subfiles; s != NULL; s = s->next)
+	for (s = m_subfiles; s != NULL; s = s->next)
 	  if (s->language == language_c)
 	    s->language = sublang;
     }
@@ -648,11 +648,11 @@ buildsym_compunit::patch_subfile_names (struct subfile *subfile,
 					const char *name)
 {
   if (subfile != NULL
-      && comp_dir == NULL
+      && m_comp_dir == NULL
       && subfile->name != NULL
       && IS_DIR_SEPARATOR (subfile->name[strlen (subfile->name) - 1]))
     {
-      comp_dir.reset (subfile->name);
+      m_comp_dir.reset (subfile->name);
       subfile->name = xstrdup (name);
       set_last_source_file (name);
 
@@ -872,7 +872,7 @@ buildsym_compunit::watch_main_source_file_lossage ()
   struct subfile *mainsub, *subfile;
 
   /* Get the main source file.  */
-  mainsub = main_subfile;
+  mainsub = m_main_subfile;
 
   /* If the main source file doesn't have any line number or symbol
      info, look for an alias in another subfile.  */
@@ -887,7 +887,7 @@ buildsym_compunit::watch_main_source_file_lossage ()
       struct subfile *prev_mainsub_alias = NULL;
 
       prevsub = NULL;
-      for (subfile = subfiles;
+      for (subfile = m_subfiles;
 	   subfile != NULL;
 	   subfile = subfile->next)
 	{
@@ -915,7 +915,7 @@ buildsym_compunit::watch_main_source_file_lossage ()
 	  mainsub->symtab = mainsub_alias->symtab;
 
 	  if (prev_mainsub_alias == NULL)
-	    subfiles = mainsub_alias->next;
+	    m_subfiles = mainsub_alias->next;
 	  else
 	    prev_mainsub_alias->next = mainsub_alias->next;
 	  xfree (mainsub_alias->name);
@@ -968,7 +968,7 @@ buildsym_compunit::end_symtab_get_static_block (CORE_ADDR end_addr,
   /* Reordered executables may have out of order pending blocks; if
      OBJF_REORDERED is true, then sort the pending blocks.  */
 
-  if ((objfile->flags & OBJF_REORDERED) && m_pending_blocks)
+  if ((m_objfile->flags & OBJF_REORDERED) && m_pending_blocks)
     {
       struct pending_block *pb;
 
@@ -1001,8 +1001,8 @@ buildsym_compunit::end_symtab_get_static_block (CORE_ADDR end_addr,
      are no-ops.  FIXME: Is this handled right in case of QUIT?  Can
      we make this cleaner?  */
 
-  cleanup_undefined_stabs_types (objfile);
-  finish_global_stabs (objfile);
+  cleanup_undefined_stabs_types (m_objfile);
+  finish_global_stabs (m_objfile);
 
   if (!required
       && m_pending_blocks == NULL
@@ -1032,14 +1032,14 @@ struct compunit_symtab *
 buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
 						int section, int expandable)
 {
-  struct compunit_symtab *cu = compunit_symtab;
+  struct compunit_symtab *cu = m_compunit_symtab;
   struct symtab *symtab;
   struct blockvector *blockvector;
   struct subfile *subfile;
   CORE_ADDR end_addr;
 
   gdb_assert (static_block != NULL);
-  gdb_assert (subfiles != NULL);
+  gdb_assert (m_subfiles != NULL);
 
   end_addr = BLOCK_END (static_block);
 
@@ -1051,8 +1051,8 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
 
   /* Read the line table if it has to be read separately.
      This is only used by xcoffread.c.  */
-  if (objfile->sf->sym_read_linetable != NULL)
-    objfile->sf->sym_read_linetable (objfile);
+  if (m_objfile->sf->sym_read_linetable != NULL)
+    m_objfile->sf->sym_read_linetable (m_objfile);
 
   /* Handle the case where the debug info specifies a different path
      for the main source file.  It can cause us to lose track of its
@@ -1062,7 +1062,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
   /* Now create the symtab objects proper, if not already done,
      one for each subfile.  */
 
-  for (subfile = subfiles;
+  for (subfile = m_subfiles;
        subfile != NULL;
        subfile = subfile->next)
     {
@@ -1076,7 +1076,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
 	  /* Like the pending blocks, the line table may be
 	     scrambled in reordered executables.  Sort it if
 	     OBJF_REORDERED is true.  */
-	  if (objfile->flags & OBJF_REORDERED)
+	  if (m_objfile->flags & OBJF_REORDERED)
 	    qsort (subfile->line_vector->item,
 		   subfile->line_vector->nitems,
 		   sizeof (struct linetable_entry), compare_line_numbers);
@@ -1093,7 +1093,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
 	{
 	  /* Reallocate the line table on the symbol obstack.  */
 	  SYMTAB_LINETABLE (symtab) = (struct linetable *)
-	    obstack_alloc (&objfile->objfile_obstack, linetablesize);
+	    obstack_alloc (&m_objfile->objfile_obstack, linetablesize);
 	  memcpy (SYMTAB_LINETABLE (symtab), subfile->line_vector,
 		  linetablesize);
 	}
@@ -1115,7 +1115,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
   {
     struct symtab *main_symtab, *prev_symtab;
 
-    main_symtab = main_subfile->symtab;
+    main_symtab = m_main_subfile->symtab;
     prev_symtab = NULL;
     ALL_COMPUNIT_FILETABS (cu, symtab)
       {
@@ -1136,20 +1136,20 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
 
   /* Fill out the compunit symtab.  */
 
-  if (comp_dir != NULL)
+  if (m_comp_dir != NULL)
     {
       /* Reallocate the dirname on the symbol obstack.  */
-      const char *comp_dir = this->comp_dir.get ();
+      const char *comp_dir = m_comp_dir.get ();
       COMPUNIT_DIRNAME (cu)
-	= (const char *) obstack_copy0 (&objfile->objfile_obstack,
+	= (const char *) obstack_copy0 (&m_objfile->objfile_obstack,
 					comp_dir, strlen (comp_dir));
     }
 
   /* Save the debug format string (if any) in the symtab.  */
-  COMPUNIT_DEBUGFORMAT (cu) = debugformat;
+  COMPUNIT_DEBUGFORMAT (cu) = m_debugformat;
 
   /* Similarly for the producer.  */
-  COMPUNIT_PRODUCER (cu) = producer;
+  COMPUNIT_PRODUCER (cu) = m_producer;
 
   COMPUNIT_BLOCKVECTOR (cu) = blockvector;
   {
@@ -1298,7 +1298,7 @@ set_missing_symtab (struct pending *pending_list,
 void
 buildsym_compunit::augment_type_symtab ()
 {
-  struct compunit_symtab *cust = compunit_symtab;
+  struct compunit_symtab *cust = m_compunit_symtab;
   const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
 
   if (!m_context_stack.empty ())
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index d90faff903..41d1c61ba2 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -124,11 +124,11 @@ struct buildsym_compunit
   buildsym_compunit (struct objfile *objfile_, const char *name,
 		     const char *comp_dir_, enum language language_,
 		     CORE_ADDR last_addr, struct compunit_symtab *cust)
-    : objfile (objfile_),
+    : m_objfile (objfile_),
       m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
-      comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
-      compunit_symtab (cust),
-      language (language_),
+      m_comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
+      m_compunit_symtab (cust),
+      m_language (language_),
       m_last_source_start_addr (last_addr)
   {
   }
@@ -185,7 +185,7 @@ struct buildsym_compunit
 
   struct compunit_symtab *get_compunit_symtab ()
   {
-    return compunit_symtab;
+    return m_compunit_symtab;
   }
 
   void set_last_source_start_addr (CORE_ADDR addr)
@@ -252,12 +252,12 @@ struct buildsym_compunit
 
   void record_debugformat (const char *format)
   {
-    debugformat = format;
+    m_debugformat = format;
   }
 
   void record_producer (const char *producer)
   {
-    this->producer = producer;
+    m_producer = producer;
   }
 
   struct context_stack *push_context (int desc, CORE_ADDR valu);
@@ -296,16 +296,16 @@ private:
       (struct block *static_block, int section, int expandable);
 
   /* The objfile we're reading debug info from.  */
-  struct objfile *objfile;
+  struct objfile *m_objfile;
 
   /* List of subfiles (source files).
      Files are added to the front of the list.
      This is important mostly for the language determination hacks we use,
      which iterate over previously added files.  */
-  struct subfile *subfiles = nullptr;
+  struct subfile *m_subfiles = nullptr;
 
   /* The subfile of the main source file.  */
-  struct subfile *main_subfile = nullptr;
+  struct subfile *m_main_subfile = nullptr;
 
   /* Name of source file whose symbol data we are now processing.  This
      comes from a symbol of type N_SO for stabs.  For Dwarf it comes
@@ -314,21 +314,21 @@ private:
   gdb::unique_xmalloc_ptr<char> m_last_source_file;
 
   /* E.g., DW_AT_comp_dir if DWARF.  Space for this is malloc'd.  */
-  gdb::unique_xmalloc_ptr<char> comp_dir;
+  gdb::unique_xmalloc_ptr<char> m_comp_dir;
 
   /* Space for this is not malloc'd, and is assumed to have at least
      the same lifetime as objfile.  */
-  const char *producer = nullptr;
+  const char *m_producer = nullptr;
 
   /* Space for this is not malloc'd, and is assumed to have at least
      the same lifetime as objfile.  */
-  const char *debugformat = nullptr;
+  const char *m_debugformat = nullptr;
 
   /* The compunit we are building.  */
-  struct compunit_symtab *compunit_symtab = nullptr;
+  struct compunit_symtab *m_compunit_symtab = nullptr;
 
   /* Language of this compunit_symtab.  */
-  enum language language;
+  enum language m_language;
 
   /* The macro table for the compilation unit whose symbols we're
      currently reading.  */

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 06/42] Move have_line_numbers to buildsym_compunit
  2018-05-23  4:59 ` [RFA 06/42] Move have_line_numbers to buildsym_compunit Tom Tromey
@ 2018-07-05 19:01   ` Keith Seitz
  2018-07-08 16:05     ` Simon Marchi
  2018-07-08 16:26     ` Tom Tromey
  0 siblings, 2 replies; 129+ messages in thread
From: Keith Seitz @ 2018-07-05 19:01 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Hi,

I have just one trivial request:

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index c3961254da..d0dfa4cd02 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -1288,7 +1286,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
>        && pending_blocks == NULL
>        && file_symbols == NULL
>        && global_symbols == NULL
> -      && have_line_numbers == 0
> +      && buildsym_compunit->m_have_line_numbers == 0
>        && buildsym_compunit->m_pending_macros == NULL
>        && global_using_directives == NULL)
>      {

Since m_have_line_numbers was declared bool, I prefer (and I think most do?) that the comparison use `false' instead.

Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 10/42] Move some code from buildsym to stabsread
  2018-05-23  4:59 ` [RFA 10/42] Move some code from buildsym to stabsread Tom Tromey
@ 2018-07-05 19:16   ` Keith Seitz
  2018-07-08 16:35     ` Simon Marchi
  2018-07-08 16:37     ` Tom Tromey
  0 siblings, 2 replies; 129+ messages in thread
From: Keith Seitz @ 2018-07-05 19:16 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

I just have one comment:

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/stabsread.c b/gdb/stabsread.c
> index 4cfefaa3e0..13663106dc 100644
> --- a/gdb/stabsread.c
> +++ b/gdb/stabsread.c
> @@ -44,6 +44,7 @@
>  #include "target-float.h"
>  #include "cp-abi.h"
>  #include "cp-support.h"
> +#include "bcache.h"
>  #include <ctype.h>
>  
>  /* Ask stabsread.h to define the vars it normally declares `extern'.  */
> @@ -4839,6 +4840,18 @@ find_name_end (const char *name)
>      }
>  }
>  
> +\f
> +
> +/* Compute a small integer hash code for the given name.  */
> +
> +int
> +hashname (const char *name)
> +{
> +  return hash (name, strlen (name)) % HASHSIZE;
> +}
> +
> +\f
> +
>  /* Initializer for this module.  */
>  
>  void

Seems some superfluous newlines got pasted in here?
Please use "See stabsread.h" and move the comment into the header.

Okay, that's actually two comments, but one is so trivial, I didn't count it.

Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 19/42] Move the using directives to buildsym_compunit
  2018-05-23  4:59 ` [RFA 19/42] Move the using directives to buildsym_compunit Tom Tromey
@ 2018-07-05 20:14   ` Keith Seitz
  2018-07-08 16:28     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Keith Seitz @ 2018-07-05 20:14 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Trivial nitpicking time:

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index 5d3d1f2942..4e3ca5e4b1 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -205,6 +205,14 @@ struct buildsym_compunit
>  
>    /* Stack of subfile names.  */
>    std::vector<const char *> m_subfile_stack;
> +
> +  /* "using" directives local to lexical context.  */
> +
> +  struct using_direct *m_local_using_directives = nullptr;
> +
> +  /* global "using" directives.  */
> +
> +  struct using_direct *m_global_using_directives = nullptr;
>  };
>  
>  /* The work-in-progress of the compunit we are building.
Since you're modifying these lines, could you update the comments (e.g., capitalize "Global") and remove the newline between the comment and decl?

Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 21/42] Move the context stack to buildsym_compunit
  2018-05-23  4:59 ` [RFA 21/42] Move the context stack to buildsym_compunit Tom Tromey
@ 2018-07-06 17:30   ` Keith Seitz
  2018-07-15 18:09     ` Tom Tromey
       [not found]   ` <93a9597f-e7ff-e8ff-e873-9cee5b84d7cc@simark.ca>
  1 sibling, 1 reply; 129+ messages in thread
From: Keith Seitz @ 2018-07-06 17:30 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index 4e3ca5e4b1..54592b7795 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -213,6 +213,9 @@ struct buildsym_compunit
>    /* global "using" directives.  */
>  
>    struct using_direct *m_global_using_directives = nullptr;
> +
> +  std::vector<struct context_stack> m_context_stack;
> +  struct context_stack m_popped_context {};
>  };

Explanatory comments -- especially for m_popped_context? Had I not read the commit log, I would not have (as easily) understood why this was necessary.

>  /* The work-in-progress of the compunit we are building.
> @@ -1583,12 +1579,9 @@ augment_type_symtab (void)
>    struct compunit_symtab *cust = buildsym_compunit->compunit_symtab;
>    const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
>  
> -  if (context_stack_depth > 0)
> -    {
> -      complaint (&symfile_complaints,
> -		 _("Context stack not empty in augment_type_symtab"));
> -      context_stack_depth = 0;
> -    }
> +  if (!buildsym_compunit->m_context_stack.empty ())
> +    complaint (&symfile_complaints,
> +	       _("Context stack not empty in augment_type_symtab"));
>    if (pending_blocks != NULL)
>      complaint (&symfile_complaints, _("Blocks in a type symtab"));
>    if (buildsym_compunit->m_pending_macros != NULL)

Warning: This patch (and one or two others) need rebasing. symfile_complaints was removed in May.

> @@ -1745,6 +1736,35 @@ get_global_using_directives ()
>    return &buildsym_compunit->m_global_using_directives;
>  }
>  
> +/* See buildsym.h.  */
> +
> +bool
> +outermost_context_p ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  return buildsym_compunit->m_context_stack.empty ();
> +}
> +
> +/* See buildsym.h.  */
> +
> +struct context_stack *
> +get_current_context_stack ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  if (buildsym_compunit->m_context_stack.empty ())
> +    return nullptr;
> +  return &buildsym_compunit->m_context_stack.back ();
> +}
> +
> +/* See buildsym.h.  */
> +
> +int
> +get_context_stack_depth ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  return buildsym_compunit->m_context_stack.size ();
> +}
> +

I can't help but think these function names, which could appear in several source files, seem a little vague or collision-prone (conceptually)... Would it be worth it for these (and perhaps all similar buildsym.h get_* functions) to be namespaced or further prefixed, e.g., buildsym_[get_]current_context_stack or buildsym::get_current_context_stack? I'm not going to suggest [Dare I say, "require?"] any changes -- I'm just wondering "aloud."

>  /* Initialize anything that needs initializing when starting to read a
> diff --git a/gdb/buildsym.h b/gdb/buildsym.h
> index efb35c907b..fe158d183c 100644
> --- a/gdb/buildsym.h
> +++ b/gdb/buildsym.h
> @@ -270,6 +261,19 @@ extern void set_local_using_directives (struct using_direct *new_local);
>  
>  extern struct using_direct **get_global_using_directives ();
>  
> +/* Non-zero if the context stack is empty.  */
      ^^^^^^^^
> +
> +extern bool outermost_context_p ();

Since this (now) returns bool, please use boolean in comment. [I realize that's a cut-n-paste-o.]

> +
> +/* Return the top of the context stack, or nullptr if there is
> +   entry.  */
> +
> +extern struct context_stack *get_current_context_stack ();
> +

Typo in "if there is entry."

> +/* Return the context stack depth.  */
> +
> +extern int get_context_stack_depth ();
> +
>  #undef EXTERN
>  
>  #endif /* defined (BUILDSYM_H) */

Thank you!

[Just a gentle reminder: IANAM.]

Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 28/42] Set list_in_scope later in DWARF reader
  2018-05-23  4:59 ` [RFA 28/42] Set list_in_scope later in DWARF reader Tom Tromey
@ 2018-07-06 18:11   ` Keith Seitz
  2018-07-10  3:23     ` Simon Marchi
  2018-07-15 17:55     ` Tom Tromey
  0 siblings, 2 replies; 129+ messages in thread
From: Keith Seitz @ 2018-07-06 18:11 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 3cc15ab645..f7cca01445 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -21138,6 +21134,8 @@ dwarf2_start_symtab (struct dwarf2_cu *cu,
>      = start_symtab (cu->per_cu->dwarf2_per_objfile->objfile, name, comp_dir,
>  		    low_pc, cu->language);
>  
> +  cu->list_in_scope = get_file_symbols ();
> +
>    record_debugformat ("DWARF 2");
>    record_producer (cu->producer);
>  
> 

Warning: `get_file_symbols' is undefined until the next patch.

Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 29/42] Move the symbol lists to buildsym_compunit
  2018-05-23  4:59 ` [RFA 29/42] Move the symbol lists to buildsym_compunit Tom Tromey
@ 2018-07-06 18:35   ` Keith Seitz
  2018-07-12  4:45     ` Tom Tromey
  2018-07-10  3:38   ` Simon Marchi
  1 sibling, 1 reply; 129+ messages in thread
From: Keith Seitz @ 2018-07-06 18:35 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index 40176298a2..0e21cfd83a 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -251,6 +265,20 @@ struct buildsym_compunit
>       are just waiting to be built into a blockvector when finalizing the
>       associated symtab.  */
>    struct pending_block *m_pending_blocks = nullptr;
> +
> +  /* Here are the three lists that symbols are put on.  */
> +
> +  /* static at top level, and types */
> +
> +  struct pending *m_file_symbols = nullptr;
> +
> +  /* global functions and variables */
> +
> +  struct pending *m_global_symbols = nullptr;
> +
> +  /* everything local to lexical context */
> +
> +  struct pending *m_local_symbols = nullptr;
>  };
>  
>  /* The work-in-progress of the compunit we are building.

I know these are all cut-n-paste descriptions, but could you please update them (incomplete sentences/grammar)?

[IANAM]

Thank you,
Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 34/42] Add many methods to buildsym_compunit
  2018-05-23  6:16 ` [RFA 34/42] Add many methods to buildsym_compunit Tom Tromey
@ 2018-07-06 19:16   ` Keith Seitz
  2018-07-08 16:39     ` Tom Tromey
  2018-07-10  4:08   ` Simon Marchi
  2018-07-10  4:08   ` Simon Marchi
  2 siblings, 1 reply; 129+ messages in thread
From: Keith Seitz @ 2018-07-06 19:16 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

[Note: this patch requires rebasing (re: symfile_complaints)]

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index c965776d82..b9be6dd61a 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -143,6 +169,11 @@ struct buildsym_compunit
>      m_last_source_file.reset (new_name);
>    }
>  
> +  const char *get_last_source_file ()
> +  {
> +    return m_last_source_file.get ();
> +  }
> +
>    struct macro_table *get_macro_table ()
>    {
>      if (m_pending_macros == nullptr)
> @@ -167,6 +198,136 @@ struct buildsym_compunit
>      m_pending_blocks = nullptr;
>    }
>  
> +  struct block *finish_block (struct symbol *symbol,
> +			      struct pending_block *old_blocks,
> +			      const struct dynamic_prop *static_link,
> +			      CORE_ADDR start, CORE_ADDR end);
> +
> +  void record_block_range (struct block *block,
> +			   CORE_ADDR start, CORE_ADDR end_inclusive);
> +
> +  void start_subfile (const char *name);
> +
> +  void patch_subfile_names (struct subfile *subfile, const char *name);
> +
> +  void push_subfile ();
> +
> +  const char *pop_subfile ();
> +
> +  void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
> +
> +  struct compunit_symtab *get_compunit_symtab ()
> +  {
> +    return compunit_symtab;
> +  }
> +
> +  void set_last_source_start_addr (CORE_ADDR addr)
> +  {
> +    m_last_source_start_addr = addr;
> +  }
> +
> +  CORE_ADDR get_last_source_start_addr ()
> +  {
> +    return m_last_source_start_addr;
> +  }
> +
> +  struct using_direct **get_local_using_directives ()
> +  {
> +    return &m_local_using_directives;
> +  }
> +
> +  void set_local_using_directives (struct using_direct *new_local)
> +  {
> +    m_local_using_directives = new_local;
> +  }
> +
> +  struct using_direct **get_global_using_directives ()
> +  {
> +    return &m_global_using_directives;
> +  }
> +
> +  bool outermost_context_p () const
> +  {
> +    return m_context_stack.empty ();
> +  }
> +
> +  struct context_stack *get_current_context_stack ()
> +  {
> +    if (m_context_stack.empty ())
> +      return nullptr;
> +    return &m_context_stack.back ();
> +  }
> +
> +  int get_context_stack_depth () const
> +  {
> +    return m_context_stack.size ();
> +  }
> +
> +  struct subfile *get_current_subfile ()
> +  {
> +    return m_current_subfile;
> +  }
> +
> +  struct pending **get_local_symbols ()
> +  {
> +    return &m_local_symbols;
> +  }
> +
> +  struct pending **get_file_symbols ()
> +  {
> +    return &m_file_symbols;
> +  }
> +
> +  struct pending **get_global_symbols ()
> +  {
> +    return &m_global_symbols;
> +  }
> +
> +  void record_debugformat (const char *format)
> +  {
> +    debugformat = format;
> +  }
> +
> +  void record_producer (const char *producer)
> +  {
> +    this->producer = producer;
> +  }
> +
> +  struct context_stack *push_context (int desc, CORE_ADDR valu);
> +
> +  struct context_stack *pop_context ();
> +
> +  struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
> +					     int expandable, int required);
> +
> +  struct compunit_symtab *end_symtab_from_static_block
> +      (struct block *static_block, int section, int expandable);
> +
> +  struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
> +
> +  struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
> +						 int section);
> +
> +  void augment_type_symtab ();
> +
> +private:
> +
> +  void record_pending_block (struct block *block, struct pending_block *opblock);
> +
> +  struct block *finish_block_internal (struct symbol *symbol,
> +				       struct pending **listhead,
> +				       struct pending_block *old_blocks,
> +				       const struct dynamic_prop *static_link,
> +				       CORE_ADDR start, CORE_ADDR end,
> +				       int is_global, int expandable);
> +
> +  struct blockvector *make_blockvector ();
> +
> +  void watch_main_source_file_lossage ();
> +
> +  struct compunit_symtab *end_symtab_with_blockvector
> +      (struct block *static_block, int section, int expandable);
> +
>    /* The objfile we're reading debug info from.  */
>    struct objfile *objfile;
[snip]
> @@ -1733,5 +1852,120 @@ struct pending **
>  get_global_symbols ()
>  {
>    gdb_assert (buildsym_compunit != nullptr);
> -  return &buildsym_compunit->m_global_symbols;
> +  return buildsym_compunit->get_global_symbols ();
> +}
> +
> +void
> +start_subfile (const char *name)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  buildsym_compunit->start_subfile (name);
> +}
> +
> +void
> +patch_subfile_names (struct subfile *subfile, const char *name)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  buildsym_compunit->patch_subfile_names (subfile, name);
> +}
> +
> +void
> +push_subfile ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  buildsym_compunit->push_subfile ();
> +}
> +
> +const char *
> +pop_subfile ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  return buildsym_compunit->pop_subfile ();
> +}
> +
> +struct block *
> +end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  return buildsym_compunit->end_symtab_get_static_block (end_addr, expandable,
> +							 required);
> +}
> +
> +struct compunit_symtab *
> +end_symtab_from_static_block (struct block *static_block,
> +			      int section, int expandable)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  struct compunit_symtab *result
> +    = buildsym_compunit->end_symtab_from_static_block (static_block,
> +						       section, expandable);
> +  reset_symtab_globals ();
> +  return result;
> +}
> +
> +struct compunit_symtab *
> +end_symtab (CORE_ADDR end_addr, int section)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  struct compunit_symtab *result
> +    = buildsym_compunit->end_symtab (end_addr, section);
> +  reset_symtab_globals ();
> +  return result;
> +}
> +
> +struct compunit_symtab *
> +end_expandable_symtab (CORE_ADDR end_addr, int section)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  struct compunit_symtab *result
> +    = buildsym_compunit->end_expandable_symtab (end_addr, section);
> +  reset_symtab_globals ();
> +  return result;
> +}
> +
> +void
> +augment_type_symtab ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  buildsym_compunit->augment_type_symtab ();
> +  reset_symtab_globals ();
> +}
> +
> +struct context_stack *
> +push_context (int desc, CORE_ADDR valu)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  return buildsym_compunit->push_context (desc, valu);
> +}
> +
> +struct context_stack *
> +pop_context ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  return buildsym_compunit->pop_context ();
> +}
> +
> +struct block *
> +finish_block (struct symbol *symbol, struct pending_block *old_blocks,
> +	      const struct dynamic_prop *static_link,
> +	      CORE_ADDR start, CORE_ADDR end)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  return buildsym_compunit->finish_block (symbol, old_blocks, static_link,
> +					  start, end);
> +}
> +
> +void
> +record_block_range (struct block *block, CORE_ADDR start,
> +		    CORE_ADDR end_inclusive)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  buildsym_compunit->record_block_range (block, start, end_inclusive);
> +}
> +
> +void
> +record_line (struct subfile *subfile, int line, CORE_ADDR pc)
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  buildsym_compunit->record_line (subfile, line, pc);
>  }
> 

Yikes. <rhetorical>Did we really have that many undocumented functions?</rhetorical>

Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 39/42] Parameterize cp_scan_for_anonymous_namespaces
  2018-05-23  6:16 ` [RFA 39/42] Parameterize cp_scan_for_anonymous_namespaces Tom Tromey
@ 2018-07-06 19:23   ` Keith Seitz
  2018-07-08 16:40     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Keith Seitz @ 2018-07-06 19:23 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index 3e3170f0ee..d9a0e02653 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -1634,3 +1634,10 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc)
>    gdb_assert (buildsym_compunit != nullptr);
>    buildsym_compunit->record_line (subfile, line, pc);
>  }
> +
> +struct buildsym_compunit *
> +get_buildsym_compunit ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  return buildsym_compunit;
> +}

Missing "See legacy-buildsym.h" comment.

[IANAM]

Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 40/42] Convert the DWARF reader to new-style buildysm
  2018-05-23  6:16 ` [RFA 40/42] Convert the DWARF reader to new-style buildysm Tom Tromey
@ 2018-07-06 20:10   ` Keith Seitz
  2018-07-10  4:36   ` Simon Marchi
  1 sibling, 0 replies; 129+ messages in thread
From: Keith Seitz @ 2018-07-06 20:10 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> This converts the DWARF reader to use the new-style buildsym API.  A
> new buildsym_compunit is created for each CU and is used to construct
> the symbol table.  In some cases the CU must be passed to functions
> which previously did not accept it.  FWIW I tend to think that most
> methods in the DWARF reader ought to be methods on the dwarf2_cu
> object.

That's a really nice improvement!

IANAM, but I've now peeked at every patch in this series and have nothing but the minor nits to offer along the way.

Well done,
Keith

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 01/42] Use new and delete for buildsym_compunit
  2018-07-05 18:50   ` Keith Seitz
@ 2018-07-07  2:31     ` Simon Marchi
  2018-07-08 16:25     ` Tom Tromey
  1 sibling, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-07  2:31 UTC (permalink / raw)
  To: Keith Seitz, Tom Tromey, gdb-patches

On 2018-07-05 02:49 PM, Keith Seitz wrote:
> Hi, Tom,
> 
> I've got one general question:
> 
> On 05/22/2018 09:58 PM, Tom Tromey wrote:
>> This changes buildsym_compunit to use new and delete.
>>
>> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
>> index 5d38cb250f..9863e4ea1e 100644
>> --- a/gdb/buildsym.c
>> +++ b/gdb/buildsym.c
>> @@ -107,24 +136,24 @@ struct buildsym_compunit
>>       Files are added to the front of the list.
>>       This is important mostly for the language determination hacks we use,
>>       which iterate over previously added files.  */
>> -  struct subfile *subfiles;
>> +  struct subfile *subfiles = nullptr;
>>  
>>    /* The subfile of the main source file.  */
>> -  struct subfile *main_subfile;
>> +  struct subfile *main_subfile = nullptr;
>>  
>>    /* E.g., DW_AT_comp_dir if DWARF.  Space for this is malloc'd.  */
>>    char *comp_dir;
>>  
>>    /* Space for this is not malloc'd, and is assumed to have at least
>>       the same lifetime as objfile.  */
>> -  const char *producer;
>> +  const char *producer = nullptr;
>>  
>>    /* Space for this is not malloc'd, and is assumed to have at least
>>       the same lifetime as objfile.  */
>> -  const char *debugformat;
>> +  const char *debugformat = nullptr;
>>  
>>    /* The compunit we are building.  */
>> -  struct compunit_symtab *compunit_symtab;
>> +  struct compunit_symtab *compunit_symtab = nullptr;
>>  
>>    /* Language of this compunit_symtab.  */
>>    enum language language;
> 
> By the end of the series, this struct declaration is moved to buildsym.h and a bunch of new, private data is added. All those data members are named "m_XYZ" whereas the above variable names are never receive the "m_" treatment.
> 
> Since these variables will later become private, should they not also (some time) be renamed?
> [I think this should/could be a follow-on patch -- no changes needed here.]

In any case, this patch on its own LGTM, since the fields are still public.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 02/42] Change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr
  2018-05-23  4:59 ` [RFA 02/42] Change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr Tom Tromey
@ 2018-07-07  2:34   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-07  2:34 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr.
> This is just a small cleanup to remove some manual memory management.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 04/42] Move last_source file to buildsym_compunit
  2018-05-23  4:59 ` [RFA 04/42] Move last_source file to buildsym_compunit Tom Tromey
@ 2018-07-07  3:51   ` Simon Marchi
  2018-07-08 16:33     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-07  3:51 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> @@ -140,6 +147,12 @@ struct buildsym_compunit
>    /* The subfile of the main source file.  */
>    struct subfile *main_subfile = nullptr;
>  
> +  /* Name of source file whose symbol data we are now processing.  This
> +     comes from a symbol of type N_SO for stabs.  For Dwarf it comes

I think it's spelled DWARF (all caps)?

> +     from the DW_AT_name attribute of a DW_TAG_compile_unit DIE.  */
> +
> +  gdb::unique_xmalloc_ptr<char> m_last_source_file;

Nit: remove the empty line between the comment and the field.

Should this new field be private?

Otherwise, LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 03/42] Add assert in prepare_for_building
  2018-05-23  4:59 ` [RFA 03/42] Add assert in prepare_for_building Tom Tromey
@ 2018-07-07 14:06   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-07 14:06 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This adds an assertion in prepare_for_building.  This was useful for
> verifying whether some subsequent changes were valid.
> 
> gdb/ChangeLog
> 2018-05-22  Tom Tromey  <tom@tromey.com>
> 
> 	* buildsym.c (prepare_for_building): Add assert.
> ---
>  gdb/ChangeLog  | 4 ++++
>  gdb/buildsym.c | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index b747a082b5..9e0c39a4a4 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -1025,6 +1025,7 @@ prepare_for_building (const char *name, CORE_ADDR start_addr)
>    gdb_assert (pending_macros == NULL);
>    gdb_assert (pending_addrmap == NULL);
>    gdb_assert (current_subfile == NULL);
> +  gdb_assert (buildsym_compunit == nullptr);
>  }
>  
>  /* Start a new symtab for a new source file in OBJFILE.  Called, for example,
> 

[I failed to reply-all, so I am resending this]

The code paths in buildsym are not very obvious, so it's hard to
verify that this will always be true, but on the surface it makes sense.
Given that it survived your testing, it LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 05/42] Move pending_macros to buildsym_compunit
  2018-05-23  4:59 ` [RFA 05/42] Move pending_macros " Tom Tromey
@ 2018-07-07 15:41   ` Simon Marchi
  2018-07-08 16:35     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-07 15:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This moves the pending_macros global into buildsym_compunit.

LGTM.  As in the other patch, I would like it if the new fields
were private though.

The only access of m_pending_macros outside the class is to check if
the macro table is instantiated.  So it could be replaced with this
method:

  bool has_macro_table () const
  { return m_pending_macros != nullptr; }

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 06/42] Move have_line_numbers to buildsym_compunit
  2018-07-05 19:01   ` Keith Seitz
@ 2018-07-08 16:05     ` Simon Marchi
  2018-07-08 16:26     ` Tom Tromey
  1 sibling, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:05 UTC (permalink / raw)
  To: Keith Seitz, Tom Tromey, gdb-patches

On 2018-07-05 03:01 PM, Keith Seitz wrote:
> Hi,
> 
> I have just one trivial request:
> 
> On 05/22/2018 09:58 PM, Tom Tromey wrote:
>> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
>> index c3961254da..d0dfa4cd02 100644
>> --- a/gdb/buildsym.c
>> +++ b/gdb/buildsym.c
>> @@ -1288,7 +1286,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
>>        && pending_blocks == NULL
>>        && file_symbols == NULL
>>        && global_symbols == NULL
>> -      && have_line_numbers == 0
>> +      && buildsym_compunit->m_have_line_numbers == 0
>>        && buildsym_compunit->m_pending_macros == NULL
>>        && global_using_directives == NULL)
>>      {
> 
> Since m_have_line_numbers was declared bool, I prefer (and I think most do?) that the comparison use `false' instead.
> 
> Keith

Right, or even !buildsym_compunit->m_have_line_numbers.  LGTM either way.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 07/42] Move last_source_start_addr to buildsym_compunit
  2018-05-23  4:59 ` [RFA 07/42] Move last_source_start_addr to buildsym_compunit Tom Tromey
@ 2018-07-08 16:10   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:10 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This moves the global last_source_start_addr into buildsym_compunit,
> adding some accessors as well.

LGTM, though same comment as earlier, where I would prefer the m_
member to be private.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 08/42] Move processing_acc_compilation to dbxread.c
  2018-05-23  4:59 ` [RFA 08/42] Move processing_acc_compilation to dbxread.c Tom Tromey
@ 2018-07-08 16:15   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:15 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> processing_acc_compilation is only used in dbxread.c, so move it
> there.

LGTM.

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 09/42] Make context_stack_size static in buildsym.c
  2018-05-23  4:59 ` [RFA 09/42] Make context_stack_size static in buildsym.c Tom Tromey
@ 2018-07-08 16:16   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:16 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> context_stack_size is declared in buildsym.h, but only used in
> buildsym.c.  This makes it static in buildsym.c.

LGTM.

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 01/42] Use new and delete for buildsym_compunit
  2018-07-05 18:50   ` Keith Seitz
  2018-07-07  2:31     ` Simon Marchi
@ 2018-07-08 16:25     ` Tom Tromey
  1 sibling, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:25 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> I've got one general question:

Keith> Since these variables will later become private, should they not also (some time) be renamed?
Keith> [I think this should/could be a follow-on patch -- no changes needed here.]

Keith> PS:

[...]

Thanks for the patch :)
I wrote a ChangeLog entry & a description and tacked it on to the end of
the series.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 06/42] Move have_line_numbers to buildsym_compunit
  2018-07-05 19:01   ` Keith Seitz
  2018-07-08 16:05     ` Simon Marchi
@ 2018-07-08 16:26     ` Tom Tromey
  1 sibling, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:26 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

>> -      && have_line_numbers == 0
>> +      && buildsym_compunit->m_have_line_numbers == 0

Keith> Since m_have_line_numbers was declared bool, I prefer (and I
Keith> think most do?) that the comparison use `false' instead.

I changed it to just !have_line_numbers.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 19/42] Move the using directives to buildsym_compunit
  2018-07-05 20:14   ` Keith Seitz
@ 2018-07-08 16:28     ` Tom Tromey
  2018-07-08 17:08       ` Simon Marchi
  0 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:28 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> Since you're modifying these lines, could you update the comments
Keith> (e.g., capitalize "Global") and remove the newline between the
Keith> comment and decl?

I did this.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 04/42] Move last_source file to buildsym_compunit
  2018-07-07  3:51   ` Simon Marchi
@ 2018-07-08 16:33     ` Tom Tromey
  2018-07-08 16:37       ` Simon Marchi
  0 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:33 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> @@ -140,6 +147,12 @@ struct buildsym_compunit
>> /* The subfile of the main source file.  */
>> struct subfile *main_subfile = nullptr;
>> 
>> +  /* Name of source file whose symbol data we are now processing.  This
>> +     comes from a symbol of type N_SO for stabs.  For Dwarf it comes

Simon> I think it's spelled DWARF (all caps)?

Yeah, I just moved the old comment; but I've updated it now.

>> +     from the DW_AT_name attribute of a DW_TAG_compile_unit DIE.  */
>> +
>> +  gdb::unique_xmalloc_ptr<char> m_last_source_file;

Simon> Nit: remove the empty line between the comment and the field.

Done.

Simon> Should this new field be private?

All the data members are private by the end of the series, but I didn't
generally try to do that at each step along the way.  This is one of
those compromises I mentioned in the cover letter -- where a bigger
reordering of the series might have yielded a prettier series, but
didn't seem worth the effort.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 05/42] Move pending_macros to buildsym_compunit
  2018-07-07 15:41   ` Simon Marchi
@ 2018-07-08 16:35     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:35 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> This moves the pending_macros global into buildsym_compunit.

Simon> LGTM.  As in the other patch, I would like it if the new fields
Simon> were private though.

Simon> The only access of m_pending_macros outside the class is to check if
Simon> the macro table is instantiated.  So it could be replaced with this
Simon> method:

Simon>   bool has_macro_table () const
Simon>   { return m_pending_macros != nullptr; }

In the end the members are all private, and nothing outside the class
refers to this member directly.  I didn't look to see where this
reference occurred at this point in the series, but maybe
augment_type_symtab, which ends up as a method of buildsym_compunit?
Anyway I think the final result should be to your liking.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 10/42] Move some code from buildsym to stabsread
  2018-07-05 19:16   ` Keith Seitz
@ 2018-07-08 16:35     ` Simon Marchi
  2018-07-08 16:59       ` Tom Tromey
  2018-07-08 16:37     ` Tom Tromey
  1 sibling, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:35 UTC (permalink / raw)
  To: Keith Seitz, Tom Tromey, gdb-patches

On 2018-07-05 03:16 PM, Keith Seitz wrote:
> I just have one comment:
> 
> On 05/22/2018 09:58 PM, Tom Tromey wrote:
>> diff --git a/gdb/stabsread.c b/gdb/stabsread.c
>> index 4cfefaa3e0..13663106dc 100644
>> --- a/gdb/stabsread.c
>> +++ b/gdb/stabsread.c
>> @@ -44,6 +44,7 @@
>>  #include "target-float.h"
>>  #include "cp-abi.h"
>>  #include "cp-support.h"
>> +#include "bcache.h"
>>  #include <ctype.h>
>>  
>>  /* Ask stabsread.h to define the vars it normally declares `extern'.  */
>> @@ -4839,6 +4840,18 @@ find_name_end (const char *name)
>>      }
>>  }
>>  
>> +\f
>> +
>> +/* Compute a small integer hash code for the given name.  */
>> +
>> +int
>> +hashname (const char *name)
>> +{
>> +  return hash (name, strlen (name)) % HASHSIZE;
>> +}
>> +
>> +\f
>> +
>>  /* Initializer for this module.  */
>>  
>>  void
> 
> Seems some superfluous newlines got pasted in here?

The newline in the middle is actually a form feed character, as recommended in the
GNU coding standards [1]:

"Please use formfeed characters (control-L) to divide the program into pages at logical
places (but not within a function). It does not matter just how long the pages are,
since they do not have to fit on a printed page. The formfeeds should appear alone on
lines by themselves."

I'd be really curious to know if anybody cares about them today.  I know in some
editors you can jump from on to the other.  In my editor, they just appear as the
little "special character" box with the ascii/unicode in it.

[1] https://www.gnu.org/prep/standards/html_node/Formatting.html

> Please use "See stabsread.h" and move the comment into the header.
> 
> Okay, that's actually two comments, but one is so trivial, I didn't count it.
> 
> Keith
> 

LGTM with Keith's comment about the comment addressed.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 04/42] Move last_source file to buildsym_compunit
  2018-07-08 16:33     ` Tom Tromey
@ 2018-07-08 16:37       ` Simon Marchi
  2018-07-08 16:52         ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2018-07-08 12:33 PM, Tom Tromey wrote:
> All the data members are private by the end of the series, but I didn't
> generally try to do that at each step along the way.  This is one of
> those compromises I mentioned in the cover letter -- where a bigger
> reordering of the series might have yielded a prettier series, but
> didn't seem worth the effort.

Ok, no problem then.  You can ignore other similar comments I've already sent.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 10/42] Move some code from buildsym to stabsread
  2018-07-05 19:16   ` Keith Seitz
  2018-07-08 16:35     ` Simon Marchi
@ 2018-07-08 16:37     ` Tom Tromey
  1 sibling, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:37 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> Seems some superfluous newlines got pasted in here?

I usually put lines around the ^Ls, but it doesn't matter to me so I
removed them.

Keith> Please use "See stabsread.h" and move the comment into the header.

I did this.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 34/42] Add many methods to buildsym_compunit
  2018-07-06 19:16   ` Keith Seitz
@ 2018-07-08 16:39     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:39 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> [Note: this patch requires rebasing (re: symfile_complaints)]

Yeah, a few did; but no big deal.

Keith> Yikes. <rhetorical>Did we really have that many undocumented functions?</rhetorical>

Try looking at value.h sometime ;)

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 39/42] Parameterize cp_scan_for_anonymous_namespaces
  2018-07-06 19:23   ` Keith Seitz
@ 2018-07-08 16:40     ` Tom Tromey
  2018-07-10  4:25       ` Simon Marchi
  0 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:40 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> On 05/22/2018 09:58 PM, Tom Tromey wrote:
>> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
>> index 3e3170f0ee..d9a0e02653 100644
>> --- a/gdb/buildsym.c
>> +++ b/gdb/buildsym.c
>> @@ -1634,3 +1634,10 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc)
>> gdb_assert (buildsym_compunit != nullptr);
buildsym_compunit-> record_line (subfile, line, pc);
>> }
>> +
>> +struct buildsym_compunit *
>> +get_buildsym_compunit ()
>> +{
>> +  gdb_assert (buildsym_compunit != nullptr);
>> +  return buildsym_compunit;
>> +}

Keith> Missing "See legacy-buildsym.h" comment.

Thanks, I made this change.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 11/42] Move processing_gcc to stabsread
  2018-05-23  6:16 ` [RFA 11/42] Move processing_gcc to stabsread Tom Tromey
@ 2018-07-08 16:46   ` Simon Marchi
  2018-07-08 16:56     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:46 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> processing_gcc is also only used by stabsread -- it is set by the
> DWARF reader, but this turns out not to be needed.  So, this patch
> moves processing_gcc and removes the assignment from the DWARF reader.

Any idea if the assignment of processing_gcc_compilation in go32-nat.c is
useful?  In looks very strange to me to set that in nat code rather than
in symbol-reading code...

Either way, it LGTM, I am fine if you leave it there to stay on the safe side,
since I suppose you couldn't test that change easily.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 12/42] Move within_function to stabsread
  2018-05-23  4:59 ` [RFA 12/42] Move within_function to stabsread Tom Tromey
@ 2018-07-08 16:49   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:49 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> The global within_function is only used by a few symbol readers.  This
> patch moves the global out of buildsym and into stabsread, which
> seemed like a better fit.  It also arranges for the existing readers
> to clear the global at the appropriate time.

LGTM.

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 13/42] Remove buildsym_new_init
  2018-05-23  4:59 ` [RFA 13/42] Remove buildsym_new_init Tom Tromey
@ 2018-07-08 16:51   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:51 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> buildsym_new_init is just an alias for buildsym_init.  This removes
> it.  In the long run buildsym_init will also go away; this patch just
> helps make things a bit clearer in the meantime.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 04/42] Move last_source file to buildsym_compunit
  2018-07-08 16:37       ` Simon Marchi
@ 2018-07-08 16:52         ` Tom Tromey
  2018-07-08 17:01           ` Simon Marchi
  0 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:52 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2018-07-08 12:33 PM, Tom Tromey wrote:
>> All the data members are private by the end of the series, but I didn't
>> generally try to do that at each step along the way.  This is one of
>> those compromises I mentioned in the cover letter -- where a bigger
>> reordering of the series might have yielded a prettier series, but
>> didn't seem worth the effort.

Simon> Ok, no problem then.  You can ignore other similar comments I've
Simon> already sent.

I already sent one other reply but you can likewise ignore that :)

This series is a bit unwieldy.  And I should probably have mentioned
earlier (before Keith went to the effort of applying it...) that it is
in my github as submit/buildsym-fixups, in case you wanted to check it
out or something.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 14/42] Move scan_file_globals declaration to stabsread.h
  2018-05-23  4:59 ` [RFA 14/42] Move scan_file_globals declaration to stabsread.h Tom Tromey
@ 2018-07-08 16:52   ` Simon Marchi
  2018-07-09 23:07     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:52 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> scan_file_globals is defined in stabsread.c, so move its declaration
> to stabsread.h.

LGTM, though can you move the comment to the .h and add the usual "See..."?

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 15/42] Remove merge_symbol_lists
  2018-05-23  4:59 ` [RFA 15/42] Remove merge_symbol_lists Tom Tromey
@ 2018-07-08 16:54   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:54 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> I discovered that merge_symbol_lists is unused, so this removes it.

LGTM.

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 16/42] Use gdb_assert in two places in buildsym.c
  2018-05-23  4:59 ` [RFA 16/42] Use gdb_assert in two places " Tom Tromey
@ 2018-07-08 16:55   ` Simon Marchi
  2018-07-09 23:13     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:55 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This changes buildsym.c to use gdb_assert rather than internal_error
> in a couple of spots.

Just a nit, but I think inverting the condition would be more readable

  gdb_assert (current_subfile != NULL && current_subfile->name != NULL);

LGTM either way.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 11/42] Move processing_gcc to stabsread
  2018-07-08 16:46   ` Simon Marchi
@ 2018-07-08 16:56     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:56 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> processing_gcc is also only used by stabsread -- it is set by the
>> DWARF reader, but this turns out not to be needed.  So, this patch
>> moves processing_gcc and removes the assignment from the DWARF reader.

Simon> Any idea if the assignment of processing_gcc_compilation in go32-nat.c is
Simon> useful?  In looks very strange to me to set that in nat code rather than
Simon> in symbol-reading code...

Simon> Either way, it LGTM, I am fine if you leave it there to stay on the safe side,
Simon> since I suppose you couldn't test that change easily.

Yeah, I have no idea and didn't want to mess with that.

It does seem incorrect to set it there.  Here's the email about that
change:

    https://sourceware.org/ml/gdb-patches/2000-q1/msg00710.html

Not much to go on, and long enough ago that many other parts of gdb
might well have been very different.

Anyway I tend to think that this port in particular can mostly be
approached with benign neglect.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 10/42] Move some code from buildsym to stabsread
  2018-07-08 16:35     ` Simon Marchi
@ 2018-07-08 16:59       ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-08 16:59 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Keith Seitz, Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> The newline in the middle is actually a form feed character, as recommended in the
Simon> GNU coding standards [1]:

Hah, it didn't even occur to me that these wouldn't have shown up, but
that's probably what happened.

Simon> I'd be really curious to know if anybody cares about them today.  I know in some
Simon> editors you can jump from on to the other.  In my editor, they just appear as the
Simon> little "special character" box with the ascii/unicode in it.

I use them as indicators of "this group of functions belongs together",
but I don't actually use the page navigation functions in Emacs.  Also
there's a historical / habitual component to adding them; it's long been
part of the GNU style.

Maybe having more and smaller files would be a better approach to what I
use them for.  Though of course that's not without its costs.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 17/42] Move the subfile stack to buildsym_compunit
  2018-05-23  4:59 ` [RFA 17/42] Move the subfile stack to buildsym_compunit Tom Tromey
@ 2018-07-08 16:59   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 16:59 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This moves the global subfile_stack to be a member of
> buildsym_compunit.  It also change this to be a std::vector, which
> simplifies the code.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 04/42] Move last_source file to buildsym_compunit
  2018-07-08 16:52         ` Tom Tromey
@ 2018-07-08 17:01           ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 17:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2018-07-08 12:52 PM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
> 
> Simon> On 2018-07-08 12:33 PM, Tom Tromey wrote:
>>> All the data members are private by the end of the series, but I didn't
>>> generally try to do that at each step along the way.  This is one of
>>> those compromises I mentioned in the cover letter -- where a bigger
>>> reordering of the series might have yielded a prettier series, but
>>> didn't seem worth the effort.
> 
> Simon> Ok, no problem then.  You can ignore other similar comments I've
> Simon> already sent.
> 
> I already sent one other reply but you can likewise ignore that :)
> 
> This series is a bit unwieldy.  And I should probably have mentioned
> earlier (before Keith went to the effort of applying it...) that it is
> in my github as submit/buildsym-fixups, in case you wanted to check it
> out or something.

It's been mostly fine so far (just one or two trivial merge conflicts), but
thanks for tip anyway.  The patches are good on their own I think, so feel free
to start pushing them as soon as they are approved, so the pendant part of the
series gradually shrinks.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 18/42] Make free_pending_blocks static
  2018-05-23  4:59 ` [RFA 18/42] Make free_pending_blocks static Tom Tromey
@ 2018-07-08 17:04   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 17:04 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> free_pending_blocks can be static because scoped_free_pendings (et al)
> arrange for it to be NULL in the "steady state".  This removes a
> couple of unnecessary calls to free_pending_blocks and changes it to
> be static.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 19/42] Move the using directives to buildsym_compunit
  2018-07-08 16:28     ` Tom Tromey
@ 2018-07-08 17:08       ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 17:08 UTC (permalink / raw)
  To: Tom Tromey, Keith Seitz; +Cc: gdb-patches

On 2018-07-08 12:28 PM, Tom Tromey wrote:
>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
> 
> Keith> Since you're modifying these lines, could you update the comments
> Keith> (e.g., capitalize "Global") and remove the newline between the
> Keith> comment and decl?
> 
> I did this.
> 
> Tom

LGTM with this.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 20/42] Use outermost_context_p in more places
  2018-05-23  4:59 ` [RFA 20/42] Use outermost_context_p in more places Tom Tromey
@ 2018-07-08 17:13   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-08 17:13 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This changes a few explicit checks of context_stack_depth to use
> outermost_context_p instead.  This simplifies some future work.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 14/42] Move scan_file_globals declaration to stabsread.h
  2018-07-08 16:52   ` Simon Marchi
@ 2018-07-09 23:07     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-09 23:07 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> scan_file_globals is defined in stabsread.c, so move its declaration
>> to stabsread.h.

Simon> LGTM, though can you move the comment to the .h and add the usual "See..."?

I did this.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 16/42] Use gdb_assert in two places in buildsym.c
  2018-07-08 16:55   ` Simon Marchi
@ 2018-07-09 23:13     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-09 23:13 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> Just a nit, but I think inverting the condition would be more readable
Simon>   gdb_assert (current_subfile != NULL && current_subfile->name != NULL);
Simon> LGTM either way.

I did this.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 21/42] Move the context stack to buildsym_compunit
       [not found]   ` <93a9597f-e7ff-e8ff-e873-9cee5b84d7cc@simark.ca>
@ 2018-07-10  1:45     ` Simon Marchi
  2018-07-15 18:10       ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  1:45 UTC (permalink / raw)
  To: Tom Tromey, GDB patches

On 2018-07-08 01:49 PM, Simon Marchi wrote:
> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> This moves the context stack globals to be members of
>> buildsym_compunit, changing the type to a std::vector in the process.
>>
>> Note that the context stack works in a somewhat odd way, where callers
>> can pop the stack and expect the returned pointer to remain valid
>> until the next pop.  In the new code we handle this by having a
>> "popped context" object that remains valid in this way.
> 
> Would it work to make pop_context return the context_stack object by value
> instead?
> 
>> @@ -270,6 +261,19 @@ extern void set_local_using_directives (struct using_direct *new_local);
>>  
>>  extern struct using_direct **get_global_using_directives ();
>>  
>> +/* Non-zero if the context stack is empty.  */
>> +
>> +extern bool outermost_context_p ();
> 
> "True" instead of "Non-zero".
> 
> Simon

Damn, failed to reply all again.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 22/42] Move current_subfile to buildsym_compunit
  2018-05-23  4:59 ` [RFA 22/42] Move current_subfile to buildsym_compunit Tom Tromey
@ 2018-07-10  1:52   ` Simon Marchi
  2018-07-12  4:34     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  1:52 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

> @@ -901,8 +902,10 @@ void
>  push_subfile ()
>  {
>    gdb_assert (buildsym_compunit != nullptr);
> -  gdb_assert (! (current_subfile == NULL || current_subfile->name == NULL));
> -  buildsym_compunit->m_subfile_stack.push_back (current_subfile->name);
> +  gdb_assert (! (buildsym_compunit->m_current_subfile == NULL
> +		 || buildsym_compunit->m_current_subfile->name == NULL));

Here, you might as well write two separate asserts.

  gdb_assert (buildsym_compunit->m_current_subfile != NULL);
  gdb_assert (buildsym_compunit->m_current_subfile->name != NULL);

Otherwise, LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 23/42] Move pending addrmap globals to buildsym_compunit
  2018-05-23  4:59 ` [RFA 23/42] Move pending addrmap globals " Tom Tromey
@ 2018-07-10  1:56   ` Simon Marchi
  2018-07-12  4:35     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  1:56 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> @@ -660,15 +656,14 @@ record_block_range (struct block *block,
>       need to record this block in the addrmap.  */
>    if (start != BLOCK_START (block)
>        || end_inclusive + 1 != BLOCK_END (block))
> -    pending_addrmap_interesting = 1;
> +    buildsym_compunit->m_pending_addrmap_interesting = true;
>  
> -  if (! pending_addrmap)
> -    {
> -      obstack_init (&pending_addrmap_obstack);
> -      pending_addrmap = addrmap_create_mutable (&pending_addrmap_obstack);
> -    }
> +  if (! buildsym_compunit->m_pending_addrmap)

Can you please change this to == nullptr?

> +    buildsym_compunit->m_pending_addrmap
> +      = addrmap_create_mutable (&buildsym_compunit->m_pending_addrmap_obstack);
>  
> -  addrmap_set_empty (pending_addrmap, start, end_inclusive, block);
> +  addrmap_set_empty (buildsym_compunit->m_pending_addrmap,
> +		     start, end_inclusive, block);
>  }
>  
>  static struct blockvector *
> @@ -706,9 +701,11 @@ make_blockvector (void)
>  
>    /* If we needed an address map for this symtab, record it in the
>       blockvector.  */
> -  if (pending_addrmap && pending_addrmap_interesting)
> +  if (buildsym_compunit->m_pending_addrmap
> +      && buildsym_compunit->m_pending_addrmap_interesting)

And here != nullptr.

Otherwise, LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 24/42] Move pending_blocks and pending_block_obstack to buildsym_compunit
  2018-05-23  6:16 ` [RFA 24/42] Move pending_blocks and pending_block_obstack to buildsym_compunit Tom Tromey
@ 2018-07-10  2:05   ` Simon Marchi
  2018-07-12  4:39     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  2:05 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> @@ -344,7 +348,6 @@ find_symbol_in_list (struct pending *list, char *name, int length)
>  
>  scoped_free_pendings::scoped_free_pendings ()
>  {
> -  gdb_assert (pending_blocks == nullptr);
>  }

You can remove the constructor (here and in the .h).

Otherwise, LGTM.  The ownership model of the pending blocks is not very clear
to me yet, but I'm sure it will become by the end of the series.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 25/42] Remove the "listhead" argument from finish_block
  2018-05-23  4:59 ` [RFA 25/42] Remove the "listhead" argument from finish_block Tom Tromey
@ 2018-07-10  2:07   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  2:07 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> finish_block is only ever called with "&local_symbols" as the
> "listhead" argument.  So, remove this argument.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 26/42] Remove free_pendings
  2018-05-23  4:59 ` [RFA 26/42] Remove free_pendings Tom Tromey
@ 2018-07-10  2:55   ` Simon Marchi
  2018-07-10  3:16     ` Simon Marchi
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  2:55 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> buildsym.c currently keeps a free list of "struct pending"s.  However,
> this didn't seem necessary to me, and so this patch removes the free
> list.

LGTM.

It looks like this was to avoid some allocations/deallocations, for performance?
Since it's hard to tell if something is worth it performance-wise without data,
I made some quick measurements.  I compiled GDB with optimizations, then loaded
my debug build of GDB in it like this:

 $ for i in 1 2 3; do /usr/bin/time -a -o after ./gdb /home/simark/build/binutils-gdb/gdb/gdb -readnow -batch; done

This is before:

58.66user 5.38system 1:04.47elapsed 99%CPU (0avgtext+0avgdata 2841916maxresident)k
2520inputs+0outputs (1major+679737minor)pagefaults 0swaps
59.24user 5.52system 1:05.07elapsed 99%CPU (0avgtext+0avgdata 2841572maxresident)k
1616inputs+0outputs (4major+679723minor)pagefaults 0swaps
61.50user 5.38system 1:07.36elapsed 99%CPU (0avgtext+0avgdata 2841764maxresident)k
0inputs+0outputs (0major+679732minor)pagefaults 0swaps

This is after:

53.14user 4.91system 0:59.02elapsed 98%CPU (0avgtext+0avgdata 2841824maxresident)k
0inputs+0outputs (0major+679713minor)pagefaults 0swaps
52.70user 4.97system 0:58.49elapsed 98%CPU (0avgtext+0avgdata 2842052maxresident)k
0inputs+0outputs (0major+679747minor)pagefaults 0swaps
54.42user 5.30system 1:01.11elapsed 97%CPU (0avgtext+0avgdata 2841764maxresident)k
0inputs+0outputs (0major+679760minor)pagefaults 0swaps

So, unless I mixed up "before" and "after", it looks like this patch actually
improves the performance of GDB!

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 26/42] Remove free_pendings
  2018-07-10  2:55   ` Simon Marchi
@ 2018-07-10  3:16     ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  3:16 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-07-09 10:55 PM, Simon Marchi wrote:
> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> buildsym.c currently keeps a free list of "struct pending"s.  However,
>> this didn't seem necessary to me, and so this patch removes the free
>> list.
> 
> LGTM.
> 
> It looks like this was to avoid some allocations/deallocations, for performance?
> Since it's hard to tell if something is worth it performance-wise without data,
> I made some quick measurements.  I compiled GDB with optimizations, then loaded
> my debug build of GDB in it like this:
> 
>  $ for i in 1 2 3; do /usr/bin/time -a -o after ./gdb /home/simark/build/binutils-gdb/gdb/gdb -readnow -batch; done
> 
> This is before:
> 
> 58.66user 5.38system 1:04.47elapsed 99%CPU (0avgtext+0avgdata 2841916maxresident)k
> 2520inputs+0outputs (1major+679737minor)pagefaults 0swaps
> 59.24user 5.52system 1:05.07elapsed 99%CPU (0avgtext+0avgdata 2841572maxresident)k
> 1616inputs+0outputs (4major+679723minor)pagefaults 0swaps
> 61.50user 5.38system 1:07.36elapsed 99%CPU (0avgtext+0avgdata 2841764maxresident)k
> 0inputs+0outputs (0major+679732minor)pagefaults 0swaps
> 
> This is after:
> 
> 53.14user 4.91system 0:59.02elapsed 98%CPU (0avgtext+0avgdata 2841824maxresident)k
> 0inputs+0outputs (0major+679713minor)pagefaults 0swaps
> 52.70user 4.97system 0:58.49elapsed 98%CPU (0avgtext+0avgdata 2842052maxresident)k
> 0inputs+0outputs (0major+679747minor)pagefaults 0swaps
> 54.42user 5.30system 1:01.11elapsed 97%CPU (0avgtext+0avgdata 2841764maxresident)k
> 0inputs+0outputs (0major+679760minor)pagefaults 0swaps
> 
> So, unless I mixed up "before" and "after", it looks like this patch actually
> improves the performance of GDB!
> 
> Simon

Ok, now that I re-run it I don't see a difference anymore... not sure what happened.
Still, the patch LGTM :)

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 27/42] Do not look at file symbols when reading psymtabs
  2018-05-23  4:59 ` [RFA 27/42] Do not look at file symbols when reading psymtabs Tom Tromey
@ 2018-07-10  3:19   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  3:19 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> The DWARF reader was setting the list_in_scope member when reading
> partial symbols.  however, this member is only useful when reading
> full symbols.  Future patches will make this assert, so remove these
> unneeded initializations.

Makes sense, LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 28/42] Set list_in_scope later in DWARF reader
  2018-07-06 18:11   ` Keith Seitz
@ 2018-07-10  3:23     ` Simon Marchi
  2018-07-15 17:55     ` Tom Tromey
  1 sibling, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  3:23 UTC (permalink / raw)
  To: Keith Seitz, Tom Tromey, gdb-patches

On 2018-07-06 02:11 PM, Keith Seitz wrote:
> On 05/22/2018 09:58 PM, Tom Tromey wrote:
>> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
>> index 3cc15ab645..f7cca01445 100644
>> --- a/gdb/dwarf2read.c
>> +++ b/gdb/dwarf2read.c
>> @@ -21138,6 +21134,8 @@ dwarf2_start_symtab (struct dwarf2_cu *cu,
>>      = start_symtab (cu->per_cu->dwarf2_per_objfile->objfile, name, comp_dir,
>>  		    low_pc, cu->language);
>>  
>> +  cu->list_in_scope = get_file_symbols ();
>> +
>>    record_debugformat ("DWARF 2");
>>    record_producer (cu->producer);
>>  
>>
> 
> Warning: `get_file_symbols' is undefined until the next patch.
> 
> Keith
> 

Indeed, though the principle sounds good.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 29/42] Move the symbol lists to buildsym_compunit
  2018-05-23  4:59 ` [RFA 29/42] Move the symbol lists to buildsym_compunit Tom Tromey
  2018-07-06 18:35   ` Keith Seitz
@ 2018-07-10  3:38   ` Simon Marchi
  2018-07-15 17:44     ` Tom Tromey
  1 sibling, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  3:38 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> @@ -1551,26 +1556,27 @@ augment_type_symtab (void)
>      complaint (&symfile_complaints,
>  	       _("Line numbers recorded in a type symtab"));
>  
> -  if (file_symbols != NULL)
> +  if (*get_file_symbols () != NULL)
>      {
>        struct block *block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
>  
>        /* First mark any symbols without a specified symtab as belonging
>  	 to the primary symtab.  */
> -      set_missing_symtab (file_symbols, cust);
> +      set_missing_symtab (buildsym_compunit->m_file_symbols, cust);
>  
> -      dict_add_pending (BLOCK_DICT (block), file_symbols);
> +      dict_add_pending (BLOCK_DICT (block), buildsym_compunit->m_file_symbols);
>      }

I find it a bit odd to use get_file_symbols () in the "if" but
buildsym_compunit->m_file_symbols later.  I guess it would make
sense for what will eventually become a method of buildsym_compunit
to access the field directly.

The same occurs at different places, with different fields.

Otherwise, LGTM considering Keith's comments.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 30/42] Remove buildsym_init
  2018-05-23  8:49 ` [RFA 30/42] Remove buildsym_init Tom Tromey
@ 2018-07-10  3:41   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  3:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> Now that buildsym_init does nothing, it can be removed.

Good milestone, LGTM!

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 31/42] Remove a TODO
  2018-05-23  6:16 ` [RFA 31/42] Remove a TODO Tom Tromey
@ 2018-07-10  3:42   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  3:42 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This removes a TODO comment -- the work has been done.

Obviously ok, thanks for this :).

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 32/42] Remove EXTERN from buildsym.h
  2018-05-23  6:16 ` [RFA 32/42] Remove EXTERN from buildsym.h Tom Tromey
@ 2018-07-10  3:44   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  3:44 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> Nothing in buildsym.h relies on the "EXTERN" method of
> declaration/definition, so remove the traces.

LGTM.

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 33/42] Remove parameter from record_pending_block
  2018-05-23  6:16 ` [RFA 33/42] Remove parameter from record_pending_block Tom Tromey
@ 2018-07-10  3:49   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  3:49 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This removes a redundant parameter from record_pending_block.  It also
> moves record_pending_block earlier in the file, so that a forward
> declaration is no longer needed.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 34/42] Add many methods to buildsym_compunit
  2018-05-23  6:16 ` [RFA 34/42] Add many methods to buildsym_compunit Tom Tromey
  2018-07-06 19:16   ` Keith Seitz
@ 2018-07-10  4:08   ` Simon Marchi
  2018-07-12  5:18     ` Tom Tromey
  2018-07-10  4:08   ` Simon Marchi
  2 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:08 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This adds many methods to buildsym_compunit and makes the data members
> private.  Essentially the entire buildsym API is now available as a
> method on buildsym_compunit.  However, standalone functions are still
> provided, as this is what the sybmol readers actually use.
> 
> gdb/ChangeLog
> 2018-05-22  Tom Tromey  <tom@tromey.com>
> 
> 	* buildsym.c (buildsym_compunit::buildsym_compunit): Do more
> 	initialization.
> 	(buildsym_compunit): Add new constructor.
> 	(struct buildsym_compunit) <get_last_source_file, finish_block,
> 	record_block_range, start_subfile, patch_subfile_names,
> 	push_subfile, pop_subfile, record_line, get_compunit_symtab,
> 	set_last_source_start_addr, get_last_source_start_addr,
> 	get_local_using_directives, set_local_using_directives,
> 	get_global_using_directives, outermost_context_p,
> 	get_current_context_stack, get_context_stack_depth,
> 	get_current_subfile, get_local_symbols, get_file_symbols,
> 	get_global_symbols, record_debugformat, record_producer,
> 	push_context, pop_context, end_symtab_get_static_block,
> 	end_symtab_from_static_block, end_symtab, end_expandable_symtab>:
> 	New public methods.
> 	<record_pending_block, finish_block_internal, make_blockvector,
> 	watch_main_source_file_lossage, end_symtab_with_blockvector>: New
> 	private methods.
> 	Update all users.
> ---
>  gdb/ChangeLog  |  22 +++
>  gdb/buildsym.c | 610 +++++++++++++++++++++++++++++++++++++++------------------
>  2 files changed, 444 insertions(+), 188 deletions(-)
> 
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
> index c965776d82..b9be6dd61a 100644
> --- a/gdb/buildsym.c
> +++ b/gdb/buildsym.c
> @@ -103,6 +103,32 @@ struct buildsym_compunit
>        language (language_),
>        m_last_source_start_addr (last_addr)
>    {
> +    /* Allocate the compunit symtab now.  The caller needs it to allocate
> +       non-primary symtabs.  It is also needed by get_macro_table.  */
> +    compunit_symtab = allocate_compunit_symtab (objfile, name);
> +
> +    /* Build the subfile for NAME (the main source file) so that we can record
> +       a pointer to it for later.
> +       IMPORTANT: Do not allocate a struct symtab for NAME here.
> +       It can happen that the debug info provides a different path to NAME than
> +       DIRNAME,NAME.  We cope with this in watch_main_source_file_lossage but
> +       that only works if the main_subfile doesn't have a symtab yet.  */
> +    start_subfile (name);
> +    /* Save this so that we don't have to go looking for it at the end
> +       of the subfiles list.  */
> +    main_subfile = m_current_subfile;
> +  }
> +
> +  buildsym_compunit (struct objfile *objfile_, const char *name,
> +		     const char *comp_dir_, enum language language_,
> +		     CORE_ADDR last_addr, struct compunit_symtab *cust)
> +    : objfile (objfile_),
> +      m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
> +      comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
> +      compunit_symtab (cust),
> +      language (language_),
> +      m_last_source_start_addr (last_addr)
> +  {
>    }

Oh, and could you provide a comment for the second constructor?

Thanks,

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 34/42] Add many methods to buildsym_compunit
  2018-05-23  6:16 ` [RFA 34/42] Add many methods to buildsym_compunit Tom Tromey
  2018-07-06 19:16   ` Keith Seitz
  2018-07-10  4:08   ` Simon Marchi
@ 2018-07-10  4:08   ` Simon Marchi
  2018-07-10  4:12     ` Simon Marchi
  2 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:08 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> +void
> +augment_type_symtab ()
> +{
> +  gdb_assert (buildsym_compunit != nullptr);
> +  buildsym_compunit->augment_type_symtab ();
> +  reset_symtab_globals ();

reset_symtab_globals () is called both here and in
buildsym_compunit->augment_type_symtab, is it intended?

Same thing for end_symtab_from_static_block and the corresponding
method.

Otherwise, LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 35/42] Do not use buildsym.h in some files
  2018-05-23  6:16 ` [RFA 35/42] Do not use buildsym.h in some files Tom Tromey
@ 2018-07-10  4:10   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:10 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> A few files no longer need to include buildsym.h.

I gave a quick glance at those files, I indeed didn't
find anything relying on buildsym.h, so LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 36/42] Remove reset_symtab_globals
  2018-05-23  6:16 ` [RFA 36/42] Remove reset_symtab_globals Tom Tromey
@ 2018-07-10  4:11   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:11 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This patch arranges for the remaining buildsym global --
> buildsym_compunit -- to only be cleared by the wrapper functions, not
> by methods on struct buildsym_compunit.  In the process,
> reset_symtab_globals is removed.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 34/42] Add many methods to buildsym_compunit
  2018-07-10  4:08   ` Simon Marchi
@ 2018-07-10  4:12     ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:12 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-07-10 12:08 AM, Simon Marchi wrote:
> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> +void
>> +augment_type_symtab ()
>> +{
>> +  gdb_assert (buildsym_compunit != nullptr);
>> +  buildsym_compunit->augment_type_symtab ();
>> +  reset_symtab_globals ();
> 
> reset_symtab_globals () is called both here and in
> buildsym_compunit->augment_type_symtab, is it intended?
> 
> Same thing for end_symtab_from_static_block and the corresponding
> method.
> 
> Otherwise, LGTM.
> 
> Simon
> 

I just saw that patch 36 removes it anyway, so never mind.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 37/42] Move struct buildsym_compunit to buildsym.h
  2018-05-23  6:16 ` [RFA 37/42] Move struct buildsym_compunit to buildsym.h Tom Tromey
@ 2018-07-10  4:15   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:15 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This moves struct buildsym_compunit to buildsym.h.  Now that the
> members are private, and it no longer affects any global state in
> buildsym.c, an instance can be used directly for symtab creation.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 38/42] Introduce legacy-buildsym.h
  2018-05-23  7:31 ` [RFA 38/42] Introduce legacy-buildsym.h Tom Tromey
@ 2018-07-10  4:22   ` Simon Marchi
  2018-07-15 18:43     ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:22 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This introduces a new header, legacy-buildsym.h, and changes all the
> symbol readers to use it.  The idea is to put the function-based
> interface, that relies on the buildsym_compunit global, into a
> separate header.  Then when a symbol reader is updated to use the new
> interface, it can simply not include legacy-buildsym.h, so it's easy
> to be sure that the new API is used everywhere.

Cool, good idea.  I have two suggestions:

- Name it buildsym-legacy.h, so that it will be ordered right next to
  buildsym.h in alphabetical lists.
- I would also create buildsym-legacy.c and move all the corresponding
  definitions there, including the buildsym_compunit global variable.
  I haven't actually tried it, maybe it's not possible and you have
  already tried it though.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 39/42] Parameterize cp_scan_for_anonymous_namespaces
  2018-07-08 16:40     ` Tom Tromey
@ 2018-07-10  4:25       ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:25 UTC (permalink / raw)
  To: Tom Tromey, Keith Seitz; +Cc: gdb-patches

On 2018-07-08 12:40 PM, Tom Tromey wrote:
>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
> 
> Keith> On 05/22/2018 09:58 PM, Tom Tromey wrote:
>>> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
>>> index 3e3170f0ee..d9a0e02653 100644
>>> --- a/gdb/buildsym.c
>>> +++ b/gdb/buildsym.c
>>> @@ -1634,3 +1634,10 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc)
>>> gdb_assert (buildsym_compunit != nullptr);
> buildsym_compunit-> record_line (subfile, line, pc);
>>> }
>>> +
>>> +struct buildsym_compunit *
>>> +get_buildsym_compunit ()
>>> +{
>>> +  gdb_assert (buildsym_compunit != nullptr);
>>> +  return buildsym_compunit;
>>> +}
> 
> Keith> Missing "See legacy-buildsym.h" comment.
> 
> Thanks, I made this change.
> 
> Tom
> 

LGTM with this.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 40/42] Convert the DWARF reader to new-style buildysm
  2018-05-23  6:16 ` [RFA 40/42] Convert the DWARF reader to new-style buildysm Tom Tromey
  2018-07-06 20:10   ` Keith Seitz
@ 2018-07-10  4:36   ` Simon Marchi
  2018-07-15 17:38     ` Tom Tromey
  1 sibling, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:36 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Just some nits, otherwise it LGTM.

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> @@ -11129,12 +11139,12 @@ read_namespace_alias (struct die_info *die, struct dwarf2_cu *cu)
>     global only in Ada.  */
>  
>  static struct using_direct **
> -using_directives (enum language language)
> +using_directives (struct dwarf2_cu *cu)

The comment above would need to be updated.

> @@ -11578,7 +11588,13 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
>        else
>  	{
>  	  gdb_assert (tu_group->symtabs == NULL);
> -	  restart_symtab (tu_group->compunit_symtab, "", 0);
> +	  gdb_assert (!bool (cu->builder));

That looks odd, can't you do the usual

  gdb_assert (cu->builder == nullptr) ?

There are other instances of this.

> @@ -24200,6 +24237,7 @@ dwarf_parse_macro_header (const gdb_byte **opcode_definitions,
>  
>  static void
>  dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
> +			  struct dwarf2_cu *cu,
>  			  bfd *abfd,
>  			  const gdb_byte *mac_ptr, const gdb_byte *mac_end,
>  			  struct macro_source_file *current_file,

You can probably remove the dwarf2_per_objfile parameter, since it's<
available as:

struct dwarf2_per_objfile *dwarf2_per_objfile
    = cu->per_cu->dwarf2_per_objfile;

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 41/42] Remove some unused buildsym functions
  2018-05-23  6:16 ` [RFA 41/42] Remove some unused buildsym functions Tom Tromey
@ 2018-07-10  4:37   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:37 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> Now that the DWARF reader uses the builder-based API, we can remove a
> few "legacy" functions that were only ever called by it.

LGTM.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 42/42] Remove record_line_ftype
  2018-05-23  6:16 ` [RFA 42/42] Remove record_line_ftype Tom Tromey
@ 2018-07-10  4:38   ` Simon Marchi
  0 siblings, 0 replies; 129+ messages in thread
From: Simon Marchi @ 2018-07-10  4:38 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-23 12:58 AM, Tom Tromey wrote:
> The record_line_ftype typedef was only used in the DWARF reader, and
> we removed those uses a few patches ago.  So, remove the typedef.

LGTM.

Simon

PS: Thanks for splitting the series the way you did.  42 patches looks like a lot,
but it was actually much easier to understand and review like this than if it had
been 4-5 big patches.

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 22/42] Move current_subfile to buildsym_compunit
  2018-07-10  1:52   ` Simon Marchi
@ 2018-07-12  4:34     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-12  4:34 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> @@ -901,8 +902,10 @@ void
>> push_subfile ()
>> {
>> gdb_assert (buildsym_compunit != nullptr);
>> -  gdb_assert (! (current_subfile == NULL || current_subfile->name == NULL));
>> -  buildsym_compunit->m_subfile_stack.push_back (current_subfile->name);
>> +  gdb_assert (! (buildsym_compunit->m_current_subfile == NULL
>> +		 || buildsym_compunit->m_current_subfile->name == NULL));

Simon> Here, you might as well write two separate asserts.

Simon>   gdb_assert (buildsym_compunit->m_current_subfile != NULL);
Simon>   gdb_assert (buildsym_compunit->m_current_subfile->name != NULL);

Simon> Otherwise, LGTM.

I made this change.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 23/42] Move pending addrmap globals to buildsym_compunit
  2018-07-10  1:56   ` Simon Marchi
@ 2018-07-12  4:35     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-12  4:35 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> +  if (! buildsym_compunit->m_pending_addrmap)

Simon> Can you please change this to == nullptr?

>> +  if (buildsym_compunit->m_pending_addrmap
>> +      && buildsym_compunit->m_pending_addrmap_interesting)

Simon> And here != nullptr.

Simon> Otherwise, LGTM.

I did this.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 24/42] Move pending_blocks and pending_block_obstack to buildsym_compunit
  2018-07-10  2:05   ` Simon Marchi
@ 2018-07-12  4:39     ` Tom Tromey
  2018-07-12  5:03       ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-07-12  4:39 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> @@ -344,7 +348,6 @@ find_symbol_in_list (struct pending *list, char *name, int length)
>> 
>> scoped_free_pendings::scoped_free_pendings ()
>> {
>> -  gdb_assert (pending_blocks == nullptr);
>> }

Simon> You can remove the constructor (here and in the .h).

I made this change.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 29/42] Move the symbol lists to buildsym_compunit
  2018-07-06 18:35   ` Keith Seitz
@ 2018-07-12  4:45     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-12  4:45 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> I know these are all cut-n-paste descriptions, but could you
Keith> please update them (incomplete sentences/grammar)?

I did this.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 24/42] Move pending_blocks and pending_block_obstack to buildsym_compunit
  2018-07-12  4:39     ` Tom Tromey
@ 2018-07-12  5:03       ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-12  5:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Simon Marchi, gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>>> @@ -344,7 +348,6 @@ find_symbol_in_list (struct pending *list, char *name, int length)
>>> 
>>> scoped_free_pendings::scoped_free_pendings ()
>>> {
>>> -  gdb_assert (pending_blocks == nullptr);
>>> }

Simon> You can remove the constructor (here and in the .h).

Tom> I made this change.

Actually I had to "= default" the constructor, due to the use of
DISABLE_COPY_AND_ASSIGN.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 34/42] Add many methods to buildsym_compunit
  2018-07-10  4:08   ` Simon Marchi
@ 2018-07-12  5:18     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-12  5:18 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> Oh, and could you provide a comment for the second constructor?

I did this.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 40/42] Convert the DWARF reader to new-style buildysm
  2018-07-10  4:36   ` Simon Marchi
@ 2018-07-15 17:38     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-15 17:38 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> Just some nits, otherwise it LGTM.
[...]

I made these changes.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 29/42] Move the symbol lists to buildsym_compunit
  2018-07-10  3:38   ` Simon Marchi
@ 2018-07-15 17:44     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-15 17:44 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> I find it a bit odd to use get_file_symbols () in the "if" but
Simon> buildsym_compunit-> m_file_symbols later.  I guess it would make
Simon> sense for what will eventually become a method of buildsym_compunit
Simon> to access the field directly.

Simon> The same occurs at different places, with different fields.

I fixed these spots up.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 28/42] Set list_in_scope later in DWARF reader
  2018-07-06 18:11   ` Keith Seitz
  2018-07-10  3:23     ` Simon Marchi
@ 2018-07-15 17:55     ` Tom Tromey
  1 sibling, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-15 17:55 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> On 05/22/2018 09:58 PM, Tom Tromey wrote:
>> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
>> index 3cc15ab645..f7cca01445 100644
>> --- a/gdb/dwarf2read.c
>> +++ b/gdb/dwarf2read.c
>> @@ -21138,6 +21134,8 @@ dwarf2_start_symtab (struct dwarf2_cu *cu,
>> = start_symtab (cu->per_cu->dwarf2_per_objfile->objfile, name, comp_dir,
>> low_pc, cu->language);
>> 
>> +  cu->list_in_scope = get_file_symbols ();
>> +
>> record_debugformat ("DWARF 2");
>> record_producer (cu->producer);
>> 
>> 

Keith> Warning: `get_file_symbols' is undefined until the next patch.

Thanks.  I've fixed this.
I'll make sure to build each patch in the series before re-sending.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 21/42] Move the context stack to buildsym_compunit
  2018-07-06 17:30   ` Keith Seitz
@ 2018-07-15 18:09     ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-15 18:09 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches

>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> I can't help but think these function names, which could appear in
Keith> several source files, seem a little vague or collision-prone
Keith> (conceptually)... Would it be worth it for these (and perhaps all
Keith> similar buildsym.h get_* functions) to be namespaced or further
Keith> prefixed, e.g., buildsym_[get_]current_context_stack or
Keith> buildsym::get_current_context_stack? I'm not going to suggest [Dare I
Keith> say, "require?"] any changes -- I'm just wondering "aloud."

I think it would be a reasonable follow-up patch; though seeing that
these things are all in the legacy API, I guess I'd be inclined not to
bother.

>> +/* Non-zero if the context stack is empty.  */
Keith>       ^^^^^^^^
>> +
>> +extern bool outermost_context_p ();

Keith> Since this (now) returns bool, please use boolean in comment.

Fixed.

>> +
>> +/* Return the top of the context stack, or nullptr if there is
>> +   entry.  */
>> +
>> +extern struct context_stack *get_current_context_stack ();
>> +

Keith> Typo in "if there is entry."

Fixed.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 21/42] Move the context stack to buildsym_compunit
  2018-07-10  1:45     ` Simon Marchi
@ 2018-07-15 18:10       ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-15 18:10 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, GDB patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> Would it work to make pop_context return the context_stack object by value
Simon> instead?

Nice idea, I've made this change in the new version.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 38/42] Introduce legacy-buildsym.h
  2018-07-10  4:22   ` Simon Marchi
@ 2018-07-15 18:43     ` Tom Tromey
  2018-07-15 19:46       ` Simon Marchi
  0 siblings, 1 reply; 129+ messages in thread
From: Tom Tromey @ 2018-07-15 18:43 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>> This introduces a new header, legacy-buildsym.h, and changes all the
>> symbol readers to use it.  The idea is to put the function-based
>> interface, that relies on the buildsym_compunit global, into a
>> separate header.  Then when a symbol reader is updated to use the new
>> interface, it can simply not include legacy-buildsym.h, so it's easy
>> to be sure that the new API is used everywhere.

Simon> Cool, good idea.  I have two suggestions:

Simon> - Name it buildsym-legacy.h, so that it will be ordered right next to
Simon>   buildsym.h in alphabetical lists.
Simon> - I would also create buildsym-legacy.c and move all the corresponding
Simon>   definitions there, including the buildsym_compunit global variable.
Simon>   I haven't actually tried it, maybe it's not possible and you have
Simon>   already tried it though.

I did these.
I think I've made it through all the review comments.
I'm running the result through the buildbot again & then I will
re-submit it.  I think due to the number of rebases and edits required
it will need another round of review.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 38/42] Introduce legacy-buildsym.h
  2018-07-15 18:43     ` Tom Tromey
@ 2018-07-15 19:46       ` Simon Marchi
  2018-07-16  0:22         ` Tom Tromey
  0 siblings, 1 reply; 129+ messages in thread
From: Simon Marchi @ 2018-07-15 19:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2018-07-15 14:43, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
> 
> Simon> On 2018-05-23 12:58 AM, Tom Tromey wrote:
>>> This introduces a new header, legacy-buildsym.h, and changes all the
>>> symbol readers to use it.  The idea is to put the function-based
>>> interface, that relies on the buildsym_compunit global, into a
>>> separate header.  Then when a symbol reader is updated to use the new
>>> interface, it can simply not include legacy-buildsym.h, so it's easy
>>> to be sure that the new API is used everywhere.
> 
> Simon> Cool, good idea.  I have two suggestions:
> 
> Simon> - Name it buildsym-legacy.h, so that it will be ordered right 
> next to
> Simon>   buildsym.h in alphabetical lists.
> Simon> - I would also create buildsym-legacy.c and move all the 
> corresponding
> Simon>   definitions there, including the buildsym_compunit global 
> variable.
> Simon>   I haven't actually tried it, maybe it's not possible and you 
> have
> Simon>   already tried it though.
> 
> I did these.
> I think I've made it through all the review comments.
> I'm running the result through the buildbot again & then I will
> re-submit it.  I think due to the number of rebases and edits required
> it will need another round of review.

Sure.  But if there are some patches that had no comments that can be 
pushed
on their own, feel free to do so.  It would reduce the size of v2 a bit.

Simon

^ permalink raw reply	[flat|nested] 129+ messages in thread

* Re: [RFA 38/42] Introduce legacy-buildsym.h
  2018-07-15 19:46       ` Simon Marchi
@ 2018-07-16  0:22         ` Tom Tromey
  0 siblings, 0 replies; 129+ messages in thread
From: Tom Tromey @ 2018-07-16  0:22 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

Simon> Sure.  But if there are some patches that had no comments that
Simon> can be pushed on their own, feel free to do so.  It would reduce
Simon> the size of v2 a bit.

Sure thing.  By my reading the first patch with non-trivial changes was #21,
so I'll re-test the first 20 and push those.

Tom

^ permalink raw reply	[flat|nested] 129+ messages in thread

end of thread, other threads:[~2018-07-16  0:22 UTC | newest]

Thread overview: 129+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-23  4:59 [RFA 00/42] Remove globals from buildsym Tom Tromey
2018-05-23  4:59 ` [RFA 17/42] Move the subfile stack to buildsym_compunit Tom Tromey
2018-07-08 16:59   ` Simon Marchi
2018-05-23  4:59 ` [RFA 02/42] Change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr Tom Tromey
2018-07-07  2:34   ` Simon Marchi
2018-05-23  4:59 ` [RFA 04/42] Move last_source file to buildsym_compunit Tom Tromey
2018-07-07  3:51   ` Simon Marchi
2018-07-08 16:33     ` Tom Tromey
2018-07-08 16:37       ` Simon Marchi
2018-07-08 16:52         ` Tom Tromey
2018-07-08 17:01           ` Simon Marchi
2018-05-23  4:59 ` [RFA 15/42] Remove merge_symbol_lists Tom Tromey
2018-07-08 16:54   ` Simon Marchi
2018-05-23  4:59 ` [RFA 22/42] Move current_subfile to buildsym_compunit Tom Tromey
2018-07-10  1:52   ` Simon Marchi
2018-07-12  4:34     ` Tom Tromey
2018-05-23  4:59 ` [RFA 27/42] Do not look at file symbols when reading psymtabs Tom Tromey
2018-07-10  3:19   ` Simon Marchi
2018-05-23  4:59 ` [RFA 25/42] Remove the "listhead" argument from finish_block Tom Tromey
2018-07-10  2:07   ` Simon Marchi
2018-05-23  4:59 ` [RFA 13/42] Remove buildsym_new_init Tom Tromey
2018-07-08 16:51   ` Simon Marchi
2018-05-23  4:59 ` [RFA 29/42] Move the symbol lists to buildsym_compunit Tom Tromey
2018-07-06 18:35   ` Keith Seitz
2018-07-12  4:45     ` Tom Tromey
2018-07-10  3:38   ` Simon Marchi
2018-07-15 17:44     ` Tom Tromey
2018-05-23  4:59 ` [RFA 05/42] Move pending_macros " Tom Tromey
2018-07-07 15:41   ` Simon Marchi
2018-07-08 16:35     ` Tom Tromey
2018-05-23  4:59 ` [RFA 26/42] Remove free_pendings Tom Tromey
2018-07-10  2:55   ` Simon Marchi
2018-07-10  3:16     ` Simon Marchi
2018-05-23  4:59 ` [RFA 18/42] Make free_pending_blocks static Tom Tromey
2018-07-08 17:04   ` Simon Marchi
2018-05-23  4:59 ` [RFA 06/42] Move have_line_numbers to buildsym_compunit Tom Tromey
2018-07-05 19:01   ` Keith Seitz
2018-07-08 16:05     ` Simon Marchi
2018-07-08 16:26     ` Tom Tromey
2018-05-23  4:59 ` [RFA 23/42] Move pending addrmap globals " Tom Tromey
2018-07-10  1:56   ` Simon Marchi
2018-07-12  4:35     ` Tom Tromey
2018-05-23  4:59 ` [RFA 03/42] Add assert in prepare_for_building Tom Tromey
2018-07-07 14:06   ` Simon Marchi
2018-05-23  4:59 ` [RFA 08/42] Move processing_acc_compilation to dbxread.c Tom Tromey
2018-07-08 16:15   ` Simon Marchi
2018-05-23  4:59 ` [RFA 09/42] Make context_stack_size static in buildsym.c Tom Tromey
2018-07-08 16:16   ` Simon Marchi
2018-05-23  4:59 ` [RFA 16/42] Use gdb_assert in two places " Tom Tromey
2018-07-08 16:55   ` Simon Marchi
2018-07-09 23:13     ` Tom Tromey
2018-05-23  4:59 ` [RFA 19/42] Move the using directives to buildsym_compunit Tom Tromey
2018-07-05 20:14   ` Keith Seitz
2018-07-08 16:28     ` Tom Tromey
2018-07-08 17:08       ` Simon Marchi
2018-05-23  4:59 ` [RFA 20/42] Use outermost_context_p in more places Tom Tromey
2018-07-08 17:13   ` Simon Marchi
2018-05-23  4:59 ` [RFA 10/42] Move some code from buildsym to stabsread Tom Tromey
2018-07-05 19:16   ` Keith Seitz
2018-07-08 16:35     ` Simon Marchi
2018-07-08 16:59       ` Tom Tromey
2018-07-08 16:37     ` Tom Tromey
2018-05-23  4:59 ` [RFA 28/42] Set list_in_scope later in DWARF reader Tom Tromey
2018-07-06 18:11   ` Keith Seitz
2018-07-10  3:23     ` Simon Marchi
2018-07-15 17:55     ` Tom Tromey
2018-05-23  4:59 ` [RFA 07/42] Move last_source_start_addr to buildsym_compunit Tom Tromey
2018-07-08 16:10   ` Simon Marchi
2018-05-23  4:59 ` [RFA 14/42] Move scan_file_globals declaration to stabsread.h Tom Tromey
2018-07-08 16:52   ` Simon Marchi
2018-07-09 23:07     ` Tom Tromey
2018-05-23  4:59 ` [RFA 21/42] Move the context stack to buildsym_compunit Tom Tromey
2018-07-06 17:30   ` Keith Seitz
2018-07-15 18:09     ` Tom Tromey
     [not found]   ` <93a9597f-e7ff-e8ff-e873-9cee5b84d7cc@simark.ca>
2018-07-10  1:45     ` Simon Marchi
2018-07-15 18:10       ` Tom Tromey
2018-05-23  4:59 ` [RFA 01/42] Use new and delete for buildsym_compunit Tom Tromey
2018-07-05 18:50   ` Keith Seitz
2018-07-07  2:31     ` Simon Marchi
2018-07-08 16:25     ` Tom Tromey
2018-05-23  4:59 ` [RFA 12/42] Move within_function to stabsread Tom Tromey
2018-07-08 16:49   ` Simon Marchi
2018-05-23  6:16 ` [RFA 34/42] Add many methods to buildsym_compunit Tom Tromey
2018-07-06 19:16   ` Keith Seitz
2018-07-08 16:39     ` Tom Tromey
2018-07-10  4:08   ` Simon Marchi
2018-07-12  5:18     ` Tom Tromey
2018-07-10  4:08   ` Simon Marchi
2018-07-10  4:12     ` Simon Marchi
2018-05-23  6:16 ` [RFA 11/42] Move processing_gcc to stabsread Tom Tromey
2018-07-08 16:46   ` Simon Marchi
2018-07-08 16:56     ` Tom Tromey
2018-05-23  6:16 ` [RFA 24/42] Move pending_blocks and pending_block_obstack to buildsym_compunit Tom Tromey
2018-07-10  2:05   ` Simon Marchi
2018-07-12  4:39     ` Tom Tromey
2018-07-12  5:03       ` Tom Tromey
2018-05-23  6:16 ` [RFA 40/42] Convert the DWARF reader to new-style buildysm Tom Tromey
2018-07-06 20:10   ` Keith Seitz
2018-07-10  4:36   ` Simon Marchi
2018-07-15 17:38     ` Tom Tromey
2018-05-23  6:16 ` [RFA 32/42] Remove EXTERN from buildsym.h Tom Tromey
2018-07-10  3:44   ` Simon Marchi
2018-05-23  6:16 ` [RFA 39/42] Parameterize cp_scan_for_anonymous_namespaces Tom Tromey
2018-07-06 19:23   ` Keith Seitz
2018-07-08 16:40     ` Tom Tromey
2018-07-10  4:25       ` Simon Marchi
2018-05-23  6:16 ` [RFA 35/42] Do not use buildsym.h in some files Tom Tromey
2018-07-10  4:10   ` Simon Marchi
2018-05-23  6:16 ` [RFA 36/42] Remove reset_symtab_globals Tom Tromey
2018-07-10  4:11   ` Simon Marchi
2018-05-23  6:16 ` [RFA 42/42] Remove record_line_ftype Tom Tromey
2018-07-10  4:38   ` Simon Marchi
2018-05-23  6:16 ` [RFA 33/42] Remove parameter from record_pending_block Tom Tromey
2018-07-10  3:49   ` Simon Marchi
2018-05-23  6:16 ` [RFA 31/42] Remove a TODO Tom Tromey
2018-07-10  3:42   ` Simon Marchi
2018-05-23  6:16 ` [RFA 37/42] Move struct buildsym_compunit to buildsym.h Tom Tromey
2018-07-10  4:15   ` Simon Marchi
2018-05-23  6:16 ` [RFA 41/42] Remove some unused buildsym functions Tom Tromey
2018-07-10  4:37   ` Simon Marchi
2018-05-23  7:31 ` [RFA 38/42] Introduce legacy-buildsym.h Tom Tromey
2018-07-10  4:22   ` Simon Marchi
2018-07-15 18:43     ` Tom Tromey
2018-07-15 19:46       ` Simon Marchi
2018-07-16  0:22         ` Tom Tromey
2018-05-23  8:49 ` [RFA 30/42] Remove buildsym_init Tom Tromey
2018-07-10  3:41   ` Simon Marchi
2018-06-18 14:46 ` [RFA 00/42] Remove globals from buildsym Tom Tromey
2018-07-05 18:21 ` Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).