aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-05-18 13:46:19 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-06-25 20:54:29 +0100
commit0e350a054bbeb4d00f2c430c4815c82d5ffb47a7 (patch)
tree079b2ed8a2344ef2b6b7c854b9ccfe8450d34137 /gdb/doc
parent4a0788e08cbf9e7b90640475b17afbbf5423ea9d (diff)
downloadgdb-0e350a054bbeb4d00f2c430c4815c82d5ffb47a7.zip
gdb-0e350a054bbeb4d00f2c430c4815c82d5ffb47a7.tar.gz
gdb-0e350a054bbeb4d00f2c430c4815c82d5ffb47a7.tar.bz2
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.
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/gdb.texinfo74
2 files changed, 68 insertions, 11 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index fc16fc5..4dc1904 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,5 +1,10 @@
2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
+ * gdb.texinfo (GDB/MI File Commands): Document extensions to
+ -file-list-exec-source-files.
+
+2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
+
* python.texinfo (Breakpoints In Python): Add BP_CATCHPOINT
description.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index dfc00b1..1e56c3a 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -35623,18 +35623,49 @@ The @value{GDBN} equivalent is @samp{info source}
@subheading The @code{-file-list-exec-source-files} Command
+@kindex info sources
@findex -file-list-exec-source-files
@subsubheading Synopsis
@smallexample
- -file-list-exec-source-files
-@end smallexample
+ -file-list-exec-source-files @r{[} @var{--dirname} @r{|} @var{--basename} @r{]}
+ @r{[} -- @r{]}
+ @r{[} @var{regexp} @r{]}
+@end smallexample
+
+This command returns information about the source files @value{GDBN}
+knows about, it will output both the filename and fullname (absolute
+file name) of a source file, though the fullname can be elided if this
+information is not known to @value{GDBN}.
+
+With no arguments this command returns a list of source files. Each
+source file is represented by a tuple with the fields; @var{file},
+@var{fullname}, and @var{debug-fully-read}. The @var{file} is the
+display name for the file, while @var{fullname} is the absolute name
+of the file. The @var{fullname} field can be elided if the absolute
+name of the source file can't be computed. The field
+@var{debug-fully-read} will be a string, either @code{true} or
+@code{false}. When @code{true}, this indicates the full debug
+information for the compilation unit describing this file has been
+read in. When @code{false}, the full debug information has not yet
+been read in. While reading in the full debug information it is
+possible that @value{GDBN} could become aware of additional source
+files.
-List the source files for the current executable.
+The optional @var{regexp} can be used to filter the list of source
+files returned. The @var{regexp} will be matched against the full
+source file name. The matching is case-sensitive, except on operating
+systems that have case-insensitive filesystem (e.g.,
+MS-Windows). @samp{--} can be used before @var{regexp} to prevent
+@value{GDBN} interpreting @var{regexp} as a command option (e.g.@: if
+@var{regexp} starts with @samp{-}).
-It will always output both the filename and fullname (absolute file
-name) of a source file.
+If @code{--dirname} is provided, then @var{regexp} is matched only
+against the directory name of each source file. If @code{--basename}
+is provided, then @var{regexp} is matched against the basename of each
+source file. Only one of @code{--dirname} or @code{--basename} may be
+given, and if either is given then @var{regexp} is required.
@subsubheading @value{GDBN} Command
@@ -35643,13 +35674,34 @@ The @value{GDBN} equivalent is @samp{info sources}.
@subsubheading Example
@smallexample
-(gdb)
+(@value{GDBP})
-file-list-exec-source-files
-^done,files=[
-@{file=foo.c,fullname=/home/foo.c@},
-@{file=/home/bar.c,fullname=/home/bar.c@},
-@{file=gdb_could_not_find_fullpath.c@}]
-(gdb)
+^done,files=[@{file="foo.c",fullname="/home/foo.c",debug-fully-read="true"@},
+ @{file="/home/bar.c",fullname="/home/bar.c",debug-fully-read="true"@},
+ @{file="gdb_could_not_find_fullpath.c",debug-fully-read="true"@}]
+(@value{GDBP})
+-file-list-exec-source-files
+^done,files=[@{file="test.c",
+ fullname="/tmp/info-sources/test.c",
+ debug-fully-read="true"@},
+ @{file="/usr/include/stdc-predef.h",
+ fullname="/usr/include/stdc-predef.h",
+ debug-fully-read="true"@},
+ @{file="header.h",
+ fullname="/tmp/info-sources/header.h",
+ debug-fully-read="true"@},
+ @{file="helper.c",
+ fullname="/tmp/info-sources/helper.c",
+ debug-fully-read="true"@}]
+(@value{GDBP})
+-file-list-exec-source-files -- \\.c
+^done,files=[@{file="test.c",
+ fullname="/tmp/info-sources/test.c",
+ debug-fully-read="true"@},
+ @{file="helper.c",
+ fullname="/tmp/info-sources/helper.c",
+ debug-fully-read="true"@}]
+(@value{GDBP})
@end smallexample
@subheading The @code{-file-list-shared-libraries} Command