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;
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)
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. */
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)
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. */
}
}
-/* 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? */
void
info_sources_worker (struct ui_out *uiout,
+ bool group_by_objfile,
const info_sources_filter &filter)
{
output_source_filename_data data (uiout, filter);
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))
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. */
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