Add compunits range adapter to objfile
authorTom Tromey <tom@tromey.com>
Wed, 16 Jan 2019 03:06:48 +0000 (20:06 -0700)
committerTom Tromey <tom@tromey.com>
Thu, 17 Jan 2019 22:42:05 +0000 (15:42 -0700)
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.

12 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/coffread.c
gdb/cp-support.c
gdb/linespec.c
gdb/maint.c
gdb/mi/mi-cmd-file.c
gdb/objfiles.c
gdb/objfiles.h
gdb/source.c
gdb/symmisc.c
gdb/symtab.c

index f59eeb13c7b255a3bf6482f0b5822326bfe05b95..d3b16f64c512f641de350233959482f7e509fc0f 100644 (file)
@@ -1,3 +1,30 @@
+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
index df915c594c26498085c787713bc41bbd3fe02452..7d997543c2630514be3e4e5f3a9b5adf0d5b527c 100644 (file)
@@ -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;
index 4f05295712220461d647e01600dfab162e85378d..2b75d8189fb7fe956f78d3a1e4bbf834a8e8f0b7 100644 (file)
@@ -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);
index 4e4d2cbc747901e44d119135086dc4fef88c5ca3..bc5e8047ae8dfbf887ba207f135e6076953610f1 100644 (file)
@@ -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);
index 54f17b7a8b4db105797661fd3bf8a4b99fc6d43f..cedbd39bd77dc357bb930ff39374a5a0a816997f 100644 (file)
@@ -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);
 
index e653a5d4ac82eec3170847ddd4f3ea41569e9001..ddd25a480cca2235aea5cd9fb99d476a26499e33 100644 (file)
@@ -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));
index 0d9770a2f58ea970627a9b2776ece0f0f398dc33..714ab01b2646c1c82ed8ccb437d28c1fb916d11b 100644 (file)
@@ -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))
            {
index 82400a4fe89a1b34d4168115f3d370dfd5d869f3..34b271e86de2b9e2fa392e9815e8aea291b29c09 100644 (file)
@@ -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);
index 599d8a1bce9cb682d3baa8547433660d64ad0b04..2cf61957ec1d1a3b534c0acbce71f045a24a653b 100644 (file)
@@ -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
@@ -553,19 +562,6 @@ extern void default_iterate_over_objfiles_in_search_order
    void *cb_data, struct objfile *current_objfile);
 \f
 
-/* 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.  */
 
index 196680deafc80699c0a1b670736d7e831537b3a3..d070958e852213c73b8c7f41287e4d5309279842 100644 (file)
@@ -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))
        {
index d2feddc39be14ccf3f88980d1f5d25f178583f0c..ac5c392dc5d823fc33d7022ee2aca44cab907c50 100644 (file)
@@ -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))
              {
index 370c8b45b3268bc1945ddc09dffa2ca77a6fbdda..b8ebbc2e1a04119ed69dbc554ab5b171fcb81876 100644 (file)
@@ -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))
            {
This page took 0.037954 seconds and 4 git commands to generate.