summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.fortran
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2019-07-09 21:38:59 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2019-10-31 23:02:59 +0000
commit59c35742fb785b1e454f45c2ace663000bf34f4c (patch)
tree572be0b410f0065fd9bf704b320e0bd7388b6a87 /gdb/testsuite/gdb.fortran
parentaed61d02fb112ac2b94f67df3ed24ed29dcf911e (diff)
downloadbinutils-gdb-59c35742fb785b1e454f45c2ace663000bf34f4c.tar.gz
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/testsuite/gdb.fortran')
-rw-r--r--gdb/testsuite/gdb.fortran/info-modules.exp66
-rw-r--r--gdb/testsuite/gdb.fortran/info-types-2.f9020
-rw-r--r--gdb/testsuite/gdb.fortran/info-types.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/info-types.f903
4 files changed, 91 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
new file mode 100644
index 00000000000..f961d28b000
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -0,0 +1,66 @@
+# 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/>.
+
+# This file tests 'info modules'.
+
+load_lib "fortran.exp"
+
+if { [skip_fortran_tests] } { continue }
+
+standard_testfile info-types.f90 info-types-2.f90
+
+if { [prepare_for_testing "failed to prepare" $testfile \
+ [list $srcfile $srcfile2] {debug f90}] } {
+ return -1
+}
+
+if { ![runto MAIN__] } {
+ perror "Could not run to breakpoint `MAIN__'."
+ continue
+}
+
+gdb_test "info modules" \
+ [multi_line \
+ "All defined modules:" \
+ "" \
+ "File .*${srcfile2}:" \
+ "18:\[\t \]+mod2" \
+ "" \
+ "File .*${srcfile}:" \
+ "16:\[\t \]+mod1" ]
+
+gdb_test "info modules 1" \
+ [multi_line \
+ "All modules matching regular expression \"1\":" \
+ "" \
+ "File .*${srcfile}:" \
+ "16:\[\t \]+mod1" ]
+
+gdb_test "info modules 2" \
+ [multi_line \
+ "All modules matching regular expression \"2\":" \
+ "" \
+ "File .*${srcfile2}:" \
+ "18:\[\t \]+mod2" ]
+
+gdb_test "info modules mod" \
+ [multi_line \
+ "All modules matching regular expression \"mod\":" \
+ "" \
+ "File .*${srcfile2}:" \
+ "18:\[\t \]+mod2" \
+ "" \
+ "File .*${srcfile}:" \
+ "16:\[\t \]+mod1" ]
diff --git a/gdb/testsuite/gdb.fortran/info-types-2.f90 b/gdb/testsuite/gdb.fortran/info-types-2.f90
new file mode 100644
index 00000000000..a4044184233
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/info-types-2.f90
@@ -0,0 +1,20 @@
+! 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 2 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/>.
+
+! Comment just to change the line number on which
+! mod2 is defined.
+module mod2
+ integer :: mod2_var_1 = 123
+end module mod2
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 30646287ee9..954e083e406 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -19,9 +19,10 @@ load_lib "fortran.exp"
if { [skip_fortran_tests] } { continue }
-standard_testfile .f90
+standard_testfile info-types.f90 info-types-2.f90
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] } {
+if { [prepare_for_testing "failed to prepare" $testfile \
+ [list $srcfile2 $srcfile] {debug f90}] } {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/info-types.f90 b/gdb/testsuite/gdb.fortran/info-types.f90
index 0e27e1ddf08..ec52ef98efc 100644
--- a/gdb/testsuite/gdb.fortran/info-types.f90
+++ b/gdb/testsuite/gdb.fortran/info-types.f90
@@ -21,6 +21,7 @@ end module mod1
program info_types_test
use mod1
+ use mod2
type :: s1
integer :: a
@@ -30,7 +31,7 @@ program info_types_test
type (s1) :: var_a
type (m1t1) :: var_b
- var_a%a = 1
+ var_a%a = 1 + mod2_var_1
var_b%b = 2
l = .FALSE.
end program info_types_test