Add compunits range adapter to objfile
[deliverable/binutils-gdb.git] / gdb / maint.c
index 70e00110e52bbbddccd0a632e1d6d0737e804e3a..ddd25a480cca2235aea5cd9fb99d476a26499e33 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for GDB maintenance commands.
 
-   Copyright (C) 1992-2018 Free Software Foundation, Inc.
+   Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
    Written by Fred Fish at Cygnus Support.
 
@@ -348,7 +348,6 @@ maintenance_info_sections (const char *arg, int from_tty)
       printf_filtered (_("file type %s.\n"), bfd_get_target (exec_bfd));
       if (arg && *arg && match_substring (arg, "ALLOBJ"))
        {
-         struct objfile *ofile;
          struct obj_section *osect;
 
          /* Only this function cares about the 'ALLOBJ' argument; 
@@ -358,7 +357,7 @@ maintenance_info_sections (const char *arg, int from_tty)
          if (strcmp (arg, "ALLOBJ") == 0)
            arg = NULL;
 
-         ALL_OBJFILES (ofile)
+         for (objfile *ofile : current_program_space->objfiles ())
            {
              printf_filtered (_("  Object file: %s\n"), 
                               bfd_get_filename (ofile->obfd));
@@ -431,7 +430,6 @@ maintenance_translate_address (const char *arg, int from_tty)
   struct obj_section *sect;
   const char *p;
   struct bound_minimal_symbol sym;
-  struct objfile *objfile;
 
   if (arg == NULL || *arg == 0)
     error (_("requires argument (address or section + address)"));
@@ -444,19 +442,20 @@ maintenance_translate_address (const char *arg, int from_tty)
       while (*p && !isspace (*p))      /* Find end of section name.  */
        p++;
       if (*p == '\000')                /* End of command?  */
-       error (_("Need to specify <section-name> and <address>"));
+       error (_("Need to specify section name and address"));
 
       int arg_len = p - arg;
       p = skip_spaces (p + 1);
 
-      ALL_OBJSECTIONS (objfile, sect)
-      {
-       if (strncmp (sect->the_bfd_section->name, arg, arg_len) == 0)
-         break;
-      }
+      for (objfile *objfile : current_program_space->objfiles ())
+       ALL_OBJFILE_OSECTIONS (objfile, sect)
+         {
+           if (strncmp (sect->the_bfd_section->name, arg, arg_len) == 0)
+             goto found;
+         }
 
-      if (!objfile)
-       error (_("Unknown section %s."), arg);
+      error (_("Unknown section %s."), arg);
+    found: ;
     }
 
   address = parse_and_eval_address (p);
@@ -763,9 +762,6 @@ static void
 count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
                          int *nr_blocks_ptr)
 {
-  struct objfile *o;
-  struct compunit_symtab *cu;
-  struct symtab *s;
   int nr_symtabs = 0;
   int nr_compunit_symtabs = 0;
   int nr_blocks = 0;
@@ -775,12 +771,15 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
      current_program_space may be NULL.  */
   if (current_program_space != NULL)
     {
-      ALL_COMPUNITS (o, cu)
+      for (objfile *o : current_program_space->objfiles ())
        {
-         ++nr_compunit_symtabs;
-         nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
-         ALL_COMPUNIT_FILETABS (cu, s)
-           ++nr_symtabs;
+         for (compunit_symtab *cu : o->compunits ())
+           {
+             ++nr_compunit_symtabs;
+             nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
+             nr_symtabs += std::distance (compunit_filetabs (cu).begin (),
+                                          compunit_filetabs (cu).end ());
+           }
        }
     }
 
@@ -828,7 +827,7 @@ scoped_command_stats::~scoped_command_stats ()
 
   if (m_space_enabled && per_command_space)
     {
-#ifdef HAVE_SBRK
+#ifdef HAVE_USEFUL_SBRK
       char *lim = (char *) sbrk (0);
 
       long space_now = lim - lim_at_start;
@@ -866,7 +865,7 @@ scoped_command_stats::scoped_command_stats (bool msg_type)
 {
   if (!m_msg_type || per_command_space)
     {
-#ifdef HAVE_SBRK
+#ifdef HAVE_USEFUL_SBRK
       char *lim = (char *) sbrk (0);
       m_start_space = lim - lim_at_start;
       m_space_enabled = 1;
@@ -943,7 +942,7 @@ maintenance_selftest (const char *args, int from_tty)
   selftests::run_tests (args);
 #else
   printf_filtered (_("\
-Selftests are not available in a non-development build.\n"));
+Selftests have been disabled for this build.\n"));
 #endif
 }
 
@@ -957,7 +956,7 @@ maintenance_info_selftests (const char *arg, int from_tty)
   });
 #else
   printf_filtered (_("\
-Selftests are not available in a non-development build.\n"));
+Selftests have been disabled for this build.\n"));
 #endif
 }
 
@@ -1046,12 +1045,12 @@ This command has been moved to \"demangle\"."),
 
   add_prefix_cmd ("per-command", class_maintenance, set_per_command_cmd, _("\
 Per-command statistics settings."),
-                   &per_command_setlist, "set per-command ",
+                   &per_command_setlist, "maintenance set per-command ",
                    1/*allow-unknown*/, &maintenance_set_cmdlist);
 
   add_prefix_cmd ("per-command", class_maintenance, show_per_command_cmd, _("\
 Show per-command statistics settings."),
-                   &per_command_showlist, "show per-command ",
+                   &per_command_showlist, "maintenance show per-command ",
                    0/*allow-unknown*/, &maintenance_show_cmdlist);
 
   add_setshow_boolean_cmd ("time", class_maintenance,
This page took 0.028633 seconds and 4 git commands to generate.