Commit | Line | Data |
---|---|---|
b6ba6518 | 1 | # Copyright 1999, 2000 Free Software Foundation, Inc. |
fb40c209 AC |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 2 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program; if not, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | # | |
20 | # Test essential Machine interface (MI) operations | |
21 | # | |
22 | # Verify that, using the MI, we can run a simple program and look at registers. | |
23 | # | |
24 | # The goal is not to test gdb functionality, which is done by other tests, | |
25 | # but to verify the correct output response to MI operations. | |
26 | # | |
27 | ||
28 | ||
29 | load_lib mi-support.exp | |
b30bf9ee | 30 | set MIFLAGS "-i=mi" |
fb40c209 AC |
31 | |
32 | gdb_exit | |
33 | if [mi_gdb_start] { | |
34 | continue | |
35 | } | |
36 | ||
37 | set testfile "basics" | |
38 | set srcfile ${testfile}.c | |
39 | set binfile ${objdir}/${subdir}/${testfile} | |
40 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
41 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
42 | } | |
43 | ||
44 | mi_delete_breakpoints | |
45 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
46 | mi_gdb_load ${binfile} | |
47 | ||
48 | proc test_breakpoints_creation_and_listing {} { | |
49 | global mi_gdb_prompt | |
50 | global srcfile | |
51 | global hex | |
52 | ||
53 | # Insert some breakpoints and list them | |
54 | # Also, disable some so they do not interfere with other tests | |
55 | # Tests: | |
56 | # -break-insert | |
57 | # -break-list | |
58 | # -break-disable | |
59 | # -break-info | |
60 | ||
61 | mi_gdb_test "200-break-insert main" \ | |
62 | "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ | |
63 | "break-insert operation" | |
64 | ||
65 | mi_gdb_test "204-break-list" \ | |
66 | "204\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}\}" \ | |
67 | "list of breakpoints" | |
68 | } | |
69 | ||
70 | proc test_running_the_program {} { | |
71 | global mi_gdb_prompt | |
72 | global hex | |
73 | ||
74 | # Run the program without args | |
75 | # Tests: | |
76 | # -exec-run | |
77 | ||
78 | # mi_gdb_test cannot be used for asynchronous commands because there are | |
79 | # two prompts involved and this can lead to a race condition. | |
80 | # FIXME: We are accepting a duplicate file and line info temporarely. | |
81 | # The following is equivalent to a send_gdb "000-exec-run\n" | |
82 | mi_run_cmd | |
83 | # The running part has been checked already by mi_run_cmd | |
84 | gdb_expect { | |
fe766f11 | 85 | -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"32\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
86 | pass "run to main" |
87 | } | |
88 | -re ".*$mi_gdb_prompt$" {fail "run to main (2)"} | |
89 | timeout {fail "run to main (timeout 2)"} | |
90 | } | |
91 | } | |
92 | ||
93 | proc sparc_register_tests_no_exec { } { | |
94 | # Test the generic IDT chip. | |
95 | mi_gdb_test "111-data-list-register-values" \ | |
96 | ".*111\\^error,msg=\"mi_cmd_data_list_register_values: Usage: -data-list-register-values <format> \\\[<regnum1>...<regnumN>\\\]\"" \ | |
97 | "wrong arguments" | |
98 | ||
99 | mi_gdb_test "111-data-list-register-values x" \ | |
100 | ".*111\\^error,msg=\"mi_cmd_data_list_register_values: No registers\.\"" \ | |
101 | "no executable" | |
102 | } | |
103 | ||
104 | # These tests exercise IDT-specific MIPS registers for several | |
105 | # different processor models. | |
106 | ||
107 | # This should detect the actual processor in use and change | |
108 | # the expected results appropriately. FIXME | |
109 | ||
110 | proc sparc_register_tests { } { | |
111 | global hex | |
112 | global decimal | |
113 | set octal "\[0-7\]+" | |
114 | set binary "\[0-1\]+" | |
115 | set float "-?\[0-9\]+(\.\[0-9\]+)?(e\[+\-\]\[0-9\]+)?" | |
116 | set float2 "\-?\[0-9\]+" | |
117 | ||
118 | mi_gdb_test "111-data-list-register-names" \ | |
173d6894 | 119 | "111\\^done,register-names=\\\[\"g0\",\"g1\",\"g2\",\"g3\",\"g4\",\"g5\",\"g6\",\"g7\",\"o0\",\"o1\",\"o2\",\"o3\",\"o4\",\"o5\",\"sp\",\"o7\",\"l0\",\"l1\",\"l2\",\"l3\",\"l4\",\"l5\",\"l6\",\"l7\",\"i0\",\"i1\",\"i2\",\"i3\",\"i4\",\"i5\",\"fp\",\"i7\",\"f0\",\"f1\",\"f2\",\"f3\",\"f4\",\"f5\",\"f6\",\"f7\",\"f8\",\"f9\",\"f10\",\"f11\",\"f12\",\"f13\",\"f14\",\"f15\",\"f16\",\"f17\",\"f18\",\"f19\",\"f20\",\"f21\",\"f22\",\"f23\",\"f24\",\"f25\",\"f26\",\"f27\",\"f28\",\"f29\",\"f30\",\"f31\",\"y\",\"psr\",\"wim\",\"tbr\",\"pc\",\"npc\",\"fpsr\",\"cpsr\"\\\]" \ |
fb40c209 AC |
120 | "list register names" |
121 | ||
122 | mi_gdb_test "222-data-list-register-values x" \ | |
80f43b40 | 123 | "222\\^done,register-values=\\\[\{number=\"0\",value=\"$hex\"\}.*\{number=\"71\",value=\"$hex\"\}\\\]" \ |
fb40c209 AC |
124 | "register values x" |
125 | ||
126 | mi_gdb_test "333-data-list-register-values f" \ | |
80f43b40 | 127 | "333\\^done,register-values=\\\[\{number=\"0\",value=\"$float\"\},\{number=\"1\",value=\"$float\"\},.*\{number=\"71\",value=\"$float\"\}\\\]" \ |
fb40c209 AC |
128 | "register values f" |
129 | ||
130 | mi_gdb_test "444-data-list-register-values d" \ | |
80f43b40 | 131 | "444\\^done,register-values=\\\[\{number=\"0\",value=\"$decimal\"\}.*\{number=\"71\",value=\"$decimal\"\}\\\]" \ |
fb40c209 AC |
132 | "register values d" |
133 | ||
134 | mi_gdb_test "555-data-list-register-values o" \ | |
80f43b40 | 135 | "555\\^done,register-values=\\\[\{number=\"0\",value=\"$octal\"\}.*\{number=\"71\",value=\"$octal\"\}\\\]" \ |
fb40c209 AC |
136 | "register values o" |
137 | ||
138 | mi_gdb_test "666-data-list-register-values t" \ | |
80f43b40 | 139 | "666\\^done,register-values=\\\[\{number=\"0\",value=\"$binary\"\}.*\{number=\"71\",value=\"$binary\"\}\\\]" \ |
fb40c209 AC |
140 | "register values t" |
141 | ||
142 | # On the sparc, registers 0-31 are int, 32-63 float, 64-71 int | |
143 | ||
144 | mi_gdb_test "777-data-list-register-values N" \ | |
80f43b40 | 145 | "777\\^done,register-values=\\\[\{number=\"0\",value=\"$decimal\"\}.*\{number=\"31\",value=\"$decimal\"\},\{number=\"32\",value=\"$float\"\}.*\{number=\"63\",value=\"$float\"\},\{number=\"64\",value=\"$decimal\"\}.*\{number=\"71\",value=\"$decimal\"\}\\\]" \ |
fb40c209 AC |
146 | "register values N" |
147 | ||
148 | mi_gdb_test "888-data-list-register-values r" \ | |
80f43b40 | 149 | "888\\^done,register-values=\\\[\{number=\"0\",value=\"$hex\"\}.*\{number=\"71\",value=\"$hex\"\}\\\]" \ |
fb40c209 AC |
150 | "register values r" |
151 | ||
152 | mi_gdb_test "999-data-list-register-names 68 69 70 71" \ | |
173d6894 | 153 | "999\\^done,register-names=\\\[\"pc\",\"npc\",\"fpsr\",\"cpsr\"\\\]" \ |
fb40c209 AC |
154 | "list names of some regs" |
155 | ||
156 | mi_gdb_test "001-data-list-register-values x 68 69 70 71" \ | |
80f43b40 | 157 | "001\\^done,register-values=\\\[\{number=\"68\",value=\"$hex\"\},\{number=\"69\",value=\"$hex\"\},\{number=\"70\",value=\"$hex\"\},\{number=\"71\",value=\"$hex\"\}\\\]" \ |
fb40c209 AC |
158 | "list values of some regs" |
159 | ||
160 | # Don't know how useful this test is | |
161 | ||
162 | mi_gdb_test "002-data-list-changed-registers" \ | |
40d5d7e9 | 163 | "002\\^done,changed-registers=\\\[\"1\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"30\",\"31\",\"65\",\"68\",\"69\"\\\]" \ |
fb40c209 AC |
164 | "list changed registers" |
165 | } | |
166 | ||
167 | if [istarget "sparc-*-*"] then { | |
168 | sparc_register_tests_no_exec | |
169 | test_breakpoints_creation_and_listing | |
170 | test_running_the_program | |
171 | sparc_register_tests | |
172 | } else { | |
173 | verbose "mi-regs.exp tests ignored for this target" | |
174 | } | |
175 | ||
176 | mi_gdb_exit | |
177 | return 0 |