diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-07-09 21:38:59 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-10-31 23:02:59 +0000 |
commit | 59c35742fb785b1e454f45c2ace663000bf34f4c (patch) | |
tree | 572be0b410f0065fd9bf704b320e0bd7388b6a87 /gdb/symtab.c | |
parent | aed61d02fb112ac2b94f67df3ed24ed29dcf911e (diff) | |
download | gdb-59c35742fb785b1e454f45c2ace663000bf34f4c.zip gdb-59c35742fb785b1e454f45c2ace663000bf34f4c.tar.gz gdb-59c35742fb785b1e454f45c2ace663000bf34f4c.tar.bz2 |
gdb/fortran: Add new 'info modules' command
Add a new command 'info modules' that lists all of the modules GDB
knows about from the debug information.
A module is a debugging entity in the DWARF defined with
DW_TAG_module, currently Fortran is known to use this tag for its
modules. I'm not aware of any other language that currently makes use
of DW_TAG_module.
The output style is similar to the 'info type' output:
(gdb) info modules
All defined modules:
File info-types.f90:
16: mod1
24: mod2
(gdb)
Where the user is told the file the module is defined in and, on the
left hand side, the line number at which the module is defined along
with the name of the module.
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:
* dwarf2read.c (dw2_symtab_iter_next): Handle MODULE_DOMAIN.
(dw2_expand_marked_cus): Handle MODULES_DOMAIN.
(dw2_debug_names_iterator::next): Handle MODULE_DOMAIN and
MODULES_DOMAIN.
(scan_partial_symbols): Only create partial module symbols for non
declarations.
* psymtab.c (recursively_search_psymtabs): Handle MODULE_DOMAIN
and MODULES_DOMAIN.
* symtab.c (search_domain_name): Likewise.
(search_symbols): Likewise.
(print_symbol_info): Likewise.
(symtab_symbol_info): Likewise.
(info_modules_command): New function.
(_initialize_symtab): Register 'info modules' command.
* symtab.h (enum search_domain): Add MODULES_DOMAIN.
* NEWS: Mention new 'info modules' command.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Document new 'info modules' command.
gdb/testsuite/ChangeLog:
* gdb.fortran/info-modules.exp: New file.
* gdb.fortran/info-types.exp: Build with new file.
* gdb.fortran/info-types.f90: Include and use new module.
* gdb.fortran/info-types-2.f90: New file.
Change-Id: I2b781dd5a06bcad04620ccdc45f01a0f711adfad
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index 060e676..4c14eda 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -299,6 +299,7 @@ search_domain_name (enum search_domain e) case VARIABLES_DOMAIN: return "VARIABLES_DOMAIN"; case FUNCTIONS_DOMAIN: return "FUNCTIONS_DOMAIN"; case TYPES_DOMAIN: return "TYPES_DOMAIN"; + case MODULES_DOMAIN: return "MODULES_DOMAIN"; case ALL_DOMAIN: return "ALL_DOMAIN"; default: gdb_assert_not_reached ("bad search_domain"); } @@ -4482,7 +4483,7 @@ search_symbols (const char *regexp, enum search_domain kind, gdb::optional<compiled_regex> preg; gdb::optional<compiled_regex> treg; - gdb_assert (kind <= TYPES_DOMAIN); + gdb_assert (kind != ALL_DOMAIN); ourtype = types[kind]; ourtype2 = types2[kind]; @@ -4656,7 +4657,10 @@ search_symbols (const char *regexp, enum search_domain kind, sym))) || (kind == TYPES_DOMAIN && SYMBOL_CLASS (sym) == LOC_TYPEDEF - && SYMBOL_DOMAIN (sym) != MODULE_DOMAIN)))) + && SYMBOL_DOMAIN (sym) != MODULE_DOMAIN) + || (kind == MODULES_DOMAIN + && SYMBOL_DOMAIN (sym) == MODULE_DOMAIN + && SYMBOL_LINE (sym) != 0)))) { /* match */ result.emplace_back (i, sym); @@ -4787,6 +4791,11 @@ print_symbol_info (enum search_domain kind, printf_filtered (";\n"); } + /* Printing of modules is currently done here, maybe at some future + point we might want a language specific method to print the module + symbol so that we can customise the output more. */ + else if (kind == MODULES_DOMAIN) + printf_filtered ("%s\n", SYMBOL_PRINT_NAME (sym)); } /* This help function for symtab_symbol_info() prints information @@ -4827,11 +4836,11 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms, const char *t_regexp, int from_tty) { static const char * const classnames[] = - {"variable", "function", "type"}; + {"variable", "function", "type", "module"}; const char *last_filename = ""; int first = 1; - gdb_assert (kind <= TYPES_DOMAIN); + gdb_assert (kind != ALL_DOMAIN); if (regexp != nullptr && *regexp == '\0') regexp = nullptr; @@ -5050,6 +5059,22 @@ info_types_command_completer (struct cmd_list_element *ignore, symbol_completer (ignore, tracker, text, word); } +/* Implement the 'info modules' command. */ + +static void +info_modules_command (const char *args, int from_tty) +{ + info_types_options opts; + + auto grp = make_info_types_options_def_group (&opts); + gdb::option::process_options + (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); + if (args != nullptr && *args == '\0') + args = nullptr; + symtab_symbol_info (opts.quiet, true, args, MODULES_DOMAIN, NULL, + from_tty); +} + /* Breakpoint all functions matching regular expression. */ void @@ -6373,6 +6398,10 @@ Options:\n\ c = add_info ("sources", info_sources_command, info_sources_help.c_str ()); set_cmd_completer_handle_brkchars (c, info_sources_command_completer); + c = add_info ("modules", info_modules_command, + _("All module names, or those matching REGEXP.")); + set_cmd_completer_handle_brkchars (c, info_types_command_completer); + add_com ("rbreak", class_breakpoint, rbreak_command, _("Set a breakpoint for all functions matching REGEXP.")); |