diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-07-10 15:54:03 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-10-31 23:02:59 +0000 |
commit | 165f8965d770708f1dee623e308374ac108e6578 (patch) | |
tree | ba457b4dbe2fe85bf195d1da7feb22a8bab0abe7 /gdb/doc | |
parent | 59c35742fb785b1e454f45c2ace663000bf34f4c (diff) | |
download | gdb-165f8965d770708f1dee623e308374ac108e6578.zip gdb-165f8965d770708f1dee623e308374ac108e6578.tar.gz gdb-165f8965d770708f1dee623e308374ac108e6578.tar.bz2 |
gdb: Add new commands to list module variables and functions
This patch adds two new commands "info module functions" and "info
module variables". These commands list all of the functions and
variables grouped by module and then by file.
For example:
(gdb) info module functions
All functions in all modules:
Module "mod1":
File /some/path/gdb/testsuite/gdb.fortran/info-types.f90:
35: void mod1::__copy_mod1_M1t1(Type m1t1, Type m1t1);
25: void mod1::sub_m1_a(integer(kind=4));
31: integer(kind=4) mod1::sub_m1_b(void);
Module "mod2":
File /some/path/gdb/testsuite/gdb.fortran/info-types.f90:
41: void mod2::sub_m2_a(integer(kind=4), logical(kind=4));
49: logical(kind=4) mod2::sub_m2_b(real(kind=4));
The new commands take set of flags that allow the output to be
filtered, the user can filter by variable/function name, type, or
containing module.
As GDB doesn't currently track the relationship between a module and
the variables or functions within it in the symbol table, so I filter
based on the module prefix in order to find the functions or variables
in each module. What this makes clear is that a user could get this
same information using "info variables" and simply provide the prefix
themselves, for example:
(gdb) info module functions -m mod1 _a
All functions matching regular expression "_a",
in all modules matching regular expression "mod1":
Module "mod1":
File /some/path/gdb/testsuite/gdb.fortran/info-types.f90:
25: void mod1::sub_m1_a(integer(kind=4));
Is similar to:
(gdb) info functions mod1::.*_a.*
All functions matching regular expression "mod1::.*_a":
File /some/path/gdb/testsuite/gdb.fortran/info-types.f90:
25: void mod1::sub_m1_a(integer(kind=4));
The benefits I see for a separate command are that the user doesn't
have to think (or know) about the module prefix format, nor worry
about building a proper regexp. The user can also easily scan across
modules without having to build complex regexps.
The new function search_module_symbols is extern in this patch despite
only being used within symtab.c, this is because a later patch in this
series will also be using this function from outside symtab.c.
This patch is a new implementation of an idea originally worked on by
Mark O'Connor, Chris January, David Lecomber, and Xavier Oro from ARM.
gdb/ChangeLog:
* symtab.c (info_module_cmdlist): New variable.
(info_module_command): New function.
(search_module_symbols): New function.
(info_module_subcommand): New function.
(struct info_modules_var_func_options): New struct.
(info_modules_var_func_options_defs): New variable.
(make_info_modules_var_func_options_def_group): New function.
(info_module_functions_command): New function.
(info_module_variables_command): New function.
(info_module_var_func_command_completer): New function.
(_initialize_symtab): Register new 'info module functions' and
'info module variables' commands.
* symtab.h (typedef symbol_search_in_module): New typedef.
(search_module_symbols): Declare new function.
* NEWS: Mention new commands.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Document new 'info module variables' and
'info module functions' commands.
gdb/testsuite/ChangeLog:
* gdb.fortran/info-modules.exp: Update expected results, and add
additional tests for 'info module functinos', and 'info module
variables'.
* gdb.fortran/info-types.exp: Update expected results.
* gdb.fortran/info-types.f90: Extend testcase with additional
module variables and functions.
Change-Id: I8c2960640e2e101b77eff54027d687e21ec22e2b
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 52497a1..ce89ee4 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,5 +1,10 @@ 2019-10-31 Andrew Burgess <andrew.burgess@embecosm.com> + * gdb.texinfo (Symbols): Document new 'info module variables' and + 'info module functions' commands. + +2019-10-31 Andrew Burgess <andrew.burgess@embecosm.com> + * gdb.texinfo (Symbols): Document new 'info modules' command. 2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ee06df2..70e4be1 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -18896,6 +18896,25 @@ The optional flag @samp{-q}, which stands for @samp{quiet}, disables printing header information and messages explaining why no modules have been printed. +@kindex info module +@cindex Fortran modules, information about +@cindex functions and variables by Fortran module +@cindex module functions and variables +@item info module functions @r{[}-q@r{]} @r{[}-m @var{module-regexp}@r{]} @r{[}-t @var{type-regexp}@r{]} @r{[}@var{regexp}@r{]} +@itemx info module variables @r{[}-q@r{]} @r{[}-m @var{module-regexp}@r{]} @r{[}-t @var{type-regexp}@r{]} @r{[}@var{regexp}@r{]} +List all functions or variables within all Fortran modules. The set +of functions or variables listed can be limited by providing some or +all of the optional regular expressions. If @var{module-regexp} is +provided, then only Fortran modules matching @var{module-regexp} will +be searched. Only functions or variables whose type matches the +optional regular expression @var{type-regexp} will be listed. And +only functions or variables whose name matches the optional regular +expression @var{regexp} will be listed. + +The optional flag @samp{-q}, which stands for @samp{quiet}, disables +printing header information and messages explaining why no functions +or variables have been printed. + @kindex info classes @cindex Objective-C, classes and selectors @item info classes |