diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-10-03 22:12:09 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-11-27 12:02:02 +0000 |
commit | db5960b4d22761507097f816b1dac3bb56a22bb5 (patch) | |
tree | 211f7ccc6e5dd273b2c1f93e4dfc0a94f9e75d10 | |
parent | 7dc42066097ca6188ecd2c505d865e68d84998ee (diff) | |
download | gdb-db5960b4d22761507097f816b1dac3bb56a22bb5.zip gdb-db5960b4d22761507097f816b1dac3bb56a22bb5.tar.gz gdb-db5960b4d22761507097f816b1dac3bb56a22bb5.tar.bz2 |
gdb/mi: Add -symbol-info-modules command
Add '-symbol-info-modules', an MI version of the CLI 'info modules'
command.
gdb/ChangeLog:
* mi/mi-cmds.c (mi_cmds): Add 'symbol-info-modules' entry.
* mi/mi-cmds.h (mi_cmd_symbol_info_modules): Declare.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_info_modules): New function.
* NEWS: Mention new MI command.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-fortran-modules-2.f90: New file.
* gdb.mi/mi-fortran-modules.exp: New file.
* gdb.mi/mi-fortran-modules.f90: New file.
gdb/doc/ChangeLog:
* doc/gdb.texinfo (GDB/MI Symbol Query): Document new MI command
-symbol-info-modules.
Change-Id: Ibc618010d1d5f36ae8a8baba4fb9d9d724e62b0f
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/NEWS | 3 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 54 | ||||
-rw-r--r-- | gdb/mi/mi-cmds.c | 1 | ||||
-rw-r--r-- | gdb/mi/mi-cmds.h | 1 | ||||
-rw-r--r-- | gdb/mi/mi-symbol-cmds.c | 37 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90 | 33 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-fortran-modules.exp | 52 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-fortran-modules.f90 | 87 |
11 files changed, 286 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4f36f3d..6544661 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2019-11-27 Andrew Burgess <andrew.burgess@embecosm.com> + * mi/mi-cmds.c (mi_cmds): Add 'symbol-info-modules' entry. + * mi/mi-cmds.h (mi_cmd_symbol_info_modules): Declare. + * mi/mi-symbol-cmds.c (mi_cmd_symbol_info_modules): New function. + * NEWS: Mention new MI command. + +2019-11-27 Andrew Burgess <andrew.burgess@embecosm.com> + * mi/mi-cmds.c (mi_cmds): Add '-symbol-info-functions', '-symbol-info-types', and '-symbol-info-variables'. * mi/mi-cmds.h (mi_cmd_symbol_info_functions): Declare. @@ -370,6 +370,9 @@ focus, winheight, +, -, >, < These commands are the MI equivalent of the CLI commands 'info functions', 'info types', and 'info variables' respectively. +-symbol-info-modules, this is the MI equivalent of the CLI 'info + modules' command. + * Other MI changes ** The default version of the MI interpreter is now 3 (-i=mi3). diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index adbb052..2889538 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,6 +1,11 @@ 2019-11-27 Andrew Burgess <andrew.burgess@embecosm.com> * doc/gdb.texinfo (GDB/MI Symbol Query): Document new MI command + -symbol-info-modules. + +2019-11-27 Andrew Burgess <andrew.burgess@embecosm.com> + + * doc/gdb.texinfo (GDB/MI Symbol Query): Document new MI command -symbol-info-functions, -symbol-info-types, and -symbol-info-variables. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 6b879b7..478c95b 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -33995,6 +33995,60 @@ The corresponding @value{GDBN} command is @samp{info functions}. @end group @end smallexample +@subheading The @code{-symbol-info-modules} Command +@findex -symbol-info-modules +@anchor{-symbol-info-modules} + +@subsubheading Synopsis + +@smallexample + -symbol-info-modules [--name @var{name_regexp}] +@end smallexample + +@noindent +Return a list containing the names of all known Fortran modules. The +modules are grouped by source file, and shown with the line number on +which each modules is defined. + +The option @code{--name} allows the modules returned to be filtered +based the name of the module. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{info modules}. + +@subsubheading Example +@smallexample +@group +(gdb) +-symbol-info-modules +^done,symbols= + @{debug= + [@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90", + fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90", + symbols=[@{line="16",name="mod1"@}, + @{line="22",name="mod2"@}]@}, + @{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90", + fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90", + symbols=[@{line="16",name="mod3"@}, + @{line="22",name="modmany"@}, + @{line="26",name="moduse"@}]@}]@} +@end group +@group +(gdb) +-symbol-info-modules --name mod[123] +^done,symbols= + @{debug= + [@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90", + fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90", + symbols=[@{line="16",name="mod1"@}, + @{line="22",name="mod2"@}]@}, + @{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90", + fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90", + symbols=[@{line="16",name="mod3"@}]@}]@} +@end group +@end smallexample + @subheading The @code{-symbol-info-types} Command @findex -symbol-info-types @anchor{-symbol-info-types} diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index df9f25f..85c15ec 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -154,6 +154,7 @@ static struct mi_cmd mi_cmds[] = DEF_MI_CMD_MI ("symbol-info-functions", mi_cmd_symbol_info_functions), DEF_MI_CMD_MI ("symbol-info-variables", mi_cmd_symbol_info_variables), DEF_MI_CMD_MI ("symbol-info-types", mi_cmd_symbol_info_types), + DEF_MI_CMD_MI ("symbol-info-modules", mi_cmd_symbol_info_modules), DEF_MI_CMD_CLI ("target-attach", "attach", 1), DEF_MI_CMD_MI ("target-detach", mi_cmd_target_detach), DEF_MI_CMD_CLI ("target-disconnect", "disconnect", 0), diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index c2fd7d3..30de780 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -95,6 +95,7 @@ extern mi_cmd_argv_ftype mi_cmd_stack_list_variables; extern mi_cmd_argv_ftype mi_cmd_stack_select_frame; extern mi_cmd_argv_ftype mi_cmd_symbol_list_lines; extern mi_cmd_argv_ftype mi_cmd_symbol_info_functions; +extern mi_cmd_argv_ftype mi_cmd_symbol_info_modules; extern mi_cmd_argv_ftype mi_cmd_symbol_info_types; extern mi_cmd_argv_ftype mi_cmd_symbol_info_variables; extern mi_cmd_argv_ftype mi_cmd_target_detach; diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index f674dcf..10dd273 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -224,6 +224,43 @@ mi_cmd_symbol_info_functions (const char *command, char **argv, int argc) mi_info_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); } +/* Implement -symbol-inf-modules command. */ + +void +mi_cmd_symbol_info_modules (const char *command, char **argv, int argc) +{ + const char *regexp = nullptr; + + enum opt + { + NAME_REGEXP_OPT + }; + static const struct mi_opt opts[] = + { + {"-name", NAME_REGEXP_OPT, 1}, + { 0, 0, 0 } + }; + + int oind = 0; + char *oarg = nullptr; + + while (1) + { + int opt = mi_getopt ("-symbol-info-modules", argc, argv, opts, + &oind, &oarg); + if (opt < 0) + break; + switch ((enum opt) opt) + { + case NAME_REGEXP_OPT: + regexp = oarg; + break; + } + } + + mi_symbol_info (MODULES_DOMAIN, regexp, nullptr, true); +} + /* Implement -symbol-info-types command. */ void diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f8ce265..93e94f8 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2019-11-27 Andrew Burgess <andrew.burgess@embecosm.com> + * gdb.mi/mi-fortran-modules-2.f90: New file. + * gdb.mi/mi-fortran-modules.exp: New file. + * gdb.mi/mi-fortran-modules.f90: New file. + +2019-11-27 Andrew Burgess <andrew.burgess@embecosm.com> + * gdb.mi/mi-sym-info-1.c: New file. * gdb.mi/mi-sym-info-2.c: New file. * gdb.mi/mi-sym-info.exp: New file. diff --git a/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90 b/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90 new file mode 100644 index 0000000..690d54d --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90 @@ -0,0 +1,33 @@ +! Copyright 2009-2019 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/>. + +module mod1 + integer :: var_i = 1 + integer :: var_const + parameter (var_const = 20) +contains + subroutine check_all + if (var_i .ne. 1) call abort + if (var_const .ne. 20) call abort + end subroutine check_all +end module mod1 + +module mod2 + integer :: var_i = 2 +contains + subroutine check_var_i + if (var_i .ne. 2) call abort + end subroutine check_var_i +end module mod2 diff --git a/gdb/testsuite/gdb.mi/mi-fortran-modules.exp b/gdb/testsuite/gdb.mi/mi-fortran-modules.exp new file mode 100644 index 0000000..640bb12 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-fortran-modules.exp @@ -0,0 +1,52 @@ +# Copyright 2019 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/>. + +# Test -symbol-info-modules, listing Fortran modules. + +load_lib fortran.exp +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +standard_testfile "mi-fortran-modules.f90" "mi-fortran-modules-2.f90" + +if {[prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $srcfile2] {debug f90}]} { + return -1 +} + +gdb_exit +if {[mi_gdb_start]} { + continue +} + +mi_run_to_main + +mi_gdb_test "101-symbol-info-modules" \ + "101\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]+$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"16\",name=\"mod1\"\},\{line=\"27\",name=\"mod2\"\}\\\]\},\{filename=\"\[^\"\]+$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[\{line=\"16\",name=\"mod3\"\},\{line=\"32\",name=\"modmany\"\},\{line=\"41\",name=\"moduse\"\}\\\]\}\\\]\}" \ + "-symbol-info-modules" + +mi_gdb_test "102-symbol-info-modules --name mod\[123\]" \ + "102\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]+$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"16\",name=\"mod1\"\},\{line=\"27\",name=\"mod2\"\}\\\]\},\{filename=\"\[^\"\]+$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[\{line=\"16\",name=\"mod3\"\}\\\]\}\\\]\}" \ + "-symbol-info-modules --name mod\[123\]" + +mi_gdb_test "103-symbol-info-modules --name moduse" \ + "103\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]+$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[\{line=\"41\",name=\"moduse\"\}\\\]\}\\\]\}" \ + "-symbol-info-modules --name moduse" + + + + + + diff --git a/gdb/testsuite/gdb.mi/mi-fortran-modules.f90 b/gdb/testsuite/gdb.mi/mi-fortran-modules.f90 new file mode 100644 index 0000000..d254627 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-fortran-modules.f90 @@ -0,0 +1,87 @@ +! Copyright 2009-2019 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/>. + +module mod3 + integer :: mod2 = 3 + integer :: mod1 = 3 + integer :: var_i = 3 +contains + subroutine check_all + if (mod2 .ne. 3) call abort + if (mod1 .ne. 3) call abort + if (var_i .ne. 3) call abort + end subroutine check_all + + subroutine check_mod2 + if (mod2 .ne. 3) call abort + end subroutine check_mod2 +end module mod3 + +module modmany + integer :: var_a = 10, var_b = 11, var_c = 12, var_i = 14 +contains + subroutine check_some + if (var_a .ne. 10) call abort + if (var_b .ne. 11) call abort + end subroutine check_some +end module modmany + +module moduse + integer :: var_x = 30, var_y = 31 +contains + subroutine check_all + if (var_x .ne. 30) call abort + if (var_y .ne. 31) call abort + end subroutine check_all + + subroutine check_var_x + if (var_x .ne. 30) call abort + end subroutine check_var_x +end module moduse + +subroutine sub1 + use mod1 + if (var_i .ne. 1) call abort + var_i = var_i ! i-is-1 +end subroutine sub1 + +subroutine sub2 + use mod2 + if (var_i .ne. 2) call abort + var_i = var_i ! i-is-2 +end subroutine sub2 + +subroutine sub3 + use mod3 + var_i = var_i ! i-is-3 +end subroutine sub3 + +program module + + use modmany, only: var_b, var_d => var_c, var_i + use moduse, var_z => var_y + + call sub1 + call sub2 + call sub3 + + if (var_b .ne. 11) call abort + if (var_d .ne. 12) call abort + if (var_i .ne. 14) call abort + if (var_x .ne. 30) call abort + if (var_z .ne. 31) call abort + var_b = var_b ! a-b-c-d + +end program module |