summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.mi
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2019-10-03 22:12:09 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2019-11-27 12:02:02 +0000
commitdb5960b4d22761507097f816b1dac3bb56a22bb5 (patch)
tree211f7ccc6e5dd273b2c1f93e4dfc0a94f9e75d10 /gdb/testsuite/gdb.mi
parent7dc42066097ca6188ecd2c505d865e68d84998ee (diff)
downloadbinutils-gdb-db5960b4d22761507097f816b1dac3bb56a22bb5.tar.gz
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
Diffstat (limited to 'gdb/testsuite/gdb.mi')
-rw-r--r--gdb/testsuite/gdb.mi/mi-fortran-modules-2.f9033
-rw-r--r--gdb/testsuite/gdb.mi/mi-fortran-modules.exp52
-rw-r--r--gdb/testsuite/gdb.mi/mi-fortran-modules.f9087
3 files changed, 172 insertions, 0 deletions
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 00000000000..690d54dde8c
--- /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 00000000000..640bb12642d
--- /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 00000000000..d2546270c6e
--- /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