1 |
578 |
markom |
# Copyright 1999, 2000 Free Software Foundation, Inc.
|
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 |
|
|
|
27 |
|
|
load_lib mi-support.exp
|
28 |
|
|
set MIFLAGS "-i=mi0"
|
29 |
|
|
|
30 |
|
|
gdb_exit
|
31 |
|
|
if [mi_gdb_start] {
|
32 |
|
|
continue
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
set testfile "basics"
|
36 |
|
|
set srcfile ${testfile}.c
|
37 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
38 |
|
|
if { [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 |
|
|
|
42 |
|
|
mi_delete_breakpoints
|
43 |
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
44 |
|
|
mi_gdb_load ${binfile}
|
45 |
|
|
|
46 |
|
|
proc 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 |
|
|
|
68 |
|
|
proc 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 |
|
|
|
91 |
|
|
proc test_disassembly_only {} {
|
92 |
|
|
global mi_gdb_prompt
|
93 |
|
|
global hex
|
94 |
|
|
global decimal
|
95 |
|
|
|
96 |
|
|
# Test disassembly more only for the current function.
|
97 |
|
|
# Tests:
|
98 |
|
|
# -data-disassemble -s $pc -e "$pc+8" -- 0
|
99 |
|
|
# -data-disassembly -f basics.c -l 32 -- 0
|
100 |
|
|
|
101 |
|
|
mi_gdb_test "print/x \$pc" "" ""
|
102 |
|
|
mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 0" \
|
103 |
|
|
"111\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\}" \
|
104 |
|
|
"data-disassemble from pc to pc+12 assembly only"
|
105 |
|
|
|
106 |
|
|
mi_gdb_test "222-data-disassemble -f basics.c -l 32 -- 0" \
|
107 |
|
|
"222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \
|
108 |
|
|
"data-disassemble file & line, assembly only"
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
proc test_disassembly_lines_limit {} {
|
112 |
|
|
global mi_gdb_prompt
|
113 |
|
|
global hex
|
114 |
|
|
global decimal
|
115 |
|
|
|
116 |
|
|
# Test disassembly more only for the current function.
|
117 |
|
|
# Tests:
|
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
|
121 |
|
|
|
122 |
|
|
mi_gdb_test "print/x \$pc" "" ""
|
123 |
|
|
mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 0" \
|
124 |
|
|
"222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \
|
125 |
|
|
"data-disassemble file, line, number assembly only"
|
126 |
|
|
|
127 |
|
|
mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 0" \
|
128 |
|
|
"222\\^done,asm_insns=\{\}" \
|
129 |
|
|
"data-disassemble file, line, number (zero lines) assembly only"
|
130 |
|
|
|
131 |
|
|
mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 0" \
|
132 |
|
|
"222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \
|
133 |
|
|
"data-disassemble file, line, number (more than main lines) assembly only"
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
proc 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:
|
144 |
|
|
# -data-disassembly -f basics.c -l 21 -- 1
|
145 |
|
|
# -data-disassembly -s $pc -e "$pc+8" -- 1
|
146 |
|
|
|
147 |
|
|
mi_gdb_test "002-data-disassemble -f basics.c -l 21 -- 1" \
|
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=\".*\"\}\}\}\}" \
|
149 |
|
|
"data-disassemble file, line assembly mixed"
|
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
|
154 |
|
|
# which we are now, even if we have specified that the range is only 2 insns.
|
155 |
|
|
#
|
156 |
|
|
mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 1" \
|
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=\".*\"\}\}\}\}" \
|
158 |
|
|
"data-disassemble range assembly mixed"
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
proc 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:
|
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
|
171 |
|
|
|
172 |
|
|
mi_gdb_test "print/x \$pc" "" ""
|
173 |
|
|
mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 1" \
|
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=\".*\"\}.*\}" \
|
175 |
|
|
"data-disassemble file, line, number assembly mixed"
|
176 |
|
|
|
177 |
|
|
mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 1" \
|
178 |
|
|
"222\\^done,asm_insns=\{src_and_asm_line=\{line=\"31\",file=\".*basics.c\",line_asm_insn=\{\}\}\}" \
|
179 |
|
|
"data-disassemble file, line, number (zero lines) assembly mixed"
|
180 |
|
|
|
181 |
|
|
mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 1" \
|
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=\".*\"\}.*\}" \
|
183 |
|
|
"data-disassemble file, line, number (more than main lines) assembly mixed"
|
184 |
|
|
}
|
185 |
|
|
|
186 |
|
|
proc 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:
|
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
|
196 |
|
|
|
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"
|
200 |
|
|
|
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"
|
204 |
|
|
|
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"
|
208 |
|
|
|
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"
|
212 |
|
|
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
test_breakpoints_creation_and_listing
|
216 |
|
|
test_running_the_program
|
217 |
|
|
test_disassembly_only
|
218 |
|
|
test_disassembly_mixed
|
219 |
|
|
test_disassembly_bogus_args
|
220 |
|
|
test_disassembly_lines_limit
|
221 |
|
|
test_disassembly_mixed_lines_limit
|
222 |
|
|
|
223 |
|
|
mi_gdb_exit
|
224 |
|
|
return 0
|