]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/reggroups.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / reggroups.exp
CommitLineData
b67d92b0
SH
1# This testcase is part of GDB, the GNU debugger.
2
42a4f53d 3# Copyright 2017-2019 Free Software Foundation, Inc.
b67d92b0
SH
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18# Test listing reggroups and the registers in each group.
19
20standard_testfile
21
22if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
23 return -1
24}
25
26if ![runto_main] then {
27 fail "can't run to main"
28 return 0
29}
30
31set invalid_register_re "Invalid register .*"
32
33# Fetch all reggroups from 'maint print reggroups'.
34
35proc fetch_reggroups {test} {
36 global gdb_prompt
37
38 set reggroups {}
39 gdb_test_multiple "maint print reggroups" $test {
40 -re "maint print reggroups\r\n" {
41 exp_continue
42 }
43 -re "^ Group\[ \t\]+Type\[ \t\]+\r\n" {
44 exp_continue
45 }
a466edac 46 -re "^ (\[_0-9a-zA-Z-\]+)\[ \t\]+(user|internal)\[ \t\]+\r\n" {
b67d92b0
SH
47 lappend reggroups $expect_out(1,string)
48 exp_continue
49 }
50 -re "$gdb_prompt $" {
51 gdb_assert "[llength $reggroups] != 0" $test
52 }
53 }
54
55 return $reggroups
56}
57
58# Fetch all registers for a reggroup from 'info reg <reggroup>'.
59
60proc fetch_reggroup_regs {reggroup test} {
61 global gdb_prompt
62 global invalid_register_re
63
64 # The command info reg <reggroup> will return something like the following:
65 #
66 # r0 0x0 0^M
67 # r1 0x7fdffc 0x7fdffc^M
68 # r2 0x7fe000 0x7fe000^M
69 # npc 0x23a8 0x23a8 <main+12>^M
70 # sr 0x8401 [ SM CY FO CID=0 ]^M
71 #
72 # We parse out and return the reg names, this is done by detecting
73 # that for each line we have a register name followed by a $hex number.
74 #
75 # Note: we will not return vector registers, but I think this is ok because
76 # for testing purposes we just want to ensure we get some registers and dont
77 # fail. Example vector register:
78 #
79 # xmm0 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, ... }}
80 #
81 set regs {}
82 gdb_test_multiple "info reg $reggroup" $test {
83 -re "info reg $reggroup\r\n" {
84 exp_continue
85 }
86 -re "^(\[0-9a-zA-Z-\]+)\[ \t\]+(0x\[0-9a-f\]+)\[ \t\]+(\[^\n\r\]+)\r\n" {
87 lappend regs $expect_out(1,string)
88 exp_continue
89 }
90 -re $invalid_register_re {
91 fail "$test (unexpected invalid register response)"
92 }
93 -re "$gdb_prompt $" {
94 pass $test
95 }
96 }
97 return $regs
98}
99
100set reggroups [fetch_reggroups "fetch reggroups"]
101set regcount 0
102foreach reggroup $reggroups {
103 set regs [fetch_reggroup_regs $reggroup "fetch reggroup regs $reggroup"]
104 set regcount [expr $regcount + [llength $regs]]
105}
106
107gdb_assert "[llength $regcount] != 0" "system has reggroup registers"
108
109# If this fails it means that probably someone changed the error text returned
110# for an invalid register argument. If that happens we should fix the pattern
111# here and in the fetch_reggroup_regs procedure above.
112gdb_test "info reg invalid-reggroup" $invalid_register_re \
113 "info reg invalid-reggroup should report 'Invalid register'"