Eliminate the old mi/tui specific ChangeLog files as in ...
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-disassemble.exp
1 # Copyright 1999, 2000, 2002 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=mi"
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_disassembly_only {} {
47 global mi_gdb_prompt
48 global hex
49 global decimal
50
51 # Test disassembly more only for the current function.
52 # Tests:
53 # -data-disassemble -s $pc -e "$pc+8" -- 0
54 # -data-disassembly -f basics.c -l 32 -- 0
55
56 mi_gdb_test "print/x \$pc" "" ""
57 mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 0" \
58 "111\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\]" \
59 "data-disassemble from pc to pc+12 assembly only"
60
61 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -- 0" \
62 "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \
63 "data-disassemble file & line, assembly only"
64 }
65
66 proc test_disassembly_lines_limit {} {
67 global mi_gdb_prompt
68 global hex
69 global decimal
70
71 # Test disassembly more only for the current function.
72 # Tests:
73 # -data-disassembly -f basics.c -l 32 -n 20 -- 0
74 # -data-disassembly -f basics.c -l 32 -n 0 -- 0
75 # -data-disassembly -f basics.c -l 32 -n 50 -- 0
76
77 mi_gdb_test "print/x \$pc" "" ""
78 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 0" \
79 "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \
80 "data-disassemble file, line, number assembly only"
81
82 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 0" \
83 "222\\^done,asm_insns=\\\[\\\]" \
84 "data-disassemble file, line, number (zero lines) assembly only"
85
86 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 0" \
87 "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \
88 "data-disassemble file, line, number (more than main lines) assembly only"
89 }
90
91
92 proc test_disassembly_mixed {} {
93 global mi_gdb_prompt
94 global hex
95 global decimal
96
97 # Test disassembly more only for the current function.
98 # Tests:
99 # -data-disassembly -f basics.c -l 21 -- 1
100 # -data-disassembly -s $pc -e "$pc+8" -- 1
101
102 mi_gdb_test "002-data-disassemble -f basics.c -l 21 -- 1" \
103 "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=\".*\"\}\\\]\}\\\]" \
104 "data-disassemble file, line assembly mixed"
105
106 #
107 # In mixed mode, the lowest level of granularity is the source line.
108 # So we are going to get the disassembly for the source line at
109 # which we are now, even if we have specified that the range is only 2 insns.
110 #
111 mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 1" \
112 "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=\".*\"\}\\\]\}\\\]" \
113 "data-disassemble range assembly mixed"
114 }
115
116 proc test_disassembly_mixed_lines_limit {} {
117 global mi_gdb_prompt
118 global hex
119 global decimal
120
121 # Test disassembly more only for the current function.
122 # Tests:
123 # -data-disassembly -f basics.c -l 32 -n 20 -- 1
124 # -data-disassembly -f basics.c -l 32 -n 0 -- 1
125 # -data-disassembly -f basics.c -l 32 -n 50 -- 1
126
127 mi_gdb_test "print/x \$pc" "" ""
128 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 1" \
129 "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=\".*\"\}\\\]\}\]" \
130 "data-disassemble file, line, number assembly mixed"
131
132 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 1" \
133 "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"31\",file=\".*basics.c\",line_asm_insn=\\\[\\\]\}\\\]" \
134 "data-disassemble file, line, number (zero lines) assembly mixed"
135
136 mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 1" \
137 "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=\".*\"\}\\\]\}\]" \
138 "data-disassemble file, line, number (more than main lines) assembly mixed"
139 }
140
141 proc test_disassembly_bogus_args {} {
142 global mi_gdb_prompt
143 global hex
144
145 # Test that bogus input to disassembly command is rejected.
146 # Tests:
147 # -data-disassembly -f foo -l abc -n 0 -- 0
148 # -data-disassembly -s foo -e bar -- 0
149 # -data-disassembly -s $pc -f basics.c -- 0
150 # -data-disassembly -f basics.c -l 32 -- 9
151
152 mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \
153 ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
154 "data-disassemble bogus filename"
155
156 mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
157 "321\\^error,msg=\"No symbol \\\\\"foo\\\\\" in current context.\"" \
158 "data-disassemble bogus address"
159
160 mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
161 "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
162 "data-disassemble mix different args"
163
164 mi_gdb_test "789-data-disassemble -f basics.c -l 32 -- 9" \
165 "789\\^error,msg=\"mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.\"" \
166 "data-disassemble wrong mode arg"
167
168 }
169
170 mi_run_to_main
171 test_disassembly_only
172 test_disassembly_mixed
173 test_disassembly_bogus_args
174 test_disassembly_lines_limit
175 test_disassembly_mixed_lines_limit
176
177 mi_gdb_exit
178 return 0
This page took 0.036302 seconds and 4 git commands to generate.