gdb/mi: handle no condition argument case for -break-condition
[deliverable/binutils-gdb.git] / gdb / symtab.c
index e300596be6ec5becdf1110cc574b07e485b8ee1c..fa3f42207ecd763bcd5cefc41132c125398fe117 100644 (file)
@@ -1698,8 +1698,7 @@ fixup_section (struct general_symbol_info *ginfo,
          if (fallback == -1)
            fallback = idx;
 
-         if (obj_section_addr (s) - offset <= addr
-             && addr < obj_section_endaddr (s) - offset)
+         if (s->addr () - offset <= addr && addr < s->endaddr () - offset)
            {
              ginfo->set_section_index (idx);
              return;
@@ -4243,6 +4242,8 @@ info_sources_filter::matches (const char *fullname) const
         case match_on::FULLNAME:
           to_match = fullname;
           break;
+       default:
+         gdb_assert_not_reached ("bad m_match_type");
         }
 
       if (m_c_regexp->exec (to_match, 0, NULL, 0) != 0)
@@ -4252,33 +4253,6 @@ info_sources_filter::matches (const char *fullname) const
   return true;
 }
 
-/* See class declaration.  */
-
-void
-info_sources_filter::print (struct ui_out *uiout) const
-{
-  if (m_c_regexp.has_value ())
-    {
-      gdb_assert (m_regexp != nullptr);
-
-      switch (m_match_type)
-       {
-       case match_on::DIRNAME:
-         uiout->message (_("(dirname matching regular expression \"%s\")"),
-                         m_regexp);
-         break;
-       case match_on::BASENAME:
-         uiout->message (_("(basename matching regular expression \"%s\")"),
-                         m_regexp);
-         break;
-       case match_on::FULLNAME:
-         printf_filtered (_("(filename matching regular expression \"%s\")"),
-                          m_regexp);
-         break;
-       }
-    }
-}
-
 /* Data structure to maintain the state used for printing the results of
    the 'info sources' command.  */
 
@@ -4312,12 +4286,6 @@ struct output_source_filename_data
      expanded symtab, otherwise false).  */
   void output (const char *disp_name, const char *fullname, bool expanded_p);
 
-  /* Prints the header messages for the source files that will be printed
-     with the matching info present in the current object state.
-     SYMBOL_MSG is a message that describes what will or has been done with
-     the symbols of the matching source files.  */
-  void print_header (const char *symbol_msg);
-
   /* An overload suitable for use as a callback to
      quick_symbol_functions::map_symbol_filenames.  */
   void operator() (const char *filename, const char *fullname)
@@ -4327,6 +4295,14 @@ struct output_source_filename_data
     output (filename, fullname, false);
   }
 
+  /* Return true if at least one filename has been printed (after a call to
+     output) since either this object was created, or the last call to
+     reset_output.  */
+  bool printed_filename_p () const
+  {
+    return !m_first;
+  }
+
 private:
 
   /* Flag of whether we're printing the first one.  */
@@ -4392,16 +4368,6 @@ output_source_filename_data::output (const char *disp_name,
     }
 }
 
-/* See comment is class declaration above.  */
-
-void
-output_source_filename_data::print_header (const char *symbol_msg)
-{
-  m_uiout->text (symbol_msg);
-  m_filter.print (m_uiout);
-  m_uiout->text ("\n");
-}
-
 /* For the 'info sources' command, what part of the file names should we be
    matching the user supplied regular expression against?  */
 
@@ -4459,6 +4425,7 @@ info_sources_command_completer (cmd_list_element *ignore,
 
 void
 info_sources_worker (struct ui_out *uiout,
+                    bool group_by_objfile,
                     const info_sources_filter &filter)
 {
   output_source_filename_data data (uiout, filter);
@@ -4467,11 +4434,42 @@ info_sources_worker (struct ui_out *uiout,
   gdb::optional<ui_out_emit_tuple> output_tuple;
   gdb::optional<ui_out_emit_list> sources_list;
 
-  if (!uiout->is_mi_like_p ())
-    data.print_header (_("Source files for which symbols have been read in:\n"));
+  gdb_assert (group_by_objfile || uiout->is_mi_like_p ());
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
+      if (group_by_objfile)
+       {
+         output_tuple.emplace (uiout, nullptr);
+         uiout->field_string ("filename", objfile_name (objfile));
+         uiout->text (":\n");
+         bool debug_fully_readin = !objfile->has_unexpanded_symtabs ();
+         if (uiout->is_mi_like_p ())
+           {
+             const char *debug_info_state;
+             if (objfile_has_symbols (objfile))
+               {
+                 if (debug_fully_readin)
+                   debug_info_state = "fully-read";
+                 else
+                   debug_info_state = "partially-read";
+               }
+             else
+               debug_info_state = "none";
+             current_uiout->field_string ("debug-info", debug_info_state);
+           }
+         else
+           {
+             if (!debug_fully_readin)
+               uiout->text ("(Full debug information has not yet been read "
+                            "for this file.)\n");
+             if (!objfile_has_symbols (objfile))
+               uiout->text ("(Objfile has no debug information.)\n");
+             uiout->text ("\n");
+           }
+         sources_list.emplace (uiout, "sources");
+       }
+
       for (compunit_symtab *cu : objfile->compunits ())
        {
          for (symtab *s : compunit_filetabs (cu))
@@ -4481,14 +4479,23 @@ info_sources_worker (struct ui_out *uiout,
              data.output (file, fullname, true);
            }
        }
+
+      if (group_by_objfile)
+       {
+         objfile->map_symbol_filenames (data, true /* need_fullname */);
+         if (data.printed_filename_p ())
+           uiout->text ("\n\n");
+         data.reset_output ();
+         sources_list.reset ();
+         output_tuple.reset ();
+       }
     }
 
-  uiout->text ("\n\n");
-  if (!uiout->is_mi_like_p ())
-    data.print_header (_("Source files for which symbols will be read in on demand:\n"));
-  data.reset_output ();
-  map_symbol_filenames (data, true /*need_fullname*/);
-  uiout->text ("\n");
+  if (!group_by_objfile)
+    {
+      data.reset_output ();
+      map_symbol_filenames (data, true /*need_fullname*/);
+    }
 }
 
 /* Implement the 'info sources' command.  */
@@ -4523,7 +4530,7 @@ info_sources_command (const char *args, int from_tty)
     match_type = info_sources_filter::match_on::FULLNAME;
 
   info_sources_filter filter (match_type, regex);
-  info_sources_worker (current_uiout, filter);
+  info_sources_worker (current_uiout, true, filter);
 }
 
 /* Compare FILE against all the entries of FILENAMES.  If BASENAMES is
This page took 0.025798 seconds and 4 git commands to generate.