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
This commit is contained in:
parent
7dc4206609
commit
db5960b4d2
@ -1,3 +1,10 @@
|
||||
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',
|
||||
|
3
gdb/NEWS
3
gdb/NEWS
@ -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).
|
||||
|
@ -1,3 +1,8 @@
|
||||
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
|
||||
|
@ -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}
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,9 @@
|
||||
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.
|
||||
|
33
gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90
Normal file
33
gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90
Normal file
@ -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
|
52
gdb/testsuite/gdb.mi/mi-fortran-modules.exp
Normal file
52
gdb/testsuite/gdb.mi/mi-fortran-modules.exp
Normal file
@ -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"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
87
gdb/testsuite/gdb.mi/mi-fortran-modules.f90
Normal file
87
gdb/testsuite/gdb.mi/mi-fortran-modules.f90
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user