]>
Commit | Line | Data |
---|---|---|
6aba47ca DJ |
1 | # Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007 |
2 | # Free Software Foundation, Inc. | |
fb40c209 AC |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
fb40c209 AC |
18 | # |
19 | # Test Machine interface (MI) operations for disassembly. | |
20 | # | |
21 | # The goal is not to test gdb functionality, which is done by other tests, | |
22 | # but to verify the correct output response to MI operations. | |
23 | # | |
24 | ||
25 | load_lib mi-support.exp | |
b30bf9ee | 26 | set MIFLAGS "-i=mi" |
fb40c209 AC |
27 | |
28 | gdb_exit | |
29 | if [mi_gdb_start] { | |
30 | continue | |
31 | } | |
32 | ||
33 | set testfile "basics" | |
34 | set srcfile ${testfile}.c | |
35 | set binfile ${objdir}/${subdir}/${testfile} | |
36 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
b60f0898 JB |
37 | untested mi-disassemble.exp |
38 | return -1 | |
fb40c209 AC |
39 | } |
40 | ||
41 | mi_delete_breakpoints | |
42 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
43 | mi_gdb_load ${binfile} | |
44 | ||
fb40c209 AC |
45 | proc test_disassembly_only {} { |
46 | global mi_gdb_prompt | |
47 | global hex | |
19e08fb3 | 48 | global decimal |
fb40c209 | 49 | |
45f07fef MC |
50 | set line_main_head [gdb_get_line_number "main ("] |
51 | set line_main_body [expr $line_main_head + 2] | |
52 | ||
fb40c209 AC |
53 | # Test disassembly more only for the current function. |
54 | # Tests: | |
e2d00831 | 55 | # -data-disassemble -s $pc -e "$pc+8" -- 0 |
45f07fef | 56 | # -data-disassembly -f basics.c -l $line_main_body -- 0 |
fb40c209 AC |
57 | |
58 | mi_gdb_test "print/x \$pc" "" "" | |
e2d00831 | 59 | mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 0" \ |
70242e8d | 60 | "111\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\]" \ |
e2d00831 | 61 | "data-disassemble from pc to pc+12 assembly only" |
fb40c209 | 62 | |
45f07fef | 63 | mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -- 0" \ |
70242e8d | 64 | "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \ |
e2d00831 | 65 | "data-disassemble file & line, assembly only" |
fb40c209 AC |
66 | } |
67 | ||
68 | proc test_disassembly_lines_limit {} { | |
69 | global mi_gdb_prompt | |
70 | global hex | |
19e08fb3 | 71 | global decimal |
fb40c209 | 72 | |
45f07fef MC |
73 | set line_main_head [gdb_get_line_number "main ("] |
74 | set line_main_body [expr $line_main_head + 2] | |
75 | ||
fb40c209 AC |
76 | # Test disassembly more only for the current function. |
77 | # Tests: | |
45f07fef MC |
78 | # -data-disassembly -f basics.c -l $line_main_body -n 20 -- 0 |
79 | # -data-disassembly -f basics.c -l $line_main_body -n 0 -- 0 | |
80 | # -data-disassembly -f basics.c -l $line_main_body -n 50 -- 0 | |
fb40c209 AC |
81 | |
82 | mi_gdb_test "print/x \$pc" "" "" | |
45f07fef | 83 | mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -n 20 -- 0" \ |
70242e8d | 84 | "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \ |
e2d00831 | 85 | "data-disassemble file, line, number assembly only" |
fb40c209 | 86 | |
45f07fef | 87 | mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -n 0 -- 0" \ |
70242e8d | 88 | "222\\^done,asm_insns=\\\[\\\]" \ |
e2d00831 | 89 | "data-disassemble file, line, number (zero lines) assembly only" |
fb40c209 | 90 | |
45f07fef | 91 | mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -n 50 -- 0" \ |
70242e8d | 92 | "222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \ |
e2d00831 | 93 | "data-disassemble file, line, number (more than main lines) assembly only" |
fb40c209 AC |
94 | } |
95 | ||
e2d00831 | 96 | |
fb40c209 AC |
97 | proc test_disassembly_mixed {} { |
98 | global mi_gdb_prompt | |
99 | global hex | |
100 | global decimal | |
101 | ||
45f07fef MC |
102 | set line_callee2_head [gdb_get_line_number "callee2 ("] |
103 | set line_callee2_open_brace [expr $line_callee2_head + 1] | |
104 | ||
fb40c209 AC |
105 | # Test disassembly more only for the current function. |
106 | # Tests: | |
45f07fef | 107 | # -data-disassembly -f basics.c -l $line_callee2_open_brace -- 1 |
e2d00831 | 108 | # -data-disassembly -s $pc -e "$pc+8" -- 1 |
fb40c209 | 109 | |
45f07fef MC |
110 | mi_gdb_test "002-data-disassemble -f basics.c -l $line_callee2_open_brace -- 1" \ |
111 | "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",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 | 112 | "data-disassemble file, line assembly mixed" |
fb40c209 AC |
113 | |
114 | # | |
115 | # In mixed mode, the lowest level of granularity is the source line. | |
116 | # So we are going to get the disassembly for the source line at | |
e2d00831 | 117 | # which we are now, even if we have specified that the range is only 2 insns. |
fb40c209 | 118 | # |
e2d00831 | 119 | mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 1" \ |
70242e8d | 120 | "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 | 121 | "data-disassemble range assembly mixed" |
fb40c209 AC |
122 | } |
123 | ||
124 | proc test_disassembly_mixed_lines_limit {} { | |
125 | global mi_gdb_prompt | |
126 | global hex | |
127 | global decimal | |
128 | ||
45f07fef MC |
129 | set line_main_head [gdb_get_line_number "main ("] |
130 | set line_main_open_brace [expr $line_main_head + 1] | |
131 | set line_main_body [expr $line_main_head + 2] | |
132 | ||
fb40c209 AC |
133 | # Test disassembly more only for the current function. |
134 | # Tests: | |
45f07fef MC |
135 | # -data-disassembly -f basics.c -l $line_main_body -n 20 -- 1 |
136 | # -data-disassembly -f basics.c -l $line_main_body -n 0 -- 1 | |
137 | # -data-disassembly -f basics.c -l $line_main_body -n 50 -- 1 | |
fb40c209 AC |
138 | |
139 | mi_gdb_test "print/x \$pc" "" "" | |
45f07fef | 140 | mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -n 20 -- 1" \ |
70242e8d | 141 | "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 | 142 | "data-disassemble file, line, number assembly mixed" |
fb40c209 | 143 | |
45f07fef MC |
144 | mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -n 0 -- 1" \ |
145 | "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_main_open_brace\",file=\".*basics.c\",line_asm_insn=\\\[\\\]\}\\\]" \ | |
e2d00831 | 146 | "data-disassemble file, line, number (zero lines) assembly mixed" |
fb40c209 | 147 | |
45f07fef | 148 | mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -n 50 -- 1" \ |
70242e8d | 149 | "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 | 150 | "data-disassemble file, line, number (more than main lines) assembly mixed" |
fb40c209 AC |
151 | } |
152 | ||
153 | proc test_disassembly_bogus_args {} { | |
154 | global mi_gdb_prompt | |
155 | global hex | |
156 | ||
45f07fef MC |
157 | set line_main_head [gdb_get_line_number "main ("] |
158 | set line_main_body [expr $line_main_head + 2] | |
159 | ||
fb40c209 AC |
160 | # Test that bogus input to disassembly command is rejected. |
161 | # Tests: | |
e2d00831 EZ |
162 | # -data-disassembly -f foo -l abc -n 0 -- 0 |
163 | # -data-disassembly -s foo -e bar -- 0 | |
164 | # -data-disassembly -s $pc -f basics.c -- 0 | |
165 | # -data-disassembly -f basics.c -l 32 -- 9 | |
fb40c209 | 166 | |
e2d00831 | 167 | mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \ |
39fb8e9e | 168 | "&.*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \ |
e2d00831 | 169 | "data-disassemble bogus filename" |
fb40c209 | 170 | |
e2d00831 | 171 | mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \ |
39fb8e9e | 172 | "&.*321\\^error,msg=\"No symbol \\\\\"foo\\\\\" in current context.\"" \ |
e2d00831 | 173 | "data-disassemble bogus address" |
fb40c209 | 174 | |
e2d00831 | 175 | mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \ |
39fb8e9e | 176 | "&.*456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \ |
e2d00831 | 177 | "data-disassemble mix different args" |
fb40c209 | 178 | |
45f07fef | 179 | mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \ |
39fb8e9e | 180 | "&.*789\\^error,msg=\"mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.\"" \ |
e2d00831 | 181 | "data-disassemble wrong mode arg" |
fb40c209 AC |
182 | |
183 | } | |
184 | ||
6afa27b0 | 185 | mi_run_to_main |
fb40c209 AC |
186 | test_disassembly_only |
187 | test_disassembly_mixed | |
188 | test_disassembly_bogus_args | |
189 | test_disassembly_lines_limit | |
190 | test_disassembly_mixed_lines_limit | |
fb40c209 AC |
191 | |
192 | mi_gdb_exit | |
193 | return 0 |