binutils-gdb/gdb/testsuite/gdb.mi/mi-info-sources.c
Andrew Burgess 0e350a054b gdb/mi: add regexp filtering to -file-list-exec-source-files
This commit extends the existing MI command
-file-list-exec-source-files to provide the same regular expression
based filtering that the equivalent CLI command "info sources"
provides.

The new command syntax is:

  -file-list-exec-source-files [--basename | --dirname] [--] [REGEXP]

All options are optional, which ensures the command is backward
compatible.

As part of this work I have unified the CLI and MI code.

As a result of the unified code I now provide additional information
in the MI command output, there is now a new field 'debug-fully-read'
included with each source file.  This field which has the values
'true' or 'false', indicates if the source file is from a compilation
unit that has had its debug information fully read.  However, as this
is additional information, a well written front-end should just ignore
this field if it doesn't understand it, so things should still be
backward compatible.

gdb/ChangeLog:

	* NEWS: Mention additions to -file-list-exec-source-files.
	* mi/mi-cmd-file.c (print_partial_file_name): Delete.
	(mi_cmd_file_list_exec_source_files): Rewrite to handle command
	options, and make use of info_sources_worker.
	* symtab.c (struct info_sources_filter): Moved to symtab.h.
	(info_sources_filter::print): Take uiout argument, produce output
	through uiout.
	(struct output_source_filename_data)
	<output_source_filename_data>: Take uiout argument, store into
	m_uiout.  <output>: Rewrite comment, add additional arguments to
	declaration.  <operator()>: Send more arguments to
	output. <m_uiout>: New member variable.
	(output_source_filename_data::output): Take extra arguments,
	produce output through m_uiout, and structure for MI.
	(output_source_filename_data::print_header): Produce output
	through m_uiout.
	(info_sources_worker): New function, the implementation is taken
	from info_sources_command, but modified so produce output through
	a ui_out.
	(info_sources_command): The second half of this function has gone
	to become info_sources_worker.
	* symtab.h (struct info_sources_filter): Moved from symtab.c, add
	extra parameter to print member function.
	(info_sources_worker): Declare.

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI File Commands): Document extensions to
	-file-list-exec-source-files.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-filename.exp: Update expected results.
	* gdb.mi/mi-file.exp: Likewise.
	* gdb.mi/mi-info-sources-base.c: New file.
	* gdb.mi/mi-info-sources.c: New file.
	* gdb.mi/mi-info-sources.exp: New file.
2021-06-25 20:54:29 +01:00

26 lines
910 B
C

/* This testcase is part of GDB, the GNU debugger.
Copyright 2019-2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This file was originally copied from gdb.base/info_sources.c. */
extern void some_other_func (void);
int main ()
{
some_other_func ();
return 0;
}