This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


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

[binutils-gdb] Add compunits range adapter to objfile


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b669c95337903d39aa2254e8ea0405c0ac117d24

commit b669c95337903d39aa2254e8ea0405c0ac117d24
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Jan 15 20:06:48 2019 -0700

    Add compunits range adapter to objfile
    
    This removes the objfile_compunits range adapter in favor of using a
    method on objfile.
    
    2019-01-15  Tom Tromey  <tom@tromey.com>
    
    	* symtab.c (lookup_objfile_from_block)
    	(lookup_symbol_in_objfile_symtabs)
    	(basic_lookup_transparent_type_1, find_pc_sect_compunit_symtab)
    	(find_line_symtab, info_sources_command)
    	(default_collect_symbol_completion_matches_break_on)
    	(make_source_files_completion_list): Update.
    	* symmisc.c (print_objfile_statistics, dump_objfile)
    	(maintenance_print_symbols, maintenance_info_symtabs)
    	(maintenance_check_symtabs, maintenance_info_line_tables):
    	Update.
    	* source.c (select_source_symtab)
    	(forget_cached_source_info_for_objfile): Update.
    	* objfiles.h (class objfile_compunits): Remove.
    	(struct objfile) <compunits_range>: New typedef.
    	(compunits): New method.
    	* objfiles.c (objfile_relocate1): Update.
    	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
    	* maint.c (count_symtabs_and_blocks): Update.
    	* linespec.c (iterate_over_all_matching_symtabs): Update.
    	* cp-support.c (add_symbol_overload_list_qualified): Update.
    	* coffread.c (coff_symtab_read): Update.
    	* ada-lang.c (add_nonlocal_symbols)
    	(ada_collect_symbol_completion_matches)
    	(ada_add_global_exceptions): Update.

Diff:
---
 gdb/ChangeLog        | 27 +++++++++++++++++++++++++++
 gdb/ada-lang.c       |  8 ++++----
 gdb/coffread.c       |  2 +-
 gdb/cp-support.c     |  4 ++--
 gdb/linespec.c       |  2 +-
 gdb/maint.c          |  2 +-
 gdb/mi/mi-cmd-file.c |  2 +-
 gdb/objfiles.c       |  4 ++--
 gdb/objfiles.h       | 22 +++++++++-------------
 gdb/source.c         |  4 ++--
 gdb/symmisc.c        | 16 ++++++++--------
 gdb/symtab.c         | 18 +++++++++---------
 12 files changed, 67 insertions(+), 44 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f59eeb1..d3b16f6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,32 @@
 2019-01-15  Tom Tromey  <tom@tromey.com>
 
+	* symtab.c (lookup_objfile_from_block)
+	(lookup_symbol_in_objfile_symtabs)
+	(basic_lookup_transparent_type_1, find_pc_sect_compunit_symtab)
+	(find_line_symtab, info_sources_command)
+	(default_collect_symbol_completion_matches_break_on)
+	(make_source_files_completion_list): Update.
+	* symmisc.c (print_objfile_statistics, dump_objfile)
+	(maintenance_print_symbols, maintenance_info_symtabs)
+	(maintenance_check_symtabs, maintenance_info_line_tables):
+	Update.
+	* source.c (select_source_symtab)
+	(forget_cached_source_info_for_objfile): Update.
+	* objfiles.h (class objfile_compunits): Remove.
+	(struct objfile) <compunits_range>: New typedef.
+	(compunits): New method.
+	* objfiles.c (objfile_relocate1): Update.
+	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
+	* maint.c (count_symtabs_and_blocks): Update.
+	* linespec.c (iterate_over_all_matching_symtabs): Update.
+	* cp-support.c (add_symbol_overload_list_qualified): Update.
+	* coffread.c (coff_symtab_read): Update.
+	* ada-lang.c (add_nonlocal_symbols)
+	(ada_collect_symbol_completion_matches)
+	(ada_add_global_exceptions): Update.
+
+2019-01-15  Tom Tromey  <tom@tromey.com>
+
 	* progspace.h (program_space) <objfiles_safe_range>: New
 	typedef.
 	<objfiles_safe>: New method.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index df915c5..7d99754 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5629,7 +5629,7 @@ add_nonlocal_symbols (struct obstack *obstackp,
 					       symbol_name_match_type::FULL,
 					       compare_names);
 
-      for (compunit_symtab *cu : objfile_compunits (objfile))
+      for (compunit_symtab *cu : objfile->compunits ())
 	{
 	  const struct block *global_block
 	    = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK);
@@ -6467,7 +6467,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *s : objfile_compunits (objfile))
+      for (compunit_symtab *s : objfile->compunits ())
 	{
 	  QUIT;
 	  b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
@@ -6486,7 +6486,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *s : objfile_compunits (objfile))
+      for (compunit_symtab *s : objfile->compunits ())
 	{
 	  QUIT;
 	  b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
@@ -13568,7 +13568,7 @@ ada_add_global_exceptions (compiled_regex *preg,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *s : objfile_compunits (objfile))
+      for (compunit_symtab *s : objfile->compunits ())
 	{
 	  const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s);
 	  int i;
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 4f05295..2b75d81 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1203,7 +1203,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
   /* Patch up any opaque types (references to types that are not defined
      in the file where they are referenced, e.g. "struct foo *bar").  */
   {
-    for (compunit_symtab *cu : objfile_compunits (objfile))
+    for (compunit_symtab *cu : objfile->compunits ())
       {
 	for (symtab *s : compunit_filetabs (cu))
 	  patch_opaque_types (s);
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 4e4d2cb..bc5e804 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1397,7 +1397,7 @@ add_symbol_overload_list_qualified (const char *func_name,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cust : objfile_compunits (objfile))
+      for (compunit_symtab *cust : objfile->compunits ())
 	{
 	  QUIT;
 	  b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
@@ -1407,7 +1407,7 @@ add_symbol_overload_list_qualified (const char *func_name,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cust : objfile_compunits (objfile))
+      for (compunit_symtab *cust : objfile->compunits ())
 	{
 	  QUIT;
 	  b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 54f17b7..cedbd39 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1150,7 +1150,7 @@ iterate_over_all_matching_symtabs
 						    NULL, NULL,
 						    search_domain);
 
-	for (compunit_symtab *cu : objfile_compunits (objfile))
+	for (compunit_symtab *cu : objfile->compunits ())
 	  {
 	    struct symtab *symtab = COMPUNIT_FILETABS (cu);
 
diff --git a/gdb/maint.c b/gdb/maint.c
index e653a5d..ddd25a4 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -773,7 +773,7 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
     {
       for (objfile *o : current_program_space->objfiles ())
 	{
-	  for (compunit_symtab *cu : objfile_compunits (o))
+	  for (compunit_symtab *cu : o->compunits ())
 	    {
 	      ++nr_compunit_symtabs;
 	      nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index 0d9770a..714ab01 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -94,7 +94,7 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
   /* Look at all of the file symtabs.  */
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cu : objfile_compunits (objfile))
+      for (compunit_symtab *cu : objfile->compunits ())
 	{
 	  for (symtab *s : compunit_filetabs (cu))
 	    {
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 82400a4..34b271e 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -787,7 +787,7 @@ objfile_relocate1 (struct objfile *objfile,
 
   /* OK, get all the symtabs.  */
   {
-    for (compunit_symtab *cust : objfile_compunits (objfile))
+    for (compunit_symtab *cust : objfile->compunits ())
       {
 	for (symtab *s : compunit_filetabs (cust))
 	  {
@@ -805,7 +805,7 @@ objfile_relocate1 (struct objfile *objfile,
 	  }
       }
 
-    for (compunit_symtab *cust : objfile_compunits (objfile))
+    for (compunit_symtab *cust : objfile->compunits ())
       {
 	const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
 	int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 599d8a1..2cf6195 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -301,6 +301,15 @@ struct objfile
     partial_symtabs.reset (new psymtab_storage ());
   }
 
+  typedef next_adapter<struct compunit_symtab> compunits_range;
+
+  /* A range adapter that makes it possible to iterate over all
+     compunits in one objfile.  */
+
+  compunits_range compunits ()
+  {
+    return compunits_range (compunit_symtabs);
+  }
 
   /* All struct objfile's are chained together by their next pointers.
      The program space field "objfiles"  (frequently referenced via
@@ -554,19 +563,6 @@ extern void default_iterate_over_objfiles_in_search_order
 
 
 /* A range adapter that makes it possible to iterate over all
-   compunits in one objfile.  */
-
-class objfile_compunits : public next_adapter<struct compunit_symtab>
-{
-public:
-
-  explicit objfile_compunits (struct objfile *objfile)
-    : next_adapter<struct compunit_symtab> (objfile->compunit_symtabs)
-  {
-  }
-};
-
-/* A range adapter that makes it possible to iterate over all
    minimal symbols of an objfile.  */
 
 class objfile_msymbols
diff --git a/gdb/source.c b/gdb/source.c
index 196680d..d070958 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -271,7 +271,7 @@ select_source_symtab (struct symtab *s)
 
   for (objfile *ofp : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cu : objfile_compunits (ofp))
+      for (compunit_symtab *cu : ofp->compunits ())
 	{
 	  for (symtab *symtab : compunit_filetabs (cu))
 	    {
@@ -353,7 +353,7 @@ show_directories_command (struct ui_file *file, int from_tty,
 void
 forget_cached_source_info_for_objfile (struct objfile *objfile)
 {
-  for (compunit_symtab *cu : objfile_compunits (objfile))
+  for (compunit_symtab *cu : objfile->compunits ())
     {
       for (symtab *s : compunit_filetabs (cu))
 	{
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index d2feddc..ac5c392 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -108,7 +108,7 @@ print_objfile_statistics (void)
       if (objfile->sf)
 	objfile->sf->qf->print_stats (objfile);
       i = linetables = 0;
-      for (compunit_symtab *cu : objfile_compunits (objfile))
+      for (compunit_symtab *cu : objfile->compunits ())
 	{
 	  for (symtab *s : compunit_filetabs (cu))
 	    {
@@ -117,8 +117,8 @@ print_objfile_statistics (void)
 		linetables++;
 	    }
 	}
-      blockvectors = std::distance (objfile_compunits (objfile).begin (),
-				    objfile_compunits (objfile).end ());
+      blockvectors = std::distance (objfile->compunits ().begin (),
+				    objfile->compunits ().end ());
       printf_filtered (_("  Number of symbol tables: %d\n"), i);
       printf_filtered (_("  Number of symbol tables with line tables: %d\n"),
 		       linetables);
@@ -162,7 +162,7 @@ dump_objfile (struct objfile *objfile)
   if (objfile->compunit_symtabs != NULL)
     {
       printf_filtered ("Symtabs:\n");
-      for (compunit_symtab *cu : objfile_compunits (objfile))
+      for (compunit_symtab *cu : objfile->compunits ())
 	{
 	  for (symtab *symtab : compunit_filetabs (cu))
 	    {
@@ -486,7 +486,7 @@ maintenance_print_symbols (const char *args, int from_tty)
 	  if (!print_for_objfile)
 	    continue;
 
-	  for (compunit_symtab *cu : objfile_compunits (objfile))
+	  for (compunit_symtab *cu : objfile->compunits ())
 	    {
 	      for (symtab *s : compunit_filetabs (cu))
 		{
@@ -784,7 +784,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 	   actually find a symtab whose name matches.  */
 	int printed_objfile_start = 0;
 
-	for (compunit_symtab *cust : objfile_compunits (objfile))
+	for (compunit_symtab *cust : objfile->compunits ())
 	  {
 	    int printed_compunit_symtab_start = 0;
 
@@ -869,7 +869,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
 	   actually find something worth printing.  */
 	int printed_objfile_start = 0;
 
-	for (compunit_symtab *cust : objfile_compunits (objfile))
+	for (compunit_symtab *cust : objfile->compunits ())
 	  {
 	    int found_something = 0;
 	    struct symtab *symtab = compunit_primary_filetab (cust);
@@ -1032,7 +1032,7 @@ maintenance_info_line_tables (const char *regexp, int from_tty)
   ALL_PSPACES (pspace)
     for (objfile *objfile : pspace->objfiles ())
       {
-	for (compunit_symtab *cust : objfile_compunits (objfile))
+	for (compunit_symtab *cust : objfile->compunits ())
 	  {
 	    for (symtab *symtab : compunit_filetabs (cust))
 	      {
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 370c8b4..b8ebbc2 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2171,7 +2171,7 @@ lookup_objfile_from_block (const struct block *block)
   /* Look through all blockvectors.  */
   for (objfile *obj : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cust : objfile_compunits (obj))
+      for (compunit_symtab *cust : obj->compunits ())
 	if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
 					GLOBAL_BLOCK))
 	  {
@@ -2265,7 +2265,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
 			  name, domain_name (domain));
     }
 
-  for (compunit_symtab *cust : objfile_compunits (objfile))
+  for (compunit_symtab *cust : objfile->compunits ())
     {
       const struct blockvector *bv;
       const struct block *block;
@@ -2763,7 +2763,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile, int block_index,
   const struct block *block;
   const struct symbol *sym;
 
-  for (compunit_symtab *cust : objfile_compunits (objfile))
+  for (compunit_symtab *cust : objfile->compunits ())
     {
       bv = COMPUNIT_BLOCKVECTOR (cust);
       block = BLOCKVECTOR_BLOCK (bv, block_index);
@@ -2904,7 +2904,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
 
   for (objfile *obj_file : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cust : objfile_compunits (obj_file))
+      for (compunit_symtab *cust : obj_file->compunits ())
 	{
 	  struct block *b;
 	  const struct blockvector *bv;
@@ -3360,7 +3360,7 @@ find_line_symtab (struct symtab *sym_tab, int line,
 
       for (objfile *objfile : current_program_space->objfiles ())
 	{
-	  for (compunit_symtab *cu : objfile_compunits (objfile))
+	  for (compunit_symtab *cu : objfile->compunits ())
 	    {
 	      for (symtab *s : compunit_filetabs (cu))
 		{
@@ -4200,7 +4200,7 @@ info_sources_command (const char *ignore, int from_tty)
   data.first = 1;
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cu : objfile_compunits (objfile))
+      for (compunit_symtab *cu : objfile->compunits ())
 	{
 	  for (symtab *s : compunit_filetabs (cu))
 	    {
@@ -4492,7 +4492,7 @@ search_symbols (const char *regexp, enum search_domain kind,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cust : objfile_compunits (objfile))
+      for (compunit_symtab *cust : objfile->compunits ())
 	{
 	  bv = COMPUNIT_BLOCKVECTOR (cust);
 	  for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
@@ -5293,7 +5293,7 @@ default_collect_symbol_completion_matches_break_on
   /* Add completions for all currently loaded symbol tables.  */
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cust : objfile_compunits (objfile))
+      for (compunit_symtab *cust : objfile->compunits ())
 	add_symtab_completions (cust, tracker, mode, lookup_name,
 				sym_text, word, code);
     }
@@ -5602,7 +5602,7 @@ make_source_files_completion_list (const char *text, const char *word)
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cu : objfile_compunits (objfile))
+      for (compunit_symtab *cu : objfile->compunits ())
 	{
 	  for (symtab *s : compunit_filetabs (cu))
 	    {


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