Rename gdb.mi/ChangeLog-mi to gdb.mi/ChangeLog. Update everything.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-disassemble.exp
CommitLineData
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#
21# Test Machine interface (MI) operations for disassembly.
22#
23# The goal is not to test gdb functionality, which is done by other tests,
24# but to verify the correct output response to MI operations.
25#
26
27load_lib mi-support.exp
b30bf9ee 28set MIFLAGS "-i=mi"
fb40c209
AC
29
30gdb_exit
31if [mi_gdb_start] {
32 continue
33}
34
35set testfile "basics"
36set srcfile ${testfile}.c
37set binfile ${objdir}/${subdir}/${testfile}
38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
39 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
40}
41
42mi_delete_breakpoints
43mi_gdb_reinitialize_dir $srcdir/$subdir
44mi_gdb_load ${binfile}
45
46proc test_breakpoints_creation_and_listing {} {
47 global mi_gdb_prompt
48 global srcfile
49 global hex
50
51 # Insert some breakpoints and list them
52 # Also, disable some so they do not interfere with other tests
53 # Tests:
54 # -break-insert
55 # -break-list
56 # -break-disable
57 # -break-info
58
59 mi_gdb_test "200-break-insert main" \
60 "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \
61 "break-insert operation"
62
63 mi_gdb_test "204-break-list" \
64 "204\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}\}" \
65 "list of breakpoints"
66}
67
68proc test_running_the_program {} {
69 global mi_gdb_prompt
70 global hex
71
72 # Run the program without args
73 # Tests:
74 # -exec-run
75
76 # mi_gdb_test cannot be used for asynchronous commands because there are
77 # two prompts involved and this can lead to a race condition.
78 # FIXME: We are accepting a duplicate file and line info temporarely.
79 # The following is equivalent to a send_gdb "000-exec-run\n"
80 mi_run_cmd
81 # The running part has been checked already by mi_run_cmd
82 gdb_expect {
83 -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"32\"\}\r\n$mi_gdb_prompt$" {
84 pass "run to main"
85 }
86 -re ".*$mi_gdb_prompt$" {fail "run to main (2)"}
87 timeout {fail "run to main (timeout 2)"}
88 }
89}
90
91proc test_disassembly_only {} {
92 global mi_gdb_prompt
93 global hex
19e08fb3 94 global decimal
fb40c209
AC
95
96 # Test disassembly more only for the current function.
97 # Tests:
e2d00831
EZ
98 # -data-disassemble -s $pc -e "$pc+8" -- 0
99 # -data-disassembly -f basics.c -l 32 -- 0
fb40c209
AC
100
101 mi_gdb_test "print/x \$pc" "" ""
e2d00831 102 mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 0" \
70242e8d 103 "111\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\]" \
e2d00831 104 "data-disassemble from pc to pc+12 assembly only"
fb40c209 105
e2d00831 106 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -- 0" \
70242e8d 107 "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \
e2d00831 108 "data-disassemble file & line, assembly only"
fb40c209
AC
109}
110
111proc test_disassembly_lines_limit {} {
112 global mi_gdb_prompt
113 global hex
19e08fb3 114 global decimal
fb40c209
AC
115
116 # Test disassembly more only for the current function.
117 # Tests:
e2d00831
EZ
118 # -data-disassembly -f basics.c -l 32 -n 20 -- 0
119 # -data-disassembly -f basics.c -l 32 -n 0 -- 0
120 # -data-disassembly -f basics.c -l 32 -n 50 -- 0
fb40c209
AC
121
122 mi_gdb_test "print/x \$pc" "" ""
e2d00831 123 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 0" \
70242e8d 124 "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \
e2d00831 125 "data-disassemble file, line, number assembly only"
fb40c209 126
e2d00831 127 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 0" \
70242e8d 128 "222\\^done,asm_insns=\\\[\\\]" \
e2d00831 129 "data-disassemble file, line, number (zero lines) assembly only"
fb40c209 130
e2d00831 131 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 0" \
70242e8d 132 "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \
e2d00831 133 "data-disassemble file, line, number (more than main lines) assembly only"
fb40c209
AC
134}
135
e2d00831 136
fb40c209
AC
137proc test_disassembly_mixed {} {
138 global mi_gdb_prompt
139 global hex
140 global decimal
141
142 # Test disassembly more only for the current function.
143 # Tests:
e2d00831
EZ
144 # -data-disassembly -f basics.c -l 21 -- 1
145 # -data-disassembly -s $pc -e "$pc+8" -- 1
fb40c209 146
e2d00831 147 mi_gdb_test "002-data-disassemble -f basics.c -l 21 -- 1" \
70242e8d 148 "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"21\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",inst=\".*\"\}.*\\\]\}.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\\\]" \
e2d00831 149 "data-disassemble file, line assembly mixed"
fb40c209
AC
150
151 #
152 # In mixed mode, the lowest level of granularity is the source line.
153 # So we are going to get the disassembly for the source line at
e2d00831 154 # which we are now, even if we have specified that the range is only 2 insns.
fb40c209 155 #
e2d00831 156 mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 1" \
70242e8d 157 "003\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\\\]" \
fb40c209 158 "data-disassemble range assembly mixed"
fb40c209
AC
159}
160
161proc test_disassembly_mixed_lines_limit {} {
162 global mi_gdb_prompt
163 global hex
164 global decimal
165
166 # Test disassembly more only for the current function.
167 # Tests:
19e08fb3
EZ
168 # -data-disassembly -f basics.c -l 32 -n 20 -- 1
169 # -data-disassembly -f basics.c -l 32 -n 0 -- 1
170 # -data-disassembly -f basics.c -l 32 -n 50 -- 1
fb40c209
AC
171
172 mi_gdb_test "print/x \$pc" "" ""
e2d00831 173 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 1" \
70242e8d 174 "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\]" \
e2d00831 175 "data-disassemble file, line, number assembly mixed"
fb40c209 176
e2d00831 177 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 1" \
70242e8d 178 "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"31\",file=\".*basics.c\",line_asm_insn=\\\[\\\]\}\\\]" \
e2d00831 179 "data-disassemble file, line, number (zero lines) assembly mixed"
fb40c209 180
e2d00831 181 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 1" \
70242e8d 182 "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\}.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\]" \
e2d00831 183 "data-disassemble file, line, number (more than main lines) assembly mixed"
fb40c209
AC
184}
185
186proc test_disassembly_bogus_args {} {
187 global mi_gdb_prompt
188 global hex
189
190 # Test that bogus input to disassembly command is rejected.
191 # Tests:
e2d00831
EZ
192 # -data-disassembly -f foo -l abc -n 0 -- 0
193 # -data-disassembly -s foo -e bar -- 0
194 # -data-disassembly -s $pc -f basics.c -- 0
195 # -data-disassembly -f basics.c -l 32 -- 9
fb40c209 196
e2d00831
EZ
197 mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \
198 ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
199 "data-disassemble bogus filename"
fb40c209 200
e2d00831
EZ
201 mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
202 "321\\^error,msg=\"No symbol \\\\\"foo\\\\\" in current context.\"" \
203 "data-disassemble bogus address"
fb40c209 204
e2d00831
EZ
205 mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
206 "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
207 "data-disassemble mix different args"
fb40c209 208
e2d00831
EZ
209 mi_gdb_test "789-data-disassemble -f basics.c -l 32 -- 9" \
210 "789\\^error,msg=\"mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.\"" \
211 "data-disassemble wrong mode arg"
fb40c209
AC
212
213}
214
215test_breakpoints_creation_and_listing
216test_running_the_program
217test_disassembly_only
218test_disassembly_mixed
219test_disassembly_bogus_args
220test_disassembly_lines_limit
221test_disassembly_mixed_lines_limit
fb40c209
AC
222
223mi_gdb_exit
224return 0
This page took 0.114538 seconds and 4 git commands to generate.