summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorStafford Horne <shorne@gmail.com>2017-12-27 23:36:30 +0900
committerStafford Horne <shorne@gmail.com>2017-12-27 23:36:30 +0900
commitb67d92b06e6155a392a0c2d413f87d050880dbf4 (patch)
treeb3d1258041b0a04f1f4bf3cded01739878876229 /gdb
parent76bce0d1d5c4e434736ce4331bc987c7a1ee702c (diff)
reggroups: Add test and docs for `info reg $reggroup` feature
Until now this feature has existed but was not documented. Adding docs and tests. gdb/ChangeLog: yyyy-mm-dd Stafford Horne <shorne@gmail.com> * infcmd.c (_initialize_infcmd): Add help for info reg $reggroup and info all-registers $reggroup feature. gdb/doc/ChangeLog: yyyy-mm-dd Stafford Horne <shorne@gmail.com> * gdb.texinfo (Registers): Document info reg $reggroup feature. gdb/testsuite/ChangeLog: yyyy-mm-dd Stafford Horne <shorne@gmail.com> * gdb.base/reggroups.c: New file. * gdb.base/reggroups.exp: New file.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/gdb.texinfo5
-rw-r--r--gdb/infcmd.c8
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/reggroups.c22
-rw-r--r--gdb/testsuite/gdb.base/reggroups.exp113
7 files changed, 160 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c81c611e9a..1e753cd3f7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-27 Stafford Horne <shorne@gmail.com>
+
+ * infcmd.c (_initialize_infcmd): Add help for info reg $reggroup
+ and info all-registers $reggroup feature.
+
2017-12-23 Simon Marchi <simon.marchi@polymtl.ca>
* target-descriptions.c (print_c_tdesc)
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 319e0c3cad..e958c23d88 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2017-12-27 Stafford Horne <shorne@gmail.com>
+
+ * gdb.texinfo (Registers): Document info reg $reggroup feature.
+
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 60ed80c363..a16e79bc2a 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -11023,6 +11023,11 @@ and vector registers (in the selected stack frame).
Print the names and values of all registers, including floating-point
and vector registers (in the selected stack frame).
+@item info registers @var{reggroup} @dots{}
+Print the name and value of the registers in each of the specified
+@var{reggroup}s. The @var{reggoup} can be any of those returned by
+@code{maint print reggroups} (@pxref{Maintenance Commands}).
+
@item info registers @var{regname} @dots{}
Print the @dfn{relativized} value of each specified register @var{regname}.
As discussed in detail below, register values are normally relative to
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 8bde28eab6..1b63f9b730 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -3460,13 +3460,17 @@ interrupt all running threads in non-stop mode, use the -a option."));
c = add_info ("registers", info_registers_command, _("\
List of integer registers and their contents, for selected stack frame.\n\
-Register name as argument means describe only that register."));
+One or more register names as argument means describe the given registers.\n\
+One or more register group names as argument means describe the registers\n\
+in the named register groups."));
add_info_alias ("r", "registers", 1);
set_cmd_completer (c, reg_or_group_completer);
c = add_info ("all-registers", info_all_registers_command, _("\
List of all registers and their contents, for selected stack frame.\n\
-Register name as argument means describe only that register."));
+One or more register names as argument means describe the given registers.\n\
+One or more register group names as argument means describe the registers\n\
+in the named register groups."));
set_cmd_completer (c, reg_or_group_completer);
add_info ("program", info_program_command,
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ab65ca23db..4f708f0bfe 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-27 Stafford Horne <shorne@gmail.com>
+
+ * gdb.base/reggroups.c: New file.
+ * gdb.base/reggroups.exp: New file.
+
2017-12-18 Joel Brobecker <brobecker@adacore.com>
* gdb.dwarf2/ada-valprint-error.c: New file.
diff --git a/gdb/testsuite/gdb.base/reggroups.c b/gdb/testsuite/gdb.base/reggroups.c
new file mode 100644
index 0000000000..d39f8d1038
--- /dev/null
+++ b/gdb/testsuite/gdb.base/reggroups.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2015-2017 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/>. */
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/reggroups.exp b/gdb/testsuite/gdb.base/reggroups.exp
new file mode 100644
index 0000000000..91dc8b78c3
--- /dev/null
+++ b/gdb/testsuite/gdb.base/reggroups.exp
@@ -0,0 +1,113 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2017 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 listing reggroups and the registers in each group.
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
+ return -1
+}
+
+if ![runto_main] then {
+ fail "can't run to main"
+ return 0
+}
+
+set invalid_register_re "Invalid register .*"
+
+# Fetch all reggroups from 'maint print reggroups'.
+
+proc fetch_reggroups {test} {
+ global gdb_prompt
+
+ set reggroups {}
+ gdb_test_multiple "maint print reggroups" $test {
+ -re "maint print reggroups\r\n" {
+ exp_continue
+ }
+ -re "^ Group\[ \t\]+Type\[ \t\]+\r\n" {
+ exp_continue
+ }
+ -re "^ (\[0-9a-zA-Z-\]+)\[ \t\]+(user|internal)\[ \t\]+\r\n" {
+ lappend reggroups $expect_out(1,string)
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ gdb_assert "[llength $reggroups] != 0" $test
+ }
+ }
+
+ return $reggroups
+}
+
+# Fetch all registers for a reggroup from 'info reg <reggroup>'.
+
+proc fetch_reggroup_regs {reggroup test} {
+ global gdb_prompt
+ global invalid_register_re
+
+ # The command info reg <reggroup> will return something like the following:
+ #
+ # r0 0x0 0^M
+ # r1 0x7fdffc 0x7fdffc^M
+ # r2 0x7fe000 0x7fe000^M
+ # npc 0x23a8 0x23a8 <main+12>^M
+ # sr 0x8401 [ SM CY FO CID=0 ]^M
+ #
+ # We parse out and return the reg names, this is done by detecting
+ # that for each line we have a register name followed by a $hex number.
+ #
+ # Note: we will not return vector registers, but I think this is ok because
+ # for testing purposes we just want to ensure we get some registers and dont
+ # fail. Example vector register:
+ #
+ # xmm0 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, ... }}
+ #
+ set regs {}
+ gdb_test_multiple "info reg $reggroup" $test {
+ -re "info reg $reggroup\r\n" {
+ exp_continue
+ }
+ -re "^(\[0-9a-zA-Z-\]+)\[ \t\]+(0x\[0-9a-f\]+)\[ \t\]+(\[^\n\r\]+)\r\n" {
+ lappend regs $expect_out(1,string)
+ exp_continue
+ }
+ -re $invalid_register_re {
+ fail "$test (unexpected invalid register response)"
+ }
+ -re "$gdb_prompt $" {
+ pass $test
+ }
+ }
+ return $regs
+}
+
+set reggroups [fetch_reggroups "fetch reggroups"]
+set regcount 0
+foreach reggroup $reggroups {
+ set regs [fetch_reggroup_regs $reggroup "fetch reggroup regs $reggroup"]
+ set regcount [expr $regcount + [llength $regs]]
+}
+
+gdb_assert "[llength $regcount] != 0" "system has reggroup registers"
+
+# If this fails it means that probably someone changed the error text returned
+# for an invalid register argument. If that happens we should fix the pattern
+# here and in the fetch_reggroup_regs procedure above.
+gdb_test "info reg invalid-reggroup" $invalid_register_re \
+ "info reg invalid-reggroup should report 'Invalid register'"