diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-07-22 16:53:06 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-08-27 16:21:42 +0100 |
commit | 4acfdd20c9ef3c0368868b4221554f0abef04196 (patch) | |
tree | 09e8ed00b4bc0dfdbe8bb12f22a8822d20caeed4 /gdb/testsuite | |
parent | c4a23bf878f2e9a64034006c91596401faf6db3e (diff) | |
download | gdb-4acfdd20c9ef3c0368868b4221554f0abef04196.zip gdb-4acfdd20c9ef3c0368868b4221554f0abef04196.tar.gz gdb-4acfdd20c9ef3c0368868b4221554f0abef04196.tar.bz2 |
gdb: Add new -n flag to some info commands
The 'info variables', its alias 'whereis', and 'info functions' all
include non-debug symbols in the output by default. The list of
non-debug symbols can sometimes be quite long, resulting in the
debug symbol based results being scrolled off the screen.
This commit adds a '-n' flag to all of the commands listed above that
excludes the non-debug symbols from the results, leaving just the
debug symbol based results.
gdb/ChangeLog:
* cli/cli-utils.c (info_print_options_defs): Delete.
(make_info_print_options_def_group): Delete.
(extract_info_print_options): Delete.
(info_print_command_completer): Delete.
(info_print_args_help): Add extra parameter, and optionally
include text about -n flag.
* cli/cli-utils.h (struct info_print_options): Delete.
(extract_info_print_options): Delete declaration.
(info_print_command_completer): Delete declaration.
(info_print_args_help): Add extra parameter, extend header
comment.
* python/python.c (gdbpy_rbreak): Pass additional parameter to
search_symbols.
* stack.c (struct info_print_options): New type.
(info_print_options_defs): New file scoped variable.
(make_info_print_options_def_group): New static function.
(info_print_command_completer): New static function.
(info_locals_command): Update to use new local functions.
(info_args_command): Likewise.
(_initialize_stack): Add extra parameter to calls to
info_print_args_help.
* symtab.c (search_symbols): Add extra parameter, use this to
possibly excluse non-debug symbols.
(symtab_symbol_info): Add extra parameter, which is passed on to
search_symbols.
(struct info_print_options): New type.
(info_print_options_defs): New file scoped variable.
(make_info_print_options_def_group): New static function.
(info_print_command_completer): New static function.
(info_variables_command): Update to use local functions, and pass
extra parameter through to symtab_symbol_info.
(info_functions_command): Likewise.
(info_types_command): Pass additional argument through to
symtab_symbol_info.
(rbreak_command): Pass extra argument to search_symbols.
(_initialize_symtab): Add extra arguments for calls to
info_print_args_help, and update help text for 'info variables',
'whereis', and 'info functions' commands.
* symtab.h (search_symbols): Add extra argument to declaration.
* NEWS: Mention new flags.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Add information about the -n flag to
"info variables" and "info functions".
gdb/testsuite/ChangeLog:
* gdb.base/info-fun.exp: Extend to test the -n flag for 'info
functions'. Reindent as needed.
* gdb.base/info-var-f1.c: New file.
* gdb.base/info-var-f2.c: New file.
* gdb.base/info-var.exp: New file.
* gdb.base/info-var.h: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/info-fun.exp | 97 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/info-var-f1.c | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/info-var-f2.c | 26 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/info-var.exp | 60 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/info-var.h | 18 |
6 files changed, 190 insertions, 44 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 3117fe7..7b6793b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2019-08-27 Andrew Burgess <andrew.burgess@embecosm.com> + + * gdb.base/info-fun.exp: Extend to test the -n flag for 'info + functions'. Reindent as needed. + * gdb.base/info-var-f1.c: New file. + * gdb.base/info-var-f2.c: New file. + * gdb.base/info-var.exp: New file. + * gdb.base/info-var.h: New file. + 2019-08-26 Tom de Vries <tdevries@suse.de> PR c++/24852 diff --git a/gdb/testsuite/gdb.base/info-fun.exp b/gdb/testsuite/gdb.base/info-fun.exp index 208525e..cee3a09 100644 --- a/gdb/testsuite/gdb.base/info-fun.exp +++ b/gdb/testsuite/gdb.base/info-fun.exp @@ -30,54 +30,63 @@ if [get_compiler_info] { return -1 } -# SEP must be last for the possible `unsupported' error path. -foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" { +foreach_with_prefix n_flag { 0 1 } { - set sep_lib_flags $lib_flags - if {$libsepdebug != "NO"} { - lappend sep_lib_flags {debug} - } - if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $sep_lib_flags] != "" - || [gdb_compile $srcdir/$subdir/${srcfile} ${binfile} \ - executable $bin_flags] != "" } { - untested "failed to compile" - return -1 - } + # SEP must be last for the possible `unsupported' error path. + foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" { - if {$libsepdebug == "SEP"} { - if {[gdb_gnu_strip_debug $binfile_lib] != 0} { - unsupported "could not split debug of $binfile_lib." - return - } else { - pass "split solib" + set sep_lib_flags $lib_flags + if {$libsepdebug != "NO"} { + lappend sep_lib_flags {debug} + } + if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $sep_lib_flags] != "" + || [gdb_compile $srcdir/$subdir/${srcfile} ${binfile} \ + executable $bin_flags] != "" } { + untested "failed to compile" + return -1 } - } - clean_restart $executable + if {$libsepdebug == "SEP"} { + if {[gdb_gnu_strip_debug $binfile_lib] != 0} { + unsupported "could not split debug of $binfile_lib." + return + } else { + pass "split solib" + } + } + + clean_restart $executable + + if ![runto_main] then { + fail "can't run to main" + return 0 + } - if ![runto_main] then { - fail "can't run to main" - return 0 - } + set match_str {All functions matching regular expression "foo":[\r\n]*} + if { "$libsepdebug" != "NO" } { + append match_str {File .*/info-fun-solib[.]c:[\r\n]*} + append match_str {\d+:\tint foo\(void\);[\r\n]*} + } - set match_str {All functions matching regular expression "foo":[\r\n]*} - if { "$libsepdebug" != "NO" } { - append match_str {File .*/info-fun-solib[.]c:[\r\n]*} - append match_str {\d+:\tint foo\(void\);[\r\n]*} - } - append match_str {Non-debugging symbols:[\r\n]*} - # Note: Targets like {m68k,ppc64,s390x}-linux also have, e.g., - # 00000011.plt_call.foo+0 (m68k). - set plt_foo_match "($hex \[^\r\n\]*plt\[^\r\n\]*foo\[^\r\n\]*\[\r\n\]*)?" - append match_str $plt_foo_match - # This text we want to match precisely. - append match_str "$hex *foo(@plt)?\[\r\n\]*" - # Watch for again to not have to worry about the order of appearance. - append match_str $plt_foo_match - if { "$libsepdebug" == "NO" } { - # Note: The ".?" is for targets like m68k-linux that have ".foo" here. - append match_str "$hex *.?foo\[\r\n\]*" - } + set opt "" + if { !$n_flag } { + append match_str {Non-debugging symbols:[\r\n]*} + # Note: Targets like {m68k,ppc64,s390x}-linux also have, e.g., + # 00000011.plt_call.foo+0 (m68k). + set plt_foo_match "($hex \[^\r\n\]*plt\[^\r\n\]*foo\[^\r\n\]*\[\r\n\]*)?" + append match_str $plt_foo_match + # This text we want to match precisely. + append match_str "$hex *foo(@plt)?\[\r\n\]*" + # Watch for again to not have to worry about the order of appearance. + append match_str $plt_foo_match + if { "$libsepdebug" == "NO" } { + # Note: The ".?" is for targets like m68k-linux that have ".foo" here. + append match_str "$hex *.?foo\[\r\n\]*" + } + } else { + set opt "-n" + } - gdb_test "info fun foo" "$match_str" -}} + gdb_test "info fun $opt foo" "$match_str" + }} +} diff --git a/gdb/testsuite/gdb.base/info-var-f1.c b/gdb/testsuite/gdb.base/info-var-f1.c new file mode 100644 index 0000000..b0587f1 --- /dev/null +++ b/gdb/testsuite/gdb.base/info-var-f1.c @@ -0,0 +1,24 @@ +/* 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/>. */ + +#include "info-var.h" + +static int f1_var = -3; + +int +main () +{ + return global_var + get_offset() + f1_var; +} diff --git a/gdb/testsuite/gdb.base/info-var-f2.c b/gdb/testsuite/gdb.base/info-var-f2.c new file mode 100644 index 0000000..fdff696 --- /dev/null +++ b/gdb/testsuite/gdb.base/info-var-f2.c @@ -0,0 +1,26 @@ +/* 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/>. */ + +#include "info-var.h" + +int global_var = 1; + +static int f2_var = 2; + +int +get_offset (void) +{ + return f2_var; +} diff --git a/gdb/testsuite/gdb.base/info-var.exp b/gdb/testsuite/gdb.base/info-var.exp new file mode 100644 index 0000000..5a07d62 --- /dev/null +++ b/gdb/testsuite/gdb.base/info-var.exp @@ -0,0 +1,60 @@ +# 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/>. + +# Some basic testing of 'info variables'. + +standard_testfile info-var-f1.c info-var-f2.c + +if {[prepare_for_testing "failed to prepare" \ + "${testfile}" "$srcfile $srcfile2" "debug"]} { + return -1 +} + +if ![runto_main] then { + fail "can't run to main" + return 0 +} + +gdb_test "info variables" \ + [multi_line \ + "All defined variables:" \ + "" \ + "File .*${srcfile}:" \ + "18:\[ \t\]+static int f1_var;" \ + "" \ + "File .*${srcfile2}:" \ + "18:\[ \t\]+int global_var;" \ + "20:\[ \t\]+static int f2_var;" \ + "" \ + "Non-debugging symbols:" \ + ".*"] + +gdb_test "info variables -n" \ + [multi_line \ + "All defined variables:" \ + "" \ + "File .*${srcfile}:" \ + "18:\[ \t\]+static int f1_var;" \ + "" \ + "File .*${srcfile2}:" \ + "18:\[ \t\]+int global_var;" \ + "20:\[ \t\]+static int f2_var;" ] + +gdb_test "info variables -n global" \ + [multi_line \ + "All variables matching regular expression \"global\":" \ + "" \ + "File .*${srcfile2}:" \ + "18:\[ \t\]+int global_var;" ] diff --git a/gdb/testsuite/gdb.base/info-var.h b/gdb/testsuite/gdb.base/info-var.h new file mode 100644 index 0000000..d65db82 --- /dev/null +++ b/gdb/testsuite/gdb.base/info-var.h @@ -0,0 +1,18 @@ +/* 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/>. */ + +extern int global_var; + +extern int get_offset (void); |